diff options
110 files changed, 4318 insertions, 1761 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index faea6349228f..658bac0cdc5e 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -25,7 +25,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ | |||
25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ | 25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ | 26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ | 27 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ |
28 | amdgpu_queue_mgr.o | 28 | amdgpu_queue_mgr.o amdgpu_vf_error.o |
29 | 29 | ||
30 | # add asic specific block | 30 | # add asic specific block |
31 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | 31 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index ff7bf1a9f967..51d1364cf185 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -68,13 +68,16 @@ | |||
68 | 68 | ||
69 | #include "gpu_scheduler.h" | 69 | #include "gpu_scheduler.h" |
70 | #include "amdgpu_virt.h" | 70 | #include "amdgpu_virt.h" |
71 | #include "amdgpu_gart.h" | ||
71 | 72 | ||
72 | /* | 73 | /* |
73 | * Modules parameters. | 74 | * Modules parameters. |
74 | */ | 75 | */ |
75 | extern int amdgpu_modeset; | 76 | extern int amdgpu_modeset; |
76 | extern int amdgpu_vram_limit; | 77 | extern int amdgpu_vram_limit; |
77 | extern int amdgpu_gart_size; | 78 | extern int amdgpu_vis_vram_limit; |
79 | extern unsigned amdgpu_gart_size; | ||
80 | extern int amdgpu_gtt_size; | ||
78 | extern int amdgpu_moverate; | 81 | extern int amdgpu_moverate; |
79 | extern int amdgpu_benchmarking; | 82 | extern int amdgpu_benchmarking; |
80 | extern int amdgpu_testing; | 83 | extern int amdgpu_testing; |
@@ -104,6 +107,7 @@ extern unsigned amdgpu_pcie_gen_cap; | |||
104 | extern unsigned amdgpu_pcie_lane_cap; | 107 | extern unsigned amdgpu_pcie_lane_cap; |
105 | extern unsigned amdgpu_cg_mask; | 108 | extern unsigned amdgpu_cg_mask; |
106 | extern unsigned amdgpu_pg_mask; | 109 | extern unsigned amdgpu_pg_mask; |
110 | extern unsigned amdgpu_sdma_phase_quantum; | ||
107 | extern char *amdgpu_disable_cu; | 111 | extern char *amdgpu_disable_cu; |
108 | extern char *amdgpu_virtual_display; | 112 | extern char *amdgpu_virtual_display; |
109 | extern unsigned amdgpu_pp_feature_mask; | 113 | extern unsigned amdgpu_pp_feature_mask; |
@@ -532,49 +536,6 @@ int amdgpu_fence_slab_init(void); | |||
532 | void amdgpu_fence_slab_fini(void); | 536 | void amdgpu_fence_slab_fini(void); |
533 | 537 | ||
534 | /* | 538 | /* |
535 | * GART structures, functions & helpers | ||
536 | */ | ||
537 | struct amdgpu_mc; | ||
538 | |||
539 | #define AMDGPU_GPU_PAGE_SIZE 4096 | ||
540 | #define AMDGPU_GPU_PAGE_MASK (AMDGPU_GPU_PAGE_SIZE - 1) | ||
541 | #define AMDGPU_GPU_PAGE_SHIFT 12 | ||
542 | #define AMDGPU_GPU_PAGE_ALIGN(a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) | ||
543 | |||
544 | struct amdgpu_gart { | ||
545 | dma_addr_t table_addr; | ||
546 | struct amdgpu_bo *robj; | ||
547 | void *ptr; | ||
548 | unsigned num_gpu_pages; | ||
549 | unsigned num_cpu_pages; | ||
550 | unsigned table_size; | ||
551 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | ||
552 | struct page **pages; | ||
553 | #endif | ||
554 | bool ready; | ||
555 | |||
556 | /* Asic default pte flags */ | ||
557 | uint64_t gart_pte_flags; | ||
558 | |||
559 | const struct amdgpu_gart_funcs *gart_funcs; | ||
560 | }; | ||
561 | |||
562 | int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev); | ||
563 | void amdgpu_gart_table_ram_free(struct amdgpu_device *adev); | ||
564 | int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev); | ||
565 | void amdgpu_gart_table_vram_free(struct amdgpu_device *adev); | ||
566 | int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev); | ||
567 | void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); | ||
568 | int amdgpu_gart_init(struct amdgpu_device *adev); | ||
569 | void amdgpu_gart_fini(struct amdgpu_device *adev); | ||
570 | int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, | ||
571 | int pages); | ||
572 | int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, | ||
573 | int pages, struct page **pagelist, | ||
574 | dma_addr_t *dma_addr, uint64_t flags); | ||
575 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev); | ||
576 | |||
577 | /* | ||
578 | * VMHUB structures, functions & helpers | 539 | * VMHUB structures, functions & helpers |
579 | */ | 540 | */ |
580 | struct amdgpu_vmhub { | 541 | struct amdgpu_vmhub { |
@@ -598,22 +559,20 @@ struct amdgpu_mc { | |||
598 | * about vram size near mc fb location */ | 559 | * about vram size near mc fb location */ |
599 | u64 mc_vram_size; | 560 | u64 mc_vram_size; |
600 | u64 visible_vram_size; | 561 | u64 visible_vram_size; |
601 | u64 gtt_size; | 562 | u64 gart_size; |
602 | u64 gtt_start; | 563 | u64 gart_start; |
603 | u64 gtt_end; | 564 | u64 gart_end; |
604 | u64 vram_start; | 565 | u64 vram_start; |
605 | u64 vram_end; | 566 | u64 vram_end; |
606 | unsigned vram_width; | 567 | unsigned vram_width; |
607 | u64 real_vram_size; | 568 | u64 real_vram_size; |
608 | int vram_mtrr; | 569 | int vram_mtrr; |
609 | u64 gtt_base_align; | ||
610 | u64 mc_mask; | 570 | u64 mc_mask; |
611 | const struct firmware *fw; /* MC firmware */ | 571 | const struct firmware *fw; /* MC firmware */ |
612 | uint32_t fw_version; | 572 | uint32_t fw_version; |
613 | struct amdgpu_irq_src vm_fault; | 573 | struct amdgpu_irq_src vm_fault; |
614 | uint32_t vram_type; | 574 | uint32_t vram_type; |
615 | uint32_t srbm_soft_reset; | 575 | uint32_t srbm_soft_reset; |
616 | struct amdgpu_mode_mc_save save; | ||
617 | bool prt_warning; | 576 | bool prt_warning; |
618 | uint64_t stolen_size; | 577 | uint64_t stolen_size; |
619 | /* apertures */ | 578 | /* apertures */ |
@@ -1159,7 +1118,9 @@ struct amdgpu_cs_parser { | |||
1159 | struct list_head validated; | 1118 | struct list_head validated; |
1160 | struct dma_fence *fence; | 1119 | struct dma_fence *fence; |
1161 | uint64_t bytes_moved_threshold; | 1120 | uint64_t bytes_moved_threshold; |
1121 | uint64_t bytes_moved_vis_threshold; | ||
1162 | uint64_t bytes_moved; | 1122 | uint64_t bytes_moved; |
1123 | uint64_t bytes_moved_vis; | ||
1163 | struct amdgpu_bo_list_entry *evictable; | 1124 | struct amdgpu_bo_list_entry *evictable; |
1164 | 1125 | ||
1165 | /* user fence */ | 1126 | /* user fence */ |
@@ -1231,7 +1192,9 @@ struct amdgpu_wb { | |||
1231 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); | 1192 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); |
1232 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); | 1193 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); |
1233 | int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb); | 1194 | int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb); |
1195 | int amdgpu_wb_get_256Bit(struct amdgpu_device *adev, u32 *wb); | ||
1234 | void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb); | 1196 | void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb); |
1197 | void amdgpu_wb_free_256bit(struct amdgpu_device *adev, u32 wb); | ||
1235 | 1198 | ||
1236 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); | 1199 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); |
1237 | 1200 | ||
@@ -1557,6 +1520,10 @@ struct amdgpu_device { | |||
1557 | spinlock_t gc_cac_idx_lock; | 1520 | spinlock_t gc_cac_idx_lock; |
1558 | amdgpu_rreg_t gc_cac_rreg; | 1521 | amdgpu_rreg_t gc_cac_rreg; |
1559 | amdgpu_wreg_t gc_cac_wreg; | 1522 | amdgpu_wreg_t gc_cac_wreg; |
1523 | /* protects concurrent se_cac register access */ | ||
1524 | spinlock_t se_cac_idx_lock; | ||
1525 | amdgpu_rreg_t se_cac_rreg; | ||
1526 | amdgpu_wreg_t se_cac_wreg; | ||
1560 | /* protects concurrent ENDPOINT (audio) register access */ | 1527 | /* protects concurrent ENDPOINT (audio) register access */ |
1561 | spinlock_t audio_endpt_idx_lock; | 1528 | spinlock_t audio_endpt_idx_lock; |
1562 | amdgpu_block_rreg_t audio_endpt_rreg; | 1529 | amdgpu_block_rreg_t audio_endpt_rreg; |
@@ -1593,6 +1560,7 @@ struct amdgpu_device { | |||
1593 | spinlock_t lock; | 1560 | spinlock_t lock; |
1594 | s64 last_update_us; | 1561 | s64 last_update_us; |
1595 | s64 accum_us; /* accumulated microseconds */ | 1562 | s64 accum_us; /* accumulated microseconds */ |
1563 | s64 accum_us_vis; /* for visible VRAM */ | ||
1596 | u32 log2_max_MBps; | 1564 | u32 log2_max_MBps; |
1597 | } mm_stats; | 1565 | } mm_stats; |
1598 | 1566 | ||
@@ -1687,6 +1655,8 @@ struct amdgpu_device { | |||
1687 | bool has_hw_reset; | 1655 | bool has_hw_reset; |
1688 | u8 reset_magic[AMDGPU_RESET_MAGIC_NUM]; | 1656 | u8 reset_magic[AMDGPU_RESET_MAGIC_NUM]; |
1689 | 1657 | ||
1658 | /* record last mm index being written through WREG32*/ | ||
1659 | unsigned long last_mm_index; | ||
1690 | }; | 1660 | }; |
1691 | 1661 | ||
1692 | static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) | 1662 | static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) |
@@ -1742,6 +1712,8 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v); | |||
1742 | #define WREG32_DIDT(reg, v) adev->didt_wreg(adev, (reg), (v)) | 1712 | #define WREG32_DIDT(reg, v) adev->didt_wreg(adev, (reg), (v)) |
1743 | #define RREG32_GC_CAC(reg) adev->gc_cac_rreg(adev, (reg)) | 1713 | #define RREG32_GC_CAC(reg) adev->gc_cac_rreg(adev, (reg)) |
1744 | #define WREG32_GC_CAC(reg, v) adev->gc_cac_wreg(adev, (reg), (v)) | 1714 | #define WREG32_GC_CAC(reg, v) adev->gc_cac_wreg(adev, (reg), (v)) |
1715 | #define RREG32_SE_CAC(reg) adev->se_cac_rreg(adev, (reg)) | ||
1716 | #define WREG32_SE_CAC(reg, v) adev->se_cac_wreg(adev, (reg), (v)) | ||
1745 | #define RREG32_AUDIO_ENDPT(block, reg) adev->audio_endpt_rreg(adev, (block), (reg)) | 1717 | #define RREG32_AUDIO_ENDPT(block, reg) adev->audio_endpt_rreg(adev, (block), (reg)) |
1746 | #define WREG32_AUDIO_ENDPT(block, reg, v) adev->audio_endpt_wreg(adev, (block), (reg), (v)) | 1718 | #define WREG32_AUDIO_ENDPT(block, reg, v) adev->audio_endpt_wreg(adev, (block), (reg), (v)) |
1747 | #define WREG32_P(reg, val, mask) \ | 1719 | #define WREG32_P(reg, val, mask) \ |
@@ -1792,50 +1764,6 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v); | |||
1792 | #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) | 1764 | #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) |
1793 | #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) | 1765 | #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) |
1794 | 1766 | ||
1795 | /* | ||
1796 | * RING helpers. | ||
1797 | */ | ||
1798 | static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) | ||
1799 | { | ||
1800 | if (ring->count_dw <= 0) | ||
1801 | DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n"); | ||
1802 | ring->ring[ring->wptr++ & ring->buf_mask] = v; | ||
1803 | ring->wptr &= ring->ptr_mask; | ||
1804 | ring->count_dw--; | ||
1805 | } | ||
1806 | |||
1807 | static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw) | ||
1808 | { | ||
1809 | unsigned occupied, chunk1, chunk2; | ||
1810 | void *dst; | ||
1811 | |||
1812 | if (unlikely(ring->count_dw < count_dw)) { | ||
1813 | DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n"); | ||
1814 | return; | ||
1815 | } | ||
1816 | |||
1817 | occupied = ring->wptr & ring->buf_mask; | ||
1818 | dst = (void *)&ring->ring[occupied]; | ||
1819 | chunk1 = ring->buf_mask + 1 - occupied; | ||
1820 | chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1; | ||
1821 | chunk2 = count_dw - chunk1; | ||
1822 | chunk1 <<= 2; | ||
1823 | chunk2 <<= 2; | ||
1824 | |||
1825 | if (chunk1) | ||
1826 | memcpy(dst, src, chunk1); | ||
1827 | |||
1828 | if (chunk2) { | ||
1829 | src += chunk1; | ||
1830 | dst = (void *)ring->ring; | ||
1831 | memcpy(dst, src, chunk2); | ||
1832 | } | ||
1833 | |||
1834 | ring->wptr += count_dw; | ||
1835 | ring->wptr &= ring->ptr_mask; | ||
1836 | ring->count_dw -= count_dw; | ||
1837 | } | ||
1838 | |||
1839 | static inline struct amdgpu_sdma_instance * | 1767 | static inline struct amdgpu_sdma_instance * |
1840 | amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | 1768 | amdgpu_get_sdma_instance(struct amdgpu_ring *ring) |
1841 | { | 1769 | { |
@@ -1898,7 +1826,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
1898 | #define amdgpu_ih_get_wptr(adev) (adev)->irq.ih_funcs->get_wptr((adev)) | 1826 | #define amdgpu_ih_get_wptr(adev) (adev)->irq.ih_funcs->get_wptr((adev)) |
1899 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) | 1827 | #define amdgpu_ih_decode_iv(adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) |
1900 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) | 1828 | #define amdgpu_ih_set_rptr(adev) (adev)->irq.ih_funcs->set_rptr((adev)) |
1901 | #define amdgpu_display_set_vga_render_state(adev, r) (adev)->mode_info.funcs->set_vga_render_state((adev), (r)) | ||
1902 | #define amdgpu_display_vblank_get_counter(adev, crtc) (adev)->mode_info.funcs->vblank_get_counter((adev), (crtc)) | 1829 | #define amdgpu_display_vblank_get_counter(adev, crtc) (adev)->mode_info.funcs->vblank_get_counter((adev), (crtc)) |
1903 | #define amdgpu_display_vblank_wait(adev, crtc) (adev)->mode_info.funcs->vblank_wait((adev), (crtc)) | 1830 | #define amdgpu_display_vblank_wait(adev, crtc) (adev)->mode_info.funcs->vblank_wait((adev), (crtc)) |
1904 | #define amdgpu_display_backlight_set_level(adev, e, l) (adev)->mode_info.funcs->backlight_set_level((e), (l)) | 1831 | #define amdgpu_display_backlight_set_level(adev, e, l) (adev)->mode_info.funcs->backlight_set_level((e), (l)) |
@@ -1911,8 +1838,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
1911 | #define amdgpu_display_page_flip_get_scanoutpos(adev, crtc, vbl, pos) (adev)->mode_info.funcs->page_flip_get_scanoutpos((adev), (crtc), (vbl), (pos)) | 1838 | #define amdgpu_display_page_flip_get_scanoutpos(adev, crtc, vbl, pos) (adev)->mode_info.funcs->page_flip_get_scanoutpos((adev), (crtc), (vbl), (pos)) |
1912 | #define amdgpu_display_add_encoder(adev, e, s, c) (adev)->mode_info.funcs->add_encoder((adev), (e), (s), (c)) | 1839 | #define amdgpu_display_add_encoder(adev, e, s, c) (adev)->mode_info.funcs->add_encoder((adev), (e), (s), (c)) |
1913 | #define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r)) | 1840 | #define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r)) |
1914 | #define amdgpu_display_stop_mc_access(adev, s) (adev)->mode_info.funcs->stop_mc_access((adev), (s)) | ||
1915 | #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s)) | ||
1916 | #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b)) | 1841 | #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b)) |
1917 | #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b)) | 1842 | #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b)) |
1918 | #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev)) | 1843 | #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev)) |
@@ -1927,7 +1852,8 @@ void amdgpu_pci_config_reset(struct amdgpu_device *adev); | |||
1927 | bool amdgpu_need_post(struct amdgpu_device *adev); | 1852 | bool amdgpu_need_post(struct amdgpu_device *adev); |
1928 | void amdgpu_update_display_priority(struct amdgpu_device *adev); | 1853 | void amdgpu_update_display_priority(struct amdgpu_device *adev); |
1929 | 1854 | ||
1930 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes); | 1855 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, |
1856 | u64 num_vis_bytes); | ||
1931 | void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain); | 1857 | void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain); |
1932 | bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo); | 1858 | bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo); |
1933 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages); | 1859 | int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages); |
@@ -1943,7 +1869,7 @@ bool amdgpu_ttm_tt_is_readonly(struct ttm_tt *ttm); | |||
1943 | uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, | 1869 | uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, |
1944 | struct ttm_mem_reg *mem); | 1870 | struct ttm_mem_reg *mem); |
1945 | void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base); | 1871 | void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base); |
1946 | void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); | 1872 | void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); |
1947 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); | 1873 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); |
1948 | int amdgpu_ttm_init(struct amdgpu_device *adev); | 1874 | int amdgpu_ttm_init(struct amdgpu_device *adev); |
1949 | void amdgpu_ttm_fini(struct amdgpu_device *adev); | 1875 | void amdgpu_ttm_fini(struct amdgpu_device *adev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 1e8e1123ddf4..ce443586a0c7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | |||
@@ -1686,7 +1686,7 @@ void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock) | |||
1686 | { | 1686 | { |
1687 | uint32_t bios_6_scratch; | 1687 | uint32_t bios_6_scratch; |
1688 | 1688 | ||
1689 | bios_6_scratch = RREG32(mmBIOS_SCRATCH_6); | 1689 | bios_6_scratch = RREG32(adev->bios_scratch_reg_offset + 6); |
1690 | 1690 | ||
1691 | if (lock) { | 1691 | if (lock) { |
1692 | bios_6_scratch |= ATOM_S6_CRITICAL_STATE; | 1692 | bios_6_scratch |= ATOM_S6_CRITICAL_STATE; |
@@ -1696,15 +1696,17 @@ void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock) | |||
1696 | bios_6_scratch |= ATOM_S6_ACC_MODE; | 1696 | bios_6_scratch |= ATOM_S6_ACC_MODE; |
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | WREG32(mmBIOS_SCRATCH_6, bios_6_scratch); | 1699 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) | 1702 | void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) |
1703 | { | 1703 | { |
1704 | uint32_t bios_2_scratch, bios_6_scratch; | 1704 | uint32_t bios_2_scratch, bios_6_scratch; |
1705 | 1705 | ||
1706 | bios_2_scratch = RREG32(mmBIOS_SCRATCH_2); | 1706 | adev->bios_scratch_reg_offset = mmBIOS_SCRATCH_0; |
1707 | bios_6_scratch = RREG32(mmBIOS_SCRATCH_6); | 1707 | |
1708 | bios_2_scratch = RREG32(adev->bios_scratch_reg_offset + 2); | ||
1709 | bios_6_scratch = RREG32(adev->bios_scratch_reg_offset + 6); | ||
1708 | 1710 | ||
1709 | /* let the bios control the backlight */ | 1711 | /* let the bios control the backlight */ |
1710 | bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE; | 1712 | bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE; |
@@ -1715,8 +1717,8 @@ void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) | |||
1715 | /* clear the vbios dpms state */ | 1717 | /* clear the vbios dpms state */ |
1716 | bios_2_scratch &= ~ATOM_S2_DEVICE_DPMS_STATE; | 1718 | bios_2_scratch &= ~ATOM_S2_DEVICE_DPMS_STATE; |
1717 | 1719 | ||
1718 | WREG32(mmBIOS_SCRATCH_2, bios_2_scratch); | 1720 | WREG32(adev->bios_scratch_reg_offset + 2, bios_2_scratch); |
1719 | WREG32(mmBIOS_SCRATCH_6, bios_6_scratch); | 1721 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); |
1720 | } | 1722 | } |
1721 | 1723 | ||
1722 | void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev) | 1724 | void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev) |
@@ -1724,7 +1726,7 @@ void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev) | |||
1724 | int i; | 1726 | int i; |
1725 | 1727 | ||
1726 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | 1728 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) |
1727 | adev->bios_scratch[i] = RREG32(mmBIOS_SCRATCH_0 + i); | 1729 | adev->bios_scratch[i] = RREG32(adev->bios_scratch_reg_offset + i); |
1728 | } | 1730 | } |
1729 | 1731 | ||
1730 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev) | 1732 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev) |
@@ -1738,20 +1740,30 @@ void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev) | |||
1738 | adev->bios_scratch[7] &= ~ATOM_S7_ASIC_INIT_COMPLETE_MASK; | 1740 | adev->bios_scratch[7] &= ~ATOM_S7_ASIC_INIT_COMPLETE_MASK; |
1739 | 1741 | ||
1740 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | 1742 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) |
1741 | WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]); | 1743 | WREG32(adev->bios_scratch_reg_offset + i, adev->bios_scratch[i]); |
1742 | } | 1744 | } |
1743 | 1745 | ||
1744 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, | 1746 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, |
1745 | bool hung) | 1747 | bool hung) |
1746 | { | 1748 | { |
1747 | u32 tmp = RREG32(mmBIOS_SCRATCH_3); | 1749 | u32 tmp = RREG32(adev->bios_scratch_reg_offset + 3); |
1748 | 1750 | ||
1749 | if (hung) | 1751 | if (hung) |
1750 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; | 1752 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
1751 | else | 1753 | else |
1752 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; | 1754 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
1753 | 1755 | ||
1754 | WREG32(mmBIOS_SCRATCH_3, tmp); | 1756 | WREG32(adev->bios_scratch_reg_offset + 3, tmp); |
1757 | } | ||
1758 | |||
1759 | bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev) | ||
1760 | { | ||
1761 | u32 tmp = RREG32(adev->bios_scratch_reg_offset + 7); | ||
1762 | |||
1763 | if (tmp & ATOM_S7_ASIC_INIT_COMPLETE_MASK) | ||
1764 | return false; | ||
1765 | else | ||
1766 | return true; | ||
1755 | } | 1767 | } |
1756 | 1768 | ||
1757 | /* Atom needs data in little endian format | 1769 | /* Atom needs data in little endian format |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h index 38d0fe32e5cd..b0d5d1d7fdba 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | |||
@@ -200,6 +200,7 @@ void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev); | |||
200 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); | 200 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); |
201 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, | 201 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, |
202 | bool hung); | 202 | bool hung); |
203 | bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev); | ||
203 | 204 | ||
204 | void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); | 205 | void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); |
205 | int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, | 206 | int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c index 4bdda56fccee..f9ffe8ef0cd6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | |||
@@ -66,41 +66,6 @@ void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev) | |||
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void amdgpu_atomfirmware_scratch_regs_save(struct amdgpu_device *adev) | ||
70 | { | ||
71 | int i; | ||
72 | |||
73 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
74 | adev->bios_scratch[i] = RREG32(adev->bios_scratch_reg_offset + i); | ||
75 | } | ||
76 | |||
77 | void amdgpu_atomfirmware_scratch_regs_restore(struct amdgpu_device *adev) | ||
78 | { | ||
79 | int i; | ||
80 | |||
81 | /* | ||
82 | * VBIOS will check ASIC_INIT_COMPLETE bit to decide if | ||
83 | * execute ASIC_Init posting via driver | ||
84 | */ | ||
85 | adev->bios_scratch[7] &= ~ATOM_S7_ASIC_INIT_COMPLETE_MASK; | ||
86 | |||
87 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
88 | WREG32(adev->bios_scratch_reg_offset + i, adev->bios_scratch[i]); | ||
89 | } | ||
90 | |||
91 | void amdgpu_atomfirmware_scratch_regs_engine_hung(struct amdgpu_device *adev, | ||
92 | bool hung) | ||
93 | { | ||
94 | u32 tmp = RREG32(adev->bios_scratch_reg_offset + 3); | ||
95 | |||
96 | if (hung) | ||
97 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; | ||
98 | else | ||
99 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; | ||
100 | |||
101 | WREG32(adev->bios_scratch_reg_offset + 3, tmp); | ||
102 | } | ||
103 | |||
104 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev) | 69 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev) |
105 | { | 70 | { |
106 | struct atom_context *ctx = adev->mode_info.atom_context; | 71 | struct atom_context *ctx = adev->mode_info.atom_context; |
@@ -130,3 +95,129 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev) | |||
130 | ctx->scratch_size_bytes = usage_bytes; | 95 | ctx->scratch_size_bytes = usage_bytes; |
131 | return 0; | 96 | return 0; |
132 | } | 97 | } |
98 | |||
99 | union igp_info { | ||
100 | struct atom_integrated_system_info_v1_11 v11; | ||
101 | }; | ||
102 | |||
103 | /* | ||
104 | * Return vram width from integrated system info table, if available, | ||
105 | * or 0 if not. | ||
106 | */ | ||
107 | int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev) | ||
108 | { | ||
109 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
110 | int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
111 | integratedsysteminfo); | ||
112 | u16 data_offset, size; | ||
113 | union igp_info *igp_info; | ||
114 | u8 frev, crev; | ||
115 | |||
116 | /* get any igp specific overrides */ | ||
117 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size, | ||
118 | &frev, &crev, &data_offset)) { | ||
119 | igp_info = (union igp_info *) | ||
120 | (mode_info->atom_context->bios + data_offset); | ||
121 | switch (crev) { | ||
122 | case 11: | ||
123 | return igp_info->v11.umachannelnumber * 64; | ||
124 | default: | ||
125 | return 0; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | union firmware_info { | ||
133 | struct atom_firmware_info_v3_1 v31; | ||
134 | }; | ||
135 | |||
136 | union smu_info { | ||
137 | struct atom_smu_info_v3_1 v31; | ||
138 | }; | ||
139 | |||
140 | union umc_info { | ||
141 | struct atom_umc_info_v3_1 v31; | ||
142 | }; | ||
143 | |||
144 | int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev) | ||
145 | { | ||
146 | struct amdgpu_mode_info *mode_info = &adev->mode_info; | ||
147 | struct amdgpu_pll *spll = &adev->clock.spll; | ||
148 | struct amdgpu_pll *mpll = &adev->clock.mpll; | ||
149 | uint8_t frev, crev; | ||
150 | uint16_t data_offset; | ||
151 | int ret = -EINVAL, index; | ||
152 | |||
153 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
154 | firmwareinfo); | ||
155 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
156 | &frev, &crev, &data_offset)) { | ||
157 | union firmware_info *firmware_info = | ||
158 | (union firmware_info *)(mode_info->atom_context->bios + | ||
159 | data_offset); | ||
160 | |||
161 | adev->clock.default_sclk = | ||
162 | le32_to_cpu(firmware_info->v31.bootup_sclk_in10khz); | ||
163 | adev->clock.default_mclk = | ||
164 | le32_to_cpu(firmware_info->v31.bootup_mclk_in10khz); | ||
165 | |||
166 | adev->pm.current_sclk = adev->clock.default_sclk; | ||
167 | adev->pm.current_mclk = adev->clock.default_mclk; | ||
168 | |||
169 | /* not technically a clock, but... */ | ||
170 | adev->mode_info.firmware_flags = | ||
171 | le32_to_cpu(firmware_info->v31.firmware_capability); | ||
172 | |||
173 | ret = 0; | ||
174 | } | ||
175 | |||
176 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
177 | smu_info); | ||
178 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
179 | &frev, &crev, &data_offset)) { | ||
180 | union smu_info *smu_info = | ||
181 | (union smu_info *)(mode_info->atom_context->bios + | ||
182 | data_offset); | ||
183 | |||
184 | /* system clock */ | ||
185 | spll->reference_freq = le32_to_cpu(smu_info->v31.core_refclk_10khz); | ||
186 | |||
187 | spll->reference_div = 0; | ||
188 | spll->min_post_div = 1; | ||
189 | spll->max_post_div = 1; | ||
190 | spll->min_ref_div = 2; | ||
191 | spll->max_ref_div = 0xff; | ||
192 | spll->min_feedback_div = 4; | ||
193 | spll->max_feedback_div = 0xff; | ||
194 | spll->best_vco = 0; | ||
195 | |||
196 | ret = 0; | ||
197 | } | ||
198 | |||
199 | index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, | ||
200 | umc_info); | ||
201 | if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
202 | &frev, &crev, &data_offset)) { | ||
203 | union umc_info *umc_info = | ||
204 | (union umc_info *)(mode_info->atom_context->bios + | ||
205 | data_offset); | ||
206 | |||
207 | /* memory clock */ | ||
208 | mpll->reference_freq = le32_to_cpu(umc_info->v31.mem_refclk_10khz); | ||
209 | |||
210 | mpll->reference_div = 0; | ||
211 | mpll->min_post_div = 1; | ||
212 | mpll->max_post_div = 1; | ||
213 | mpll->min_ref_div = 2; | ||
214 | mpll->max_ref_div = 0xff; | ||
215 | mpll->min_feedback_div = 4; | ||
216 | mpll->max_feedback_div = 0xff; | ||
217 | mpll->best_vco = 0; | ||
218 | |||
219 | ret = 0; | ||
220 | } | ||
221 | |||
222 | return ret; | ||
223 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h index a2c3ebe22c71..288b97e54347 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | |||
@@ -26,10 +26,8 @@ | |||
26 | 26 | ||
27 | bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device *adev); | 27 | bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device *adev); |
28 | void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev); | 28 | void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev); |
29 | void amdgpu_atomfirmware_scratch_regs_save(struct amdgpu_device *adev); | ||
30 | void amdgpu_atomfirmware_scratch_regs_restore(struct amdgpu_device *adev); | ||
31 | void amdgpu_atomfirmware_scratch_regs_engine_hung(struct amdgpu_device *adev, | ||
32 | bool hung); | ||
33 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev); | 29 | int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev); |
30 | int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev); | ||
31 | int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev); | ||
34 | 32 | ||
35 | #endif | 33 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c index 1beae5b930d0..2fb299afc12b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c | |||
@@ -40,7 +40,7 @@ static int amdgpu_benchmark_do_move(struct amdgpu_device *adev, unsigned size, | |||
40 | for (i = 0; i < n; i++) { | 40 | for (i = 0; i < n; i++) { |
41 | struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; | 41 | struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; |
42 | r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence, | 42 | r = amdgpu_copy_buffer(ring, saddr, daddr, size, NULL, &fence, |
43 | false); | 43 | false, false); |
44 | if (r) | 44 | if (r) |
45 | goto exit_do_move; | 45 | goto exit_do_move; |
46 | r = dma_fence_wait(fence, false); | 46 | r = dma_fence_wait(fence, false); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c index 365e735f6647..c21adf60a7f2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |||
@@ -86,19 +86,6 @@ static bool check_atom_bios(uint8_t *bios, size_t size) | |||
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | 88 | ||
89 | static bool is_atom_fw(uint8_t *bios) | ||
90 | { | ||
91 | uint16_t bios_header_start = bios[0x48] | (bios[0x49] << 8); | ||
92 | uint8_t frev = bios[bios_header_start + 2]; | ||
93 | uint8_t crev = bios[bios_header_start + 3]; | ||
94 | |||
95 | if ((frev < 3) || | ||
96 | ((frev == 3) && (crev < 3))) | ||
97 | return false; | ||
98 | |||
99 | return true; | ||
100 | } | ||
101 | |||
102 | /* If you boot an IGP board with a discrete card as the primary, | 89 | /* If you boot an IGP board with a discrete card as the primary, |
103 | * the IGP rom is not accessible via the rom bar as the IGP rom is | 90 | * the IGP rom is not accessible via the rom bar as the IGP rom is |
104 | * part of the system bios. On boot, the system bios puts a | 91 | * part of the system bios. On boot, the system bios puts a |
@@ -117,7 +104,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) | |||
117 | 104 | ||
118 | adev->bios = NULL; | 105 | adev->bios = NULL; |
119 | vram_base = pci_resource_start(adev->pdev, 0); | 106 | vram_base = pci_resource_start(adev->pdev, 0); |
120 | bios = ioremap(vram_base, size); | 107 | bios = ioremap_wc(vram_base, size); |
121 | if (!bios) { | 108 | if (!bios) { |
122 | return false; | 109 | return false; |
123 | } | 110 | } |
@@ -455,6 +442,6 @@ bool amdgpu_get_bios(struct amdgpu_device *adev) | |||
455 | return false; | 442 | return false; |
456 | 443 | ||
457 | success: | 444 | success: |
458 | adev->is_atom_fw = is_atom_fw(adev->bios); | 445 | adev->is_atom_fw = (adev->asic_type >= CHIP_VEGA10) ? true : false; |
459 | return true; | 446 | return true; |
460 | } | 447 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index f621ee115c98..d324e1c24028 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | |||
@@ -83,7 +83,7 @@ static int amdgpu_bo_list_create(struct amdgpu_device *adev, | |||
83 | r = idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); | 83 | r = idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); |
84 | mutex_unlock(&fpriv->bo_list_lock); | 84 | mutex_unlock(&fpriv->bo_list_lock); |
85 | if (r < 0) { | 85 | if (r < 0) { |
86 | kfree(list); | 86 | amdgpu_bo_list_free(list); |
87 | return r; | 87 | return r; |
88 | } | 88 | } |
89 | *id = r; | 89 | *id = r; |
@@ -198,12 +198,16 @@ amdgpu_bo_list_get(struct amdgpu_fpriv *fpriv, int id) | |||
198 | result = idr_find(&fpriv->bo_list_handles, id); | 198 | result = idr_find(&fpriv->bo_list_handles, id); |
199 | 199 | ||
200 | if (result) { | 200 | if (result) { |
201 | if (kref_get_unless_zero(&result->refcount)) | 201 | if (kref_get_unless_zero(&result->refcount)) { |
202 | rcu_read_unlock(); | ||
202 | mutex_lock(&result->lock); | 203 | mutex_lock(&result->lock); |
203 | else | 204 | } else { |
205 | rcu_read_unlock(); | ||
204 | result = NULL; | 206 | result = NULL; |
207 | } | ||
208 | } else { | ||
209 | rcu_read_unlock(); | ||
205 | } | 210 | } |
206 | rcu_read_unlock(); | ||
207 | 211 | ||
208 | return result; | 212 | return result; |
209 | } | 213 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index c0a806280257..a99e0bca6812 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -240,6 +240,8 @@ static uint32_t amdgpu_cgs_read_ind_register(struct cgs_device *cgs_device, | |||
240 | return RREG32_DIDT(index); | 240 | return RREG32_DIDT(index); |
241 | case CGS_IND_REG_GC_CAC: | 241 | case CGS_IND_REG_GC_CAC: |
242 | return RREG32_GC_CAC(index); | 242 | return RREG32_GC_CAC(index); |
243 | case CGS_IND_REG_SE_CAC: | ||
244 | return RREG32_SE_CAC(index); | ||
243 | case CGS_IND_REG__AUDIO_ENDPT: | 245 | case CGS_IND_REG__AUDIO_ENDPT: |
244 | DRM_ERROR("audio endpt register access not implemented.\n"); | 246 | DRM_ERROR("audio endpt register access not implemented.\n"); |
245 | return 0; | 247 | return 0; |
@@ -266,6 +268,8 @@ static void amdgpu_cgs_write_ind_register(struct cgs_device *cgs_device, | |||
266 | return WREG32_DIDT(index, value); | 268 | return WREG32_DIDT(index, value); |
267 | case CGS_IND_REG_GC_CAC: | 269 | case CGS_IND_REG_GC_CAC: |
268 | return WREG32_GC_CAC(index, value); | 270 | return WREG32_GC_CAC(index, value); |
271 | case CGS_IND_REG_SE_CAC: | ||
272 | return WREG32_SE_CAC(index, value); | ||
269 | case CGS_IND_REG__AUDIO_ENDPT: | 273 | case CGS_IND_REG__AUDIO_ENDPT: |
270 | DRM_ERROR("audio endpt register access not implemented.\n"); | 274 | DRM_ERROR("audio endpt register access not implemented.\n"); |
271 | return; | 275 | return; |
@@ -610,6 +614,17 @@ static int amdgpu_cgs_enter_safe_mode(struct cgs_device *cgs_device, | |||
610 | return 0; | 614 | return 0; |
611 | } | 615 | } |
612 | 616 | ||
617 | static void amdgpu_cgs_lock_grbm_idx(struct cgs_device *cgs_device, | ||
618 | bool lock) | ||
619 | { | ||
620 | CGS_FUNC_ADEV; | ||
621 | |||
622 | if (lock) | ||
623 | mutex_lock(&adev->grbm_idx_mutex); | ||
624 | else | ||
625 | mutex_unlock(&adev->grbm_idx_mutex); | ||
626 | } | ||
627 | |||
613 | static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | 628 | static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, |
614 | enum cgs_ucode_id type, | 629 | enum cgs_ucode_id type, |
615 | struct cgs_firmware_info *info) | 630 | struct cgs_firmware_info *info) |
@@ -719,7 +734,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | |||
719 | strcpy(fw_name, "amdgpu/polaris12_smc.bin"); | 734 | strcpy(fw_name, "amdgpu/polaris12_smc.bin"); |
720 | break; | 735 | break; |
721 | case CHIP_VEGA10: | 736 | case CHIP_VEGA10: |
722 | strcpy(fw_name, "amdgpu/vega10_smc.bin"); | 737 | if ((adev->pdev->device == 0x687f) && |
738 | ((adev->pdev->revision == 0xc0) || | ||
739 | (adev->pdev->revision == 0xc1) || | ||
740 | (adev->pdev->revision == 0xc3))) | ||
741 | strcpy(fw_name, "amdgpu/vega10_acg_smc.bin"); | ||
742 | else | ||
743 | strcpy(fw_name, "amdgpu/vega10_smc.bin"); | ||
723 | break; | 744 | break; |
724 | default: | 745 | default: |
725 | DRM_ERROR("SMC firmware not supported\n"); | 746 | DRM_ERROR("SMC firmware not supported\n"); |
@@ -1117,6 +1138,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { | |||
1117 | .query_system_info = amdgpu_cgs_query_system_info, | 1138 | .query_system_info = amdgpu_cgs_query_system_info, |
1118 | .is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled, | 1139 | .is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled, |
1119 | .enter_safe_mode = amdgpu_cgs_enter_safe_mode, | 1140 | .enter_safe_mode = amdgpu_cgs_enter_safe_mode, |
1141 | .lock_grbm_idx = amdgpu_cgs_lock_grbm_idx, | ||
1120 | }; | 1142 | }; |
1121 | 1143 | ||
1122 | static const struct cgs_os_ops amdgpu_cgs_os_ops = { | 1144 | static const struct cgs_os_ops amdgpu_cgs_os_ops = { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 5599c01b265d..33789510e663 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -223,10 +223,11 @@ static s64 bytes_to_us(struct amdgpu_device *adev, u64 bytes) | |||
223 | * ticks. The accumulated microseconds (us) are converted to bytes and | 223 | * ticks. The accumulated microseconds (us) are converted to bytes and |
224 | * returned. | 224 | * returned. |
225 | */ | 225 | */ |
226 | static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | 226 | static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, |
227 | u64 *max_bytes, | ||
228 | u64 *max_vis_bytes) | ||
227 | { | 229 | { |
228 | s64 time_us, increment_us; | 230 | s64 time_us, increment_us; |
229 | u64 max_bytes; | ||
230 | u64 free_vram, total_vram, used_vram; | 231 | u64 free_vram, total_vram, used_vram; |
231 | 232 | ||
232 | /* Allow a maximum of 200 accumulated ms. This is basically per-IB | 233 | /* Allow a maximum of 200 accumulated ms. This is basically per-IB |
@@ -238,8 +239,11 @@ static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | |||
238 | */ | 239 | */ |
239 | const s64 us_upper_bound = 200000; | 240 | const s64 us_upper_bound = 200000; |
240 | 241 | ||
241 | if (!adev->mm_stats.log2_max_MBps) | 242 | if (!adev->mm_stats.log2_max_MBps) { |
242 | return 0; | 243 | *max_bytes = 0; |
244 | *max_vis_bytes = 0; | ||
245 | return; | ||
246 | } | ||
243 | 247 | ||
244 | total_vram = adev->mc.real_vram_size - adev->vram_pin_size; | 248 | total_vram = adev->mc.real_vram_size - adev->vram_pin_size; |
245 | used_vram = atomic64_read(&adev->vram_usage); | 249 | used_vram = atomic64_read(&adev->vram_usage); |
@@ -280,23 +284,45 @@ static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | |||
280 | adev->mm_stats.accum_us = max(min_us, adev->mm_stats.accum_us); | 284 | adev->mm_stats.accum_us = max(min_us, adev->mm_stats.accum_us); |
281 | } | 285 | } |
282 | 286 | ||
283 | /* This returns 0 if the driver is in debt to disallow (optional) | 287 | /* This is set to 0 if the driver is in debt to disallow (optional) |
284 | * buffer moves. | 288 | * buffer moves. |
285 | */ | 289 | */ |
286 | max_bytes = us_to_bytes(adev, adev->mm_stats.accum_us); | 290 | *max_bytes = us_to_bytes(adev, adev->mm_stats.accum_us); |
291 | |||
292 | /* Do the same for visible VRAM if half of it is free */ | ||
293 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { | ||
294 | u64 total_vis_vram = adev->mc.visible_vram_size; | ||
295 | u64 used_vis_vram = atomic64_read(&adev->vram_vis_usage); | ||
296 | |||
297 | if (used_vis_vram < total_vis_vram) { | ||
298 | u64 free_vis_vram = total_vis_vram - used_vis_vram; | ||
299 | adev->mm_stats.accum_us_vis = min(adev->mm_stats.accum_us_vis + | ||
300 | increment_us, us_upper_bound); | ||
301 | |||
302 | if (free_vis_vram >= total_vis_vram / 2) | ||
303 | adev->mm_stats.accum_us_vis = | ||
304 | max(bytes_to_us(adev, free_vis_vram / 2), | ||
305 | adev->mm_stats.accum_us_vis); | ||
306 | } | ||
307 | |||
308 | *max_vis_bytes = us_to_bytes(adev, adev->mm_stats.accum_us_vis); | ||
309 | } else { | ||
310 | *max_vis_bytes = 0; | ||
311 | } | ||
287 | 312 | ||
288 | spin_unlock(&adev->mm_stats.lock); | 313 | spin_unlock(&adev->mm_stats.lock); |
289 | return max_bytes; | ||
290 | } | 314 | } |
291 | 315 | ||
292 | /* Report how many bytes have really been moved for the last command | 316 | /* Report how many bytes have really been moved for the last command |
293 | * submission. This can result in a debt that can stop buffer migrations | 317 | * submission. This can result in a debt that can stop buffer migrations |
294 | * temporarily. | 318 | * temporarily. |
295 | */ | 319 | */ |
296 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes) | 320 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, |
321 | u64 num_vis_bytes) | ||
297 | { | 322 | { |
298 | spin_lock(&adev->mm_stats.lock); | 323 | spin_lock(&adev->mm_stats.lock); |
299 | adev->mm_stats.accum_us -= bytes_to_us(adev, num_bytes); | 324 | adev->mm_stats.accum_us -= bytes_to_us(adev, num_bytes); |
325 | adev->mm_stats.accum_us_vis -= bytes_to_us(adev, num_vis_bytes); | ||
300 | spin_unlock(&adev->mm_stats.lock); | 326 | spin_unlock(&adev->mm_stats.lock); |
301 | } | 327 | } |
302 | 328 | ||
@@ -304,7 +330,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
304 | struct amdgpu_bo *bo) | 330 | struct amdgpu_bo *bo) |
305 | { | 331 | { |
306 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | 332 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
307 | u64 initial_bytes_moved; | 333 | u64 initial_bytes_moved, bytes_moved; |
308 | uint32_t domain; | 334 | uint32_t domain; |
309 | int r; | 335 | int r; |
310 | 336 | ||
@@ -314,17 +340,35 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
314 | /* Don't move this buffer if we have depleted our allowance | 340 | /* Don't move this buffer if we have depleted our allowance |
315 | * to move it. Don't move anything if the threshold is zero. | 341 | * to move it. Don't move anything if the threshold is zero. |
316 | */ | 342 | */ |
317 | if (p->bytes_moved < p->bytes_moved_threshold) | 343 | if (p->bytes_moved < p->bytes_moved_threshold) { |
318 | domain = bo->prefered_domains; | 344 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && |
319 | else | 345 | (bo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)) { |
346 | /* And don't move a CPU_ACCESS_REQUIRED BO to limited | ||
347 | * visible VRAM if we've depleted our allowance to do | ||
348 | * that. | ||
349 | */ | ||
350 | if (p->bytes_moved_vis < p->bytes_moved_vis_threshold) | ||
351 | domain = bo->prefered_domains; | ||
352 | else | ||
353 | domain = bo->allowed_domains; | ||
354 | } else { | ||
355 | domain = bo->prefered_domains; | ||
356 | } | ||
357 | } else { | ||
320 | domain = bo->allowed_domains; | 358 | domain = bo->allowed_domains; |
359 | } | ||
321 | 360 | ||
322 | retry: | 361 | retry: |
323 | amdgpu_ttm_placement_from_domain(bo, domain); | 362 | amdgpu_ttm_placement_from_domain(bo, domain); |
324 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | 363 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); |
325 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | 364 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); |
326 | p->bytes_moved += atomic64_read(&adev->num_bytes_moved) - | 365 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - |
327 | initial_bytes_moved; | 366 | initial_bytes_moved; |
367 | p->bytes_moved += bytes_moved; | ||
368 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && | ||
369 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | ||
370 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) | ||
371 | p->bytes_moved_vis += bytes_moved; | ||
328 | 372 | ||
329 | if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { | 373 | if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { |
330 | domain = bo->allowed_domains; | 374 | domain = bo->allowed_domains; |
@@ -350,7 +394,8 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, | |||
350 | struct amdgpu_bo_list_entry *candidate = p->evictable; | 394 | struct amdgpu_bo_list_entry *candidate = p->evictable; |
351 | struct amdgpu_bo *bo = candidate->robj; | 395 | struct amdgpu_bo *bo = candidate->robj; |
352 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | 396 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
353 | u64 initial_bytes_moved; | 397 | u64 initial_bytes_moved, bytes_moved; |
398 | bool update_bytes_moved_vis; | ||
354 | uint32_t other; | 399 | uint32_t other; |
355 | 400 | ||
356 | /* If we reached our current BO we can forget it */ | 401 | /* If we reached our current BO we can forget it */ |
@@ -370,10 +415,17 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, | |||
370 | 415 | ||
371 | /* Good we can try to move this BO somewhere else */ | 416 | /* Good we can try to move this BO somewhere else */ |
372 | amdgpu_ttm_placement_from_domain(bo, other); | 417 | amdgpu_ttm_placement_from_domain(bo, other); |
418 | update_bytes_moved_vis = | ||
419 | adev->mc.visible_vram_size < adev->mc.real_vram_size && | ||
420 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | ||
421 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT; | ||
373 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | 422 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); |
374 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | 423 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); |
375 | p->bytes_moved += atomic64_read(&adev->num_bytes_moved) - | 424 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - |
376 | initial_bytes_moved; | 425 | initial_bytes_moved; |
426 | p->bytes_moved += bytes_moved; | ||
427 | if (update_bytes_moved_vis) | ||
428 | p->bytes_moved_vis += bytes_moved; | ||
377 | 429 | ||
378 | if (unlikely(r)) | 430 | if (unlikely(r)) |
379 | break; | 431 | break; |
@@ -554,8 +606,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
554 | list_splice(&need_pages, &p->validated); | 606 | list_splice(&need_pages, &p->validated); |
555 | } | 607 | } |
556 | 608 | ||
557 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); | 609 | amdgpu_cs_get_threshold_for_moves(p->adev, &p->bytes_moved_threshold, |
610 | &p->bytes_moved_vis_threshold); | ||
558 | p->bytes_moved = 0; | 611 | p->bytes_moved = 0; |
612 | p->bytes_moved_vis = 0; | ||
559 | p->evictable = list_last_entry(&p->validated, | 613 | p->evictable = list_last_entry(&p->validated, |
560 | struct amdgpu_bo_list_entry, | 614 | struct amdgpu_bo_list_entry, |
561 | tv.head); | 615 | tv.head); |
@@ -579,8 +633,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
579 | goto error_validate; | 633 | goto error_validate; |
580 | } | 634 | } |
581 | 635 | ||
582 | amdgpu_cs_report_moved_bytes(p->adev, p->bytes_moved); | 636 | amdgpu_cs_report_moved_bytes(p->adev, p->bytes_moved, |
583 | 637 | p->bytes_moved_vis); | |
584 | fpriv->vm.last_eviction_counter = | 638 | fpriv->vm.last_eviction_counter = |
585 | atomic64_read(&p->adev->num_evictions); | 639 | atomic64_read(&p->adev->num_evictions); |
586 | 640 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 4a8fc15467cf..6279956e92a4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -53,6 +53,9 @@ | |||
53 | #include "bif/bif_4_1_d.h" | 53 | #include "bif/bif_4_1_d.h" |
54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
55 | #include <linux/firmware.h> | 55 | #include <linux/firmware.h> |
56 | #include "amdgpu_vf_error.h" | ||
57 | |||
58 | #include "amdgpu_amdkfd.h" | ||
56 | 59 | ||
57 | MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); | 60 | MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); |
58 | MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); | 61 | MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); |
@@ -128,6 +131,10 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, | |||
128 | { | 131 | { |
129 | trace_amdgpu_mm_wreg(adev->pdev->device, reg, v); | 132 | trace_amdgpu_mm_wreg(adev->pdev->device, reg, v); |
130 | 133 | ||
134 | if (adev->asic_type >= CHIP_VEGA10 && reg == 0) { | ||
135 | adev->last_mm_index = v; | ||
136 | } | ||
137 | |||
131 | if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) { | 138 | if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev)) { |
132 | BUG_ON(in_interrupt()); | 139 | BUG_ON(in_interrupt()); |
133 | return amdgpu_virt_kiq_wreg(adev, reg, v); | 140 | return amdgpu_virt_kiq_wreg(adev, reg, v); |
@@ -143,6 +150,10 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, | |||
143 | writel(v, ((void __iomem *)adev->rmmio) + (mmMM_DATA * 4)); | 150 | writel(v, ((void __iomem *)adev->rmmio) + (mmMM_DATA * 4)); |
144 | spin_unlock_irqrestore(&adev->mmio_idx_lock, flags); | 151 | spin_unlock_irqrestore(&adev->mmio_idx_lock, flags); |
145 | } | 152 | } |
153 | |||
154 | if (adev->asic_type >= CHIP_VEGA10 && reg == 1 && adev->last_mm_index == 0x5702C) { | ||
155 | udelay(500); | ||
156 | } | ||
146 | } | 157 | } |
147 | 158 | ||
148 | u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg) | 159 | u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg) |
@@ -157,6 +168,9 @@ u32 amdgpu_io_rreg(struct amdgpu_device *adev, u32 reg) | |||
157 | 168 | ||
158 | void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | 169 | void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
159 | { | 170 | { |
171 | if (adev->asic_type >= CHIP_VEGA10 && reg == 0) { | ||
172 | adev->last_mm_index = v; | ||
173 | } | ||
160 | 174 | ||
161 | if ((reg * 4) < adev->rio_mem_size) | 175 | if ((reg * 4) < adev->rio_mem_size) |
162 | iowrite32(v, adev->rio_mem + (reg * 4)); | 176 | iowrite32(v, adev->rio_mem + (reg * 4)); |
@@ -164,6 +178,10 @@ void amdgpu_io_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | |||
164 | iowrite32((reg * 4), adev->rio_mem + (mmMM_INDEX * 4)); | 178 | iowrite32((reg * 4), adev->rio_mem + (mmMM_INDEX * 4)); |
165 | iowrite32(v, adev->rio_mem + (mmMM_DATA * 4)); | 179 | iowrite32(v, adev->rio_mem + (mmMM_DATA * 4)); |
166 | } | 180 | } |
181 | |||
182 | if (adev->asic_type >= CHIP_VEGA10 && reg == 1 && adev->last_mm_index == 0x5702C) { | ||
183 | udelay(500); | ||
184 | } | ||
167 | } | 185 | } |
168 | 186 | ||
169 | /** | 187 | /** |
@@ -584,6 +602,21 @@ int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb) | |||
584 | } | 602 | } |
585 | } | 603 | } |
586 | 604 | ||
605 | int amdgpu_wb_get_256Bit(struct amdgpu_device *adev, u32 *wb) | ||
606 | { | ||
607 | int i = 0; | ||
608 | unsigned long offset = bitmap_find_next_zero_area_off(adev->wb.used, | ||
609 | adev->wb.num_wb, 0, 8, 63, 0); | ||
610 | if ((offset + 7) < adev->wb.num_wb) { | ||
611 | for (i = 0; i < 8; i++) | ||
612 | __set_bit(offset + i, adev->wb.used); | ||
613 | *wb = offset; | ||
614 | return 0; | ||
615 | } else { | ||
616 | return -EINVAL; | ||
617 | } | ||
618 | } | ||
619 | |||
587 | /** | 620 | /** |
588 | * amdgpu_wb_free - Free a wb entry | 621 | * amdgpu_wb_free - Free a wb entry |
589 | * | 622 | * |
@@ -615,6 +648,23 @@ void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb) | |||
615 | } | 648 | } |
616 | 649 | ||
617 | /** | 650 | /** |
651 | * amdgpu_wb_free_256bit - Free a wb entry | ||
652 | * | ||
653 | * @adev: amdgpu_device pointer | ||
654 | * @wb: wb index | ||
655 | * | ||
656 | * Free a wb slot allocated for use by the driver (all asics) | ||
657 | */ | ||
658 | void amdgpu_wb_free_256bit(struct amdgpu_device *adev, u32 wb) | ||
659 | { | ||
660 | int i = 0; | ||
661 | |||
662 | if ((wb + 7) < adev->wb.num_wb) | ||
663 | for (i = 0; i < 8; i++) | ||
664 | __clear_bit(wb + i, adev->wb.used); | ||
665 | } | ||
666 | |||
667 | /** | ||
618 | * amdgpu_vram_location - try to find VRAM location | 668 | * amdgpu_vram_location - try to find VRAM location |
619 | * @adev: amdgpu device structure holding all necessary informations | 669 | * @adev: amdgpu device structure holding all necessary informations |
620 | * @mc: memory controller structure holding memory informations | 670 | * @mc: memory controller structure holding memory informations |
@@ -665,7 +715,7 @@ void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 | |||
665 | } | 715 | } |
666 | 716 | ||
667 | /** | 717 | /** |
668 | * amdgpu_gtt_location - try to find GTT location | 718 | * amdgpu_gart_location - try to find GTT location |
669 | * @adev: amdgpu device structure holding all necessary informations | 719 | * @adev: amdgpu device structure holding all necessary informations |
670 | * @mc: memory controller structure holding memory informations | 720 | * @mc: memory controller structure holding memory informations |
671 | * | 721 | * |
@@ -676,28 +726,28 @@ void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 | |||
676 | * | 726 | * |
677 | * FIXME: when reducing GTT size align new size on power of 2. | 727 | * FIXME: when reducing GTT size align new size on power of 2. |
678 | */ | 728 | */ |
679 | void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc) | 729 | void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc) |
680 | { | 730 | { |
681 | u64 size_af, size_bf; | 731 | u64 size_af, size_bf; |
682 | 732 | ||
683 | size_af = ((adev->mc.mc_mask - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align; | 733 | size_af = adev->mc.mc_mask - mc->vram_end; |
684 | size_bf = mc->vram_start & ~mc->gtt_base_align; | 734 | size_bf = mc->vram_start; |
685 | if (size_bf > size_af) { | 735 | if (size_bf > size_af) { |
686 | if (mc->gtt_size > size_bf) { | 736 | if (mc->gart_size > size_bf) { |
687 | dev_warn(adev->dev, "limiting GTT\n"); | 737 | dev_warn(adev->dev, "limiting GTT\n"); |
688 | mc->gtt_size = size_bf; | 738 | mc->gart_size = size_bf; |
689 | } | 739 | } |
690 | mc->gtt_start = 0; | 740 | mc->gart_start = 0; |
691 | } else { | 741 | } else { |
692 | if (mc->gtt_size > size_af) { | 742 | if (mc->gart_size > size_af) { |
693 | dev_warn(adev->dev, "limiting GTT\n"); | 743 | dev_warn(adev->dev, "limiting GTT\n"); |
694 | mc->gtt_size = size_af; | 744 | mc->gart_size = size_af; |
695 | } | 745 | } |
696 | mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align; | 746 | mc->gart_start = mc->vram_end + 1; |
697 | } | 747 | } |
698 | mc->gtt_end = mc->gtt_start + mc->gtt_size - 1; | 748 | mc->gart_end = mc->gart_start + mc->gart_size - 1; |
699 | dev_info(adev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n", | 749 | dev_info(adev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n", |
700 | mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end); | 750 | mc->gart_size >> 20, mc->gart_start, mc->gart_end); |
701 | } | 751 | } |
702 | 752 | ||
703 | /* | 753 | /* |
@@ -720,7 +770,12 @@ bool amdgpu_need_post(struct amdgpu_device *adev) | |||
720 | adev->has_hw_reset = false; | 770 | adev->has_hw_reset = false; |
721 | return true; | 771 | return true; |
722 | } | 772 | } |
723 | /* then check MEM_SIZE, in case the crtcs are off */ | 773 | |
774 | /* bios scratch used on CIK+ */ | ||
775 | if (adev->asic_type >= CHIP_BONAIRE) | ||
776 | return amdgpu_atombios_scratch_need_asic_init(adev); | ||
777 | |||
778 | /* check MEM_SIZE for older asics */ | ||
724 | reg = amdgpu_asic_get_config_memsize(adev); | 779 | reg = amdgpu_asic_get_config_memsize(adev); |
725 | 780 | ||
726 | if ((reg != 0) && (reg != 0xffffffff)) | 781 | if ((reg != 0) && (reg != 0xffffffff)) |
@@ -1031,19 +1086,6 @@ static unsigned int amdgpu_vga_set_decode(void *cookie, bool state) | |||
1031 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; | 1086 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
1032 | } | 1087 | } |
1033 | 1088 | ||
1034 | /** | ||
1035 | * amdgpu_check_pot_argument - check that argument is a power of two | ||
1036 | * | ||
1037 | * @arg: value to check | ||
1038 | * | ||
1039 | * Validates that a certain argument is a power of two (all asics). | ||
1040 | * Returns true if argument is valid. | ||
1041 | */ | ||
1042 | static bool amdgpu_check_pot_argument(int arg) | ||
1043 | { | ||
1044 | return (arg & (arg - 1)) == 0; | ||
1045 | } | ||
1046 | |||
1047 | static void amdgpu_check_block_size(struct amdgpu_device *adev) | 1089 | static void amdgpu_check_block_size(struct amdgpu_device *adev) |
1048 | { | 1090 | { |
1049 | /* defines number of bits in page table versus page directory, | 1091 | /* defines number of bits in page table versus page directory, |
@@ -1077,7 +1119,7 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev) | |||
1077 | if (amdgpu_vm_size == -1) | 1119 | if (amdgpu_vm_size == -1) |
1078 | return; | 1120 | return; |
1079 | 1121 | ||
1080 | if (!amdgpu_check_pot_argument(amdgpu_vm_size)) { | 1122 | if (!is_power_of_2(amdgpu_vm_size)) { |
1081 | dev_warn(adev->dev, "VM size (%d) must be a power of 2\n", | 1123 | dev_warn(adev->dev, "VM size (%d) must be a power of 2\n", |
1082 | amdgpu_vm_size); | 1124 | amdgpu_vm_size); |
1083 | goto def_value; | 1125 | goto def_value; |
@@ -1118,19 +1160,24 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev) | |||
1118 | dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", | 1160 | dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", |
1119 | amdgpu_sched_jobs); | 1161 | amdgpu_sched_jobs); |
1120 | amdgpu_sched_jobs = 4; | 1162 | amdgpu_sched_jobs = 4; |
1121 | } else if (!amdgpu_check_pot_argument(amdgpu_sched_jobs)){ | 1163 | } else if (!is_power_of_2(amdgpu_sched_jobs)){ |
1122 | dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n", | 1164 | dev_warn(adev->dev, "sched jobs (%d) must be a power of 2\n", |
1123 | amdgpu_sched_jobs); | 1165 | amdgpu_sched_jobs); |
1124 | amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs); | 1166 | amdgpu_sched_jobs = roundup_pow_of_two(amdgpu_sched_jobs); |
1125 | } | 1167 | } |
1126 | 1168 | ||
1127 | if (amdgpu_gart_size != -1) { | 1169 | if (amdgpu_gart_size < 32) { |
1170 | /* gart size must be greater or equal to 32M */ | ||
1171 | dev_warn(adev->dev, "gart size (%d) too small\n", | ||
1172 | amdgpu_gart_size); | ||
1173 | amdgpu_gart_size = 32; | ||
1174 | } | ||
1175 | |||
1176 | if (amdgpu_gtt_size != -1 && amdgpu_gtt_size < 32) { | ||
1128 | /* gtt size must be greater or equal to 32M */ | 1177 | /* gtt size must be greater or equal to 32M */ |
1129 | if (amdgpu_gart_size < 32) { | 1178 | dev_warn(adev->dev, "gtt size (%d) too small\n", |
1130 | dev_warn(adev->dev, "gart size (%d) too small\n", | 1179 | amdgpu_gtt_size); |
1131 | amdgpu_gart_size); | 1180 | amdgpu_gtt_size = -1; |
1132 | amdgpu_gart_size = -1; | ||
1133 | } | ||
1134 | } | 1181 | } |
1135 | 1182 | ||
1136 | amdgpu_check_vm_size(adev); | 1183 | amdgpu_check_vm_size(adev); |
@@ -1138,7 +1185,7 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev) | |||
1138 | amdgpu_check_block_size(adev); | 1185 | amdgpu_check_block_size(adev); |
1139 | 1186 | ||
1140 | if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 || | 1187 | if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 || |
1141 | !amdgpu_check_pot_argument(amdgpu_vram_page_split))) { | 1188 | !is_power_of_2(amdgpu_vram_page_split))) { |
1142 | dev_warn(adev->dev, "invalid VRAM page split (%d)\n", | 1189 | dev_warn(adev->dev, "invalid VRAM page split (%d)\n", |
1143 | amdgpu_vram_page_split); | 1190 | amdgpu_vram_page_split); |
1144 | amdgpu_vram_page_split = 1024; | 1191 | amdgpu_vram_page_split = 1024; |
@@ -2019,7 +2066,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2019 | adev->flags = flags; | 2066 | adev->flags = flags; |
2020 | adev->asic_type = flags & AMD_ASIC_MASK; | 2067 | adev->asic_type = flags & AMD_ASIC_MASK; |
2021 | adev->usec_timeout = AMDGPU_MAX_USEC_TIMEOUT; | 2068 | adev->usec_timeout = AMDGPU_MAX_USEC_TIMEOUT; |
2022 | adev->mc.gtt_size = 512 * 1024 * 1024; | 2069 | adev->mc.gart_size = 512 * 1024 * 1024; |
2023 | adev->accel_working = false; | 2070 | adev->accel_working = false; |
2024 | adev->num_rings = 0; | 2071 | adev->num_rings = 0; |
2025 | adev->mman.buffer_funcs = NULL; | 2072 | adev->mman.buffer_funcs = NULL; |
@@ -2068,6 +2115,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2068 | spin_lock_init(&adev->uvd_ctx_idx_lock); | 2115 | spin_lock_init(&adev->uvd_ctx_idx_lock); |
2069 | spin_lock_init(&adev->didt_idx_lock); | 2116 | spin_lock_init(&adev->didt_idx_lock); |
2070 | spin_lock_init(&adev->gc_cac_idx_lock); | 2117 | spin_lock_init(&adev->gc_cac_idx_lock); |
2118 | spin_lock_init(&adev->se_cac_idx_lock); | ||
2071 | spin_lock_init(&adev->audio_endpt_idx_lock); | 2119 | spin_lock_init(&adev->audio_endpt_idx_lock); |
2072 | spin_lock_init(&adev->mm_stats.lock); | 2120 | spin_lock_init(&adev->mm_stats.lock); |
2073 | 2121 | ||
@@ -2143,6 +2191,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2143 | r = amdgpu_atombios_init(adev); | 2191 | r = amdgpu_atombios_init(adev); |
2144 | if (r) { | 2192 | if (r) { |
2145 | dev_err(adev->dev, "amdgpu_atombios_init failed\n"); | 2193 | dev_err(adev->dev, "amdgpu_atombios_init failed\n"); |
2194 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL, 0, 0); | ||
2146 | goto failed; | 2195 | goto failed; |
2147 | } | 2196 | } |
2148 | 2197 | ||
@@ -2153,6 +2202,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2153 | if (amdgpu_vpost_needed(adev)) { | 2202 | if (amdgpu_vpost_needed(adev)) { |
2154 | if (!adev->bios) { | 2203 | if (!adev->bios) { |
2155 | dev_err(adev->dev, "no vBIOS found\n"); | 2204 | dev_err(adev->dev, "no vBIOS found\n"); |
2205 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_NO_VBIOS, 0, 0); | ||
2156 | r = -EINVAL; | 2206 | r = -EINVAL; |
2157 | goto failed; | 2207 | goto failed; |
2158 | } | 2208 | } |
@@ -2160,18 +2210,28 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2160 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); | 2210 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
2161 | if (r) { | 2211 | if (r) { |
2162 | dev_err(adev->dev, "gpu post error!\n"); | 2212 | dev_err(adev->dev, "gpu post error!\n"); |
2213 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_GPU_POST_ERROR, 0, 0); | ||
2163 | goto failed; | 2214 | goto failed; |
2164 | } | 2215 | } |
2165 | } else { | 2216 | } else { |
2166 | DRM_INFO("GPU post is not needed\n"); | 2217 | DRM_INFO("GPU post is not needed\n"); |
2167 | } | 2218 | } |
2168 | 2219 | ||
2169 | if (!adev->is_atom_fw) { | 2220 | if (adev->is_atom_fw) { |
2221 | /* Initialize clocks */ | ||
2222 | r = amdgpu_atomfirmware_get_clock_info(adev); | ||
2223 | if (r) { | ||
2224 | dev_err(adev->dev, "amdgpu_atomfirmware_get_clock_info failed\n"); | ||
2225 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0); | ||
2226 | goto failed; | ||
2227 | } | ||
2228 | } else { | ||
2170 | /* Initialize clocks */ | 2229 | /* Initialize clocks */ |
2171 | r = amdgpu_atombios_get_clock_info(adev); | 2230 | r = amdgpu_atombios_get_clock_info(adev); |
2172 | if (r) { | 2231 | if (r) { |
2173 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); | 2232 | dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n"); |
2174 | return r; | 2233 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, 0, 0); |
2234 | goto failed; | ||
2175 | } | 2235 | } |
2176 | /* init i2c buses */ | 2236 | /* init i2c buses */ |
2177 | amdgpu_atombios_i2c_init(adev); | 2237 | amdgpu_atombios_i2c_init(adev); |
@@ -2181,6 +2241,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2181 | r = amdgpu_fence_driver_init(adev); | 2241 | r = amdgpu_fence_driver_init(adev); |
2182 | if (r) { | 2242 | if (r) { |
2183 | dev_err(adev->dev, "amdgpu_fence_driver_init failed\n"); | 2243 | dev_err(adev->dev, "amdgpu_fence_driver_init failed\n"); |
2244 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_FENCE_INIT_FAIL, 0, 0); | ||
2184 | goto failed; | 2245 | goto failed; |
2185 | } | 2246 | } |
2186 | 2247 | ||
@@ -2190,6 +2251,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2190 | r = amdgpu_init(adev); | 2251 | r = amdgpu_init(adev); |
2191 | if (r) { | 2252 | if (r) { |
2192 | dev_err(adev->dev, "amdgpu_init failed\n"); | 2253 | dev_err(adev->dev, "amdgpu_init failed\n"); |
2254 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 0); | ||
2193 | amdgpu_fini(adev); | 2255 | amdgpu_fini(adev); |
2194 | goto failed; | 2256 | goto failed; |
2195 | } | 2257 | } |
@@ -2209,6 +2271,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2209 | r = amdgpu_ib_pool_init(adev); | 2271 | r = amdgpu_ib_pool_init(adev); |
2210 | if (r) { | 2272 | if (r) { |
2211 | dev_err(adev->dev, "IB initialization failed (%d).\n", r); | 2273 | dev_err(adev->dev, "IB initialization failed (%d).\n", r); |
2274 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r); | ||
2212 | goto failed; | 2275 | goto failed; |
2213 | } | 2276 | } |
2214 | 2277 | ||
@@ -2253,12 +2316,14 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2253 | r = amdgpu_late_init(adev); | 2316 | r = amdgpu_late_init(adev); |
2254 | if (r) { | 2317 | if (r) { |
2255 | dev_err(adev->dev, "amdgpu_late_init failed\n"); | 2318 | dev_err(adev->dev, "amdgpu_late_init failed\n"); |
2319 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r); | ||
2256 | goto failed; | 2320 | goto failed; |
2257 | } | 2321 | } |
2258 | 2322 | ||
2259 | return 0; | 2323 | return 0; |
2260 | 2324 | ||
2261 | failed: | 2325 | failed: |
2326 | amdgpu_vf_error_trans_all(adev); | ||
2262 | if (runtime) | 2327 | if (runtime) |
2263 | vga_switcheroo_fini_domain_pm_ops(adev->dev); | 2328 | vga_switcheroo_fini_domain_pm_ops(adev->dev); |
2264 | return r; | 2329 | return r; |
@@ -2351,6 +2416,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) | |||
2351 | } | 2416 | } |
2352 | drm_modeset_unlock_all(dev); | 2417 | drm_modeset_unlock_all(dev); |
2353 | 2418 | ||
2419 | amdgpu_amdkfd_suspend(adev); | ||
2420 | |||
2354 | /* unpin the front buffers and cursors */ | 2421 | /* unpin the front buffers and cursors */ |
2355 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 2422 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
2356 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | 2423 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); |
@@ -2392,10 +2459,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) | |||
2392 | */ | 2459 | */ |
2393 | amdgpu_bo_evict_vram(adev); | 2460 | amdgpu_bo_evict_vram(adev); |
2394 | 2461 | ||
2395 | if (adev->is_atom_fw) | 2462 | amdgpu_atombios_scratch_regs_save(adev); |
2396 | amdgpu_atomfirmware_scratch_regs_save(adev); | ||
2397 | else | ||
2398 | amdgpu_atombios_scratch_regs_save(adev); | ||
2399 | pci_save_state(dev->pdev); | 2463 | pci_save_state(dev->pdev); |
2400 | if (suspend) { | 2464 | if (suspend) { |
2401 | /* Shut down the device */ | 2465 | /* Shut down the device */ |
@@ -2444,10 +2508,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) | |||
2444 | if (r) | 2508 | if (r) |
2445 | goto unlock; | 2509 | goto unlock; |
2446 | } | 2510 | } |
2447 | if (adev->is_atom_fw) | 2511 | amdgpu_atombios_scratch_regs_restore(adev); |
2448 | amdgpu_atomfirmware_scratch_regs_restore(adev); | ||
2449 | else | ||
2450 | amdgpu_atombios_scratch_regs_restore(adev); | ||
2451 | 2512 | ||
2452 | /* post card */ | 2513 | /* post card */ |
2453 | if (amdgpu_need_post(adev)) { | 2514 | if (amdgpu_need_post(adev)) { |
@@ -2490,6 +2551,9 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) | |||
2490 | } | 2551 | } |
2491 | } | 2552 | } |
2492 | } | 2553 | } |
2554 | r = amdgpu_amdkfd_resume(adev); | ||
2555 | if (r) | ||
2556 | return r; | ||
2493 | 2557 | ||
2494 | /* blat the mode back in */ | 2558 | /* blat the mode back in */ |
2495 | if (fbcon) { | 2559 | if (fbcon) { |
@@ -2860,21 +2924,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) | |||
2860 | r = amdgpu_suspend(adev); | 2924 | r = amdgpu_suspend(adev); |
2861 | 2925 | ||
2862 | retry: | 2926 | retry: |
2863 | /* Disable fb access */ | 2927 | amdgpu_atombios_scratch_regs_save(adev); |
2864 | if (adev->mode_info.num_crtc) { | ||
2865 | struct amdgpu_mode_mc_save save; | ||
2866 | amdgpu_display_stop_mc_access(adev, &save); | ||
2867 | amdgpu_wait_for_idle(adev, AMD_IP_BLOCK_TYPE_GMC); | ||
2868 | } | ||
2869 | if (adev->is_atom_fw) | ||
2870 | amdgpu_atomfirmware_scratch_regs_save(adev); | ||
2871 | else | ||
2872 | amdgpu_atombios_scratch_regs_save(adev); | ||
2873 | r = amdgpu_asic_reset(adev); | 2928 | r = amdgpu_asic_reset(adev); |
2874 | if (adev->is_atom_fw) | 2929 | amdgpu_atombios_scratch_regs_restore(adev); |
2875 | amdgpu_atomfirmware_scratch_regs_restore(adev); | ||
2876 | else | ||
2877 | amdgpu_atombios_scratch_regs_restore(adev); | ||
2878 | /* post card */ | 2930 | /* post card */ |
2879 | amdgpu_atom_asic_init(adev->mode_info.atom_context); | 2931 | amdgpu_atom_asic_init(adev->mode_info.atom_context); |
2880 | 2932 | ||
@@ -2952,6 +3004,7 @@ out: | |||
2952 | } | 3004 | } |
2953 | } else { | 3005 | } else { |
2954 | dev_err(adev->dev, "asic resume failed (%d).\n", r); | 3006 | dev_err(adev->dev, "asic resume failed (%d).\n", r); |
3007 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_ASIC_RESUME_FAIL, 0, r); | ||
2955 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 3008 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
2956 | if (adev->rings[i] && adev->rings[i]->sched.thread) { | 3009 | if (adev->rings[i] && adev->rings[i]->sched.thread) { |
2957 | kthread_unpark(adev->rings[i]->sched.thread); | 3010 | kthread_unpark(adev->rings[i]->sched.thread); |
@@ -2962,12 +3015,16 @@ out: | |||
2962 | drm_helper_resume_force_mode(adev->ddev); | 3015 | drm_helper_resume_force_mode(adev->ddev); |
2963 | 3016 | ||
2964 | ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); | 3017 | ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched); |
2965 | if (r) | 3018 | if (r) { |
2966 | /* bad news, how to tell it to userspace ? */ | 3019 | /* bad news, how to tell it to userspace ? */ |
2967 | dev_info(adev->dev, "GPU reset failed\n"); | 3020 | dev_info(adev->dev, "GPU reset failed\n"); |
2968 | else | 3021 | amdgpu_vf_error_put(AMDGIM_ERROR_VF_GPU_RESET_FAIL, 0, r); |
3022 | } | ||
3023 | else { | ||
2969 | dev_info(adev->dev, "GPU reset successed!\n"); | 3024 | dev_info(adev->dev, "GPU reset successed!\n"); |
3025 | } | ||
2970 | 3026 | ||
3027 | amdgpu_vf_error_trans_all(adev); | ||
2971 | return r; | 3028 | return r; |
2972 | } | 3029 | } |
2973 | 3030 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 469992470953..aa53a860c904 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -74,7 +74,9 @@ | |||
74 | #define KMS_DRIVER_PATCHLEVEL 0 | 74 | #define KMS_DRIVER_PATCHLEVEL 0 |
75 | 75 | ||
76 | int amdgpu_vram_limit = 0; | 76 | int amdgpu_vram_limit = 0; |
77 | int amdgpu_gart_size = -1; /* auto */ | 77 | int amdgpu_vis_vram_limit = 0; |
78 | unsigned amdgpu_gart_size = 256; | ||
79 | int amdgpu_gtt_size = -1; /* auto */ | ||
78 | int amdgpu_moverate = -1; /* auto */ | 80 | int amdgpu_moverate = -1; /* auto */ |
79 | int amdgpu_benchmarking = 0; | 81 | int amdgpu_benchmarking = 0; |
80 | int amdgpu_testing = 0; | 82 | int amdgpu_testing = 0; |
@@ -106,6 +108,7 @@ unsigned amdgpu_pcie_gen_cap = 0; | |||
106 | unsigned amdgpu_pcie_lane_cap = 0; | 108 | unsigned amdgpu_pcie_lane_cap = 0; |
107 | unsigned amdgpu_cg_mask = 0xffffffff; | 109 | unsigned amdgpu_cg_mask = 0xffffffff; |
108 | unsigned amdgpu_pg_mask = 0xffffffff; | 110 | unsigned amdgpu_pg_mask = 0xffffffff; |
111 | unsigned amdgpu_sdma_phase_quantum = 32; | ||
109 | char *amdgpu_disable_cu = NULL; | 112 | char *amdgpu_disable_cu = NULL; |
110 | char *amdgpu_virtual_display = NULL; | 113 | char *amdgpu_virtual_display = NULL; |
111 | unsigned amdgpu_pp_feature_mask = 0xffffffff; | 114 | unsigned amdgpu_pp_feature_mask = 0xffffffff; |
@@ -120,8 +123,14 @@ int amdgpu_lbpw = -1; | |||
120 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); | 123 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); |
121 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); | 124 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); |
122 | 125 | ||
123 | MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc., -1 = auto)"); | 126 | MODULE_PARM_DESC(vis_vramlimit, "Restrict visible VRAM for testing, in megabytes"); |
124 | module_param_named(gartsize, amdgpu_gart_size, int, 0600); | 127 | module_param_named(vis_vramlimit, amdgpu_vis_vram_limit, int, 0444); |
128 | |||
129 | MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc.)"); | ||
130 | module_param_named(gartsize, amdgpu_gart_size, uint, 0600); | ||
131 | |||
132 | MODULE_PARM_DESC(gttsize, "Size of the GTT domain in megabytes (-1 = auto)"); | ||
133 | module_param_named(gttsize, amdgpu_gtt_size, int, 0600); | ||
125 | 134 | ||
126 | MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)"); | 135 | MODULE_PARM_DESC(moverate, "Maximum buffer migration rate in MB/s. (32, 64, etc., -1=auto, 0=1=disabled)"); |
127 | module_param_named(moverate, amdgpu_moverate, int, 0600); | 136 | module_param_named(moverate, amdgpu_moverate, int, 0600); |
@@ -186,7 +195,7 @@ module_param_named(vm_debug, amdgpu_vm_debug, int, 0644); | |||
186 | MODULE_PARM_DESC(vm_update_mode, "VM update using CPU (0 = never (default except for large BAR(LB)), 1 = Graphics only, 2 = Compute only (default for LB), 3 = Both"); | 195 | MODULE_PARM_DESC(vm_update_mode, "VM update using CPU (0 = never (default except for large BAR(LB)), 1 = Graphics only, 2 = Compute only (default for LB), 3 = Both"); |
187 | module_param_named(vm_update_mode, amdgpu_vm_update_mode, int, 0444); | 196 | module_param_named(vm_update_mode, amdgpu_vm_update_mode, int, 0444); |
188 | 197 | ||
189 | MODULE_PARM_DESC(vram_page_split, "Number of pages after we split VRAM allocations (default 1024, -1 = disable)"); | 198 | MODULE_PARM_DESC(vram_page_split, "Number of pages after we split VRAM allocations (default 512, -1 = disable)"); |
190 | module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444); | 199 | module_param_named(vram_page_split, amdgpu_vram_page_split, int, 0444); |
191 | 200 | ||
192 | MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))"); | 201 | MODULE_PARM_DESC(exp_hw_support, "experimental hw support (1 = enable, 0 = disable (default))"); |
@@ -199,7 +208,7 @@ MODULE_PARM_DESC(sched_hw_submission, "the max number of HW submissions (default | |||
199 | module_param_named(sched_hw_submission, amdgpu_sched_hw_submission, int, 0444); | 208 | module_param_named(sched_hw_submission, amdgpu_sched_hw_submission, int, 0444); |
200 | 209 | ||
201 | MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))"); | 210 | MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))"); |
202 | module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, int, 0444); | 211 | module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, uint, 0444); |
203 | 212 | ||
204 | MODULE_PARM_DESC(no_evict, "Support pinning request from user space (1 = enable, 0 = disable (default))"); | 213 | MODULE_PARM_DESC(no_evict, "Support pinning request from user space (1 = enable, 0 = disable (default))"); |
205 | module_param_named(no_evict, amdgpu_no_evict, int, 0444); | 214 | module_param_named(no_evict, amdgpu_no_evict, int, 0444); |
@@ -219,6 +228,9 @@ module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444); | |||
219 | MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)"); | 228 | MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)"); |
220 | module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444); | 229 | module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444); |
221 | 230 | ||
231 | MODULE_PARM_DESC(sdma_phase_quantum, "SDMA context switch phase quantum (x 1K GPU clock cycles, 0 = no change (default 32))"); | ||
232 | module_param_named(sdma_phase_quantum, amdgpu_sdma_phase_quantum, uint, 0444); | ||
233 | |||
222 | MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)"); | 234 | MODULE_PARM_DESC(disable_cu, "Disable CUs (se.sh.cu,...)"); |
223 | module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444); | 235 | module_param_named(disable_cu, amdgpu_disable_cu, charp, 0444); |
224 | 236 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c index a57abc1a25fb..5cc4987cd887 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | |||
@@ -55,6 +55,19 @@ | |||
55 | /* | 55 | /* |
56 | * Common GART table functions. | 56 | * Common GART table functions. |
57 | */ | 57 | */ |
58 | |||
59 | /** | ||
60 | * amdgpu_gart_set_defaults - set the default gart_size | ||
61 | * | ||
62 | * @adev: amdgpu_device pointer | ||
63 | * | ||
64 | * Set the default gart_size based on parameters and available VRAM. | ||
65 | */ | ||
66 | void amdgpu_gart_set_defaults(struct amdgpu_device *adev) | ||
67 | { | ||
68 | adev->mc.gart_size = (uint64_t)amdgpu_gart_size << 20; | ||
69 | } | ||
70 | |||
58 | /** | 71 | /** |
59 | * amdgpu_gart_table_ram_alloc - allocate system ram for gart page table | 72 | * amdgpu_gart_table_ram_alloc - allocate system ram for gart page table |
60 | * | 73 | * |
@@ -263,6 +276,41 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, | |||
263 | } | 276 | } |
264 | 277 | ||
265 | /** | 278 | /** |
279 | * amdgpu_gart_map - map dma_addresses into GART entries | ||
280 | * | ||
281 | * @adev: amdgpu_device pointer | ||
282 | * @offset: offset into the GPU's gart aperture | ||
283 | * @pages: number of pages to bind | ||
284 | * @dma_addr: DMA addresses of pages | ||
285 | * | ||
286 | * Map the dma_addresses into GART entries (all asics). | ||
287 | * Returns 0 for success, -EINVAL for failure. | ||
288 | */ | ||
289 | int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, | ||
290 | int pages, dma_addr_t *dma_addr, uint64_t flags, | ||
291 | void *dst) | ||
292 | { | ||
293 | uint64_t page_base; | ||
294 | unsigned i, j, t; | ||
295 | |||
296 | if (!adev->gart.ready) { | ||
297 | WARN(1, "trying to bind memory to uninitialized GART !\n"); | ||
298 | return -EINVAL; | ||
299 | } | ||
300 | |||
301 | t = offset / AMDGPU_GPU_PAGE_SIZE; | ||
302 | |||
303 | for (i = 0; i < pages; i++) { | ||
304 | page_base = dma_addr[i]; | ||
305 | for (j = 0; j < (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); j++, t++) { | ||
306 | amdgpu_gart_set_pte_pde(adev, dst, t, page_base, flags); | ||
307 | page_base += AMDGPU_GPU_PAGE_SIZE; | ||
308 | } | ||
309 | } | ||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | /** | ||
266 | * amdgpu_gart_bind - bind pages into the gart page table | 314 | * amdgpu_gart_bind - bind pages into the gart page table |
267 | * | 315 | * |
268 | * @adev: amdgpu_device pointer | 316 | * @adev: amdgpu_device pointer |
@@ -279,31 +327,30 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, | |||
279 | int pages, struct page **pagelist, dma_addr_t *dma_addr, | 327 | int pages, struct page **pagelist, dma_addr_t *dma_addr, |
280 | uint64_t flags) | 328 | uint64_t flags) |
281 | { | 329 | { |
282 | unsigned t; | 330 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS |
283 | unsigned p; | 331 | unsigned i,t,p; |
284 | uint64_t page_base; | 332 | #endif |
285 | int i, j; | 333 | int r; |
286 | 334 | ||
287 | if (!adev->gart.ready) { | 335 | if (!adev->gart.ready) { |
288 | WARN(1, "trying to bind memory to uninitialized GART !\n"); | 336 | WARN(1, "trying to bind memory to uninitialized GART !\n"); |
289 | return -EINVAL; | 337 | return -EINVAL; |
290 | } | 338 | } |
291 | 339 | ||
340 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | ||
292 | t = offset / AMDGPU_GPU_PAGE_SIZE; | 341 | t = offset / AMDGPU_GPU_PAGE_SIZE; |
293 | p = t / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); | 342 | p = t / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); |
294 | 343 | for (i = 0; i < pages; i++, p++) | |
295 | for (i = 0; i < pages; i++, p++) { | ||
296 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | ||
297 | adev->gart.pages[p] = pagelist[i]; | 344 | adev->gart.pages[p] = pagelist[i]; |
298 | #endif | 345 | #endif |
299 | if (adev->gart.ptr) { | 346 | |
300 | page_base = dma_addr[i]; | 347 | if (adev->gart.ptr) { |
301 | for (j = 0; j < (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); j++, t++) { | 348 | r = amdgpu_gart_map(adev, offset, pages, dma_addr, flags, |
302 | amdgpu_gart_set_pte_pde(adev, adev->gart.ptr, t, page_base, flags); | 349 | adev->gart.ptr); |
303 | page_base += AMDGPU_GPU_PAGE_SIZE; | 350 | if (r) |
304 | } | 351 | return r; |
305 | } | ||
306 | } | 352 | } |
353 | |||
307 | mb(); | 354 | mb(); |
308 | amdgpu_gart_flush_gpu_tlb(adev, 0); | 355 | amdgpu_gart_flush_gpu_tlb(adev, 0); |
309 | return 0; | 356 | return 0; |
@@ -333,8 +380,8 @@ int amdgpu_gart_init(struct amdgpu_device *adev) | |||
333 | if (r) | 380 | if (r) |
334 | return r; | 381 | return r; |
335 | /* Compute table size */ | 382 | /* Compute table size */ |
336 | adev->gart.num_cpu_pages = adev->mc.gtt_size / PAGE_SIZE; | 383 | adev->gart.num_cpu_pages = adev->mc.gart_size / PAGE_SIZE; |
337 | adev->gart.num_gpu_pages = adev->mc.gtt_size / AMDGPU_GPU_PAGE_SIZE; | 384 | adev->gart.num_gpu_pages = adev->mc.gart_size / AMDGPU_GPU_PAGE_SIZE; |
338 | DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", | 385 | DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", |
339 | adev->gart.num_cpu_pages, adev->gart.num_gpu_pages); | 386 | adev->gart.num_cpu_pages, adev->gart.num_gpu_pages); |
340 | 387 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h new file mode 100644 index 000000000000..d4cce6936200 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __AMDGPU_GART_H__ | ||
25 | #define __AMDGPU_GART_H__ | ||
26 | |||
27 | #include <linux/types.h> | ||
28 | |||
29 | /* | ||
30 | * GART structures, functions & helpers | ||
31 | */ | ||
32 | struct amdgpu_device; | ||
33 | struct amdgpu_bo; | ||
34 | struct amdgpu_gart_funcs; | ||
35 | |||
36 | #define AMDGPU_GPU_PAGE_SIZE 4096 | ||
37 | #define AMDGPU_GPU_PAGE_MASK (AMDGPU_GPU_PAGE_SIZE - 1) | ||
38 | #define AMDGPU_GPU_PAGE_SHIFT 12 | ||
39 | #define AMDGPU_GPU_PAGE_ALIGN(a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) | ||
40 | |||
41 | struct amdgpu_gart { | ||
42 | dma_addr_t table_addr; | ||
43 | struct amdgpu_bo *robj; | ||
44 | void *ptr; | ||
45 | unsigned num_gpu_pages; | ||
46 | unsigned num_cpu_pages; | ||
47 | unsigned table_size; | ||
48 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | ||
49 | struct page **pages; | ||
50 | #endif | ||
51 | bool ready; | ||
52 | |||
53 | /* Asic default pte flags */ | ||
54 | uint64_t gart_pte_flags; | ||
55 | |||
56 | const struct amdgpu_gart_funcs *gart_funcs; | ||
57 | }; | ||
58 | |||
59 | void amdgpu_gart_set_defaults(struct amdgpu_device *adev); | ||
60 | int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev); | ||
61 | void amdgpu_gart_table_ram_free(struct amdgpu_device *adev); | ||
62 | int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev); | ||
63 | void amdgpu_gart_table_vram_free(struct amdgpu_device *adev); | ||
64 | int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev); | ||
65 | void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); | ||
66 | int amdgpu_gart_init(struct amdgpu_device *adev); | ||
67 | void amdgpu_gart_fini(struct amdgpu_device *adev); | ||
68 | int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, | ||
69 | int pages); | ||
70 | int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, | ||
71 | int pages, dma_addr_t *dma_addr, uint64_t flags, | ||
72 | void *dst); | ||
73 | int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, | ||
74 | int pages, struct page **pagelist, | ||
75 | dma_addr_t *dma_addr, uint64_t flags); | ||
76 | |||
77 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 621f739103a6..917ac5e074a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -49,7 +49,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, | |||
49 | struct drm_gem_object **obj) | 49 | struct drm_gem_object **obj) |
50 | { | 50 | { |
51 | struct amdgpu_bo *robj; | 51 | struct amdgpu_bo *robj; |
52 | unsigned long max_size; | ||
53 | int r; | 52 | int r; |
54 | 53 | ||
55 | *obj = NULL; | 54 | *obj = NULL; |
@@ -58,17 +57,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, | |||
58 | alignment = PAGE_SIZE; | 57 | alignment = PAGE_SIZE; |
59 | } | 58 | } |
60 | 59 | ||
61 | if (!(initial_domain & (AMDGPU_GEM_DOMAIN_GDS | AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA))) { | ||
62 | /* Maximum bo size is the unpinned gtt size since we use the gtt to | ||
63 | * handle vram to system pool migrations. | ||
64 | */ | ||
65 | max_size = adev->mc.gtt_size - adev->gart_pin_size; | ||
66 | if (size > max_size) { | ||
67 | DRM_DEBUG("Allocation size %ldMb bigger than %ldMb limit\n", | ||
68 | size >> 20, max_size >> 20); | ||
69 | return -ENOMEM; | ||
70 | } | ||
71 | } | ||
72 | retry: | 60 | retry: |
73 | r = amdgpu_bo_create(adev, size, alignment, kernel, initial_domain, | 61 | r = amdgpu_bo_create(adev, size, alignment, kernel, initial_domain, |
74 | flags, NULL, NULL, &robj); | 62 | flags, NULL, NULL, &robj); |
@@ -784,6 +772,7 @@ static int amdgpu_debugfs_gem_bo_info(int id, void *ptr, void *data) | |||
784 | unsigned domain; | 772 | unsigned domain; |
785 | const char *placement; | 773 | const char *placement; |
786 | unsigned pin_count; | 774 | unsigned pin_count; |
775 | uint64_t offset; | ||
787 | 776 | ||
788 | domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); | 777 | domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); |
789 | switch (domain) { | 778 | switch (domain) { |
@@ -798,9 +787,12 @@ static int amdgpu_debugfs_gem_bo_info(int id, void *ptr, void *data) | |||
798 | placement = " CPU"; | 787 | placement = " CPU"; |
799 | break; | 788 | break; |
800 | } | 789 | } |
801 | seq_printf(m, "\t0x%08x: %12ld byte %s @ 0x%010Lx", | 790 | seq_printf(m, "\t0x%08x: %12ld byte %s", |
802 | id, amdgpu_bo_size(bo), placement, | 791 | id, amdgpu_bo_size(bo), placement); |
803 | amdgpu_bo_gpu_offset(bo)); | 792 | |
793 | offset = ACCESS_ONCE(bo->tbo.mem.start); | ||
794 | if (offset != AMDGPU_BO_INVALID_OFFSET) | ||
795 | seq_printf(m, " @ 0x%010Lx", offset); | ||
804 | 796 | ||
805 | pin_count = ACCESS_ONCE(bo->pin_count); | 797 | pin_count = ACCESS_ONCE(bo->pin_count); |
806 | if (pin_count) | 798 | if (pin_count) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index e26108aad3fe..4f6c68fc1dd9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | |||
@@ -125,7 +125,8 @@ void amdgpu_gfx_compute_queue_acquire(struct amdgpu_device *adev) | |||
125 | if (mec >= adev->gfx.mec.num_mec) | 125 | if (mec >= adev->gfx.mec.num_mec) |
126 | break; | 126 | break; |
127 | 127 | ||
128 | if (adev->gfx.mec.num_mec > 1) { | 128 | /* FIXME: spreading the queues across pipes causes perf regressions */ |
129 | if (0) { | ||
129 | /* policy: amdgpu owns the first two queues of the first MEC */ | 130 | /* policy: amdgpu owns the first two queues of the first MEC */ |
130 | if (mec == 0 && queue < 2) | 131 | if (mec == 0 && queue < 2) |
131 | set_bit(i, adev->gfx.mec.queue_bitmap); | 132 | set_bit(i, adev->gfx.mec.queue_bitmap); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index f7d22c44034d..5e6b90c6794f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | |||
@@ -42,13 +42,17 @@ struct amdgpu_gtt_mgr { | |||
42 | static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, | 42 | static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, |
43 | unsigned long p_size) | 43 | unsigned long p_size) |
44 | { | 44 | { |
45 | struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); | ||
45 | struct amdgpu_gtt_mgr *mgr; | 46 | struct amdgpu_gtt_mgr *mgr; |
47 | uint64_t start, size; | ||
46 | 48 | ||
47 | mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); | 49 | mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); |
48 | if (!mgr) | 50 | if (!mgr) |
49 | return -ENOMEM; | 51 | return -ENOMEM; |
50 | 52 | ||
51 | drm_mm_init(&mgr->mm, 0, p_size); | 53 | start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS; |
54 | size = (adev->mc.gart_size >> PAGE_SHIFT) - start; | ||
55 | drm_mm_init(&mgr->mm, start, size); | ||
52 | spin_lock_init(&mgr->lock); | 56 | spin_lock_init(&mgr->lock); |
53 | mgr->available = p_size; | 57 | mgr->available = p_size; |
54 | man->priv = mgr; | 58 | man->priv = mgr; |
@@ -81,6 +85,20 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man) | |||
81 | } | 85 | } |
82 | 86 | ||
83 | /** | 87 | /** |
88 | * amdgpu_gtt_mgr_is_allocated - Check if mem has address space | ||
89 | * | ||
90 | * @mem: the mem object to check | ||
91 | * | ||
92 | * Check if a mem object has already address space allocated. | ||
93 | */ | ||
94 | bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem) | ||
95 | { | ||
96 | struct drm_mm_node *node = mem->mm_node; | ||
97 | |||
98 | return (node->start != AMDGPU_BO_INVALID_OFFSET); | ||
99 | } | ||
100 | |||
101 | /** | ||
84 | * amdgpu_gtt_mgr_alloc - allocate new ranges | 102 | * amdgpu_gtt_mgr_alloc - allocate new ranges |
85 | * | 103 | * |
86 | * @man: TTM memory type manager | 104 | * @man: TTM memory type manager |
@@ -95,13 +113,14 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | |||
95 | const struct ttm_place *place, | 113 | const struct ttm_place *place, |
96 | struct ttm_mem_reg *mem) | 114 | struct ttm_mem_reg *mem) |
97 | { | 115 | { |
116 | struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); | ||
98 | struct amdgpu_gtt_mgr *mgr = man->priv; | 117 | struct amdgpu_gtt_mgr *mgr = man->priv; |
99 | struct drm_mm_node *node = mem->mm_node; | 118 | struct drm_mm_node *node = mem->mm_node; |
100 | enum drm_mm_insert_mode mode; | 119 | enum drm_mm_insert_mode mode; |
101 | unsigned long fpfn, lpfn; | 120 | unsigned long fpfn, lpfn; |
102 | int r; | 121 | int r; |
103 | 122 | ||
104 | if (node->start != AMDGPU_BO_INVALID_OFFSET) | 123 | if (amdgpu_gtt_mgr_is_allocated(mem)) |
105 | return 0; | 124 | return 0; |
106 | 125 | ||
107 | if (place) | 126 | if (place) |
@@ -112,7 +131,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | |||
112 | if (place && place->lpfn) | 131 | if (place && place->lpfn) |
113 | lpfn = place->lpfn; | 132 | lpfn = place->lpfn; |
114 | else | 133 | else |
115 | lpfn = man->size; | 134 | lpfn = adev->gart.num_cpu_pages; |
116 | 135 | ||
117 | mode = DRM_MM_INSERT_BEST; | 136 | mode = DRM_MM_INSERT_BEST; |
118 | if (place && place->flags & TTM_PL_FLAG_TOPDOWN) | 137 | if (place && place->flags & TTM_PL_FLAG_TOPDOWN) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index f774b3f497d2..659997bfff30 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | |||
@@ -130,6 +130,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
130 | 130 | ||
131 | unsigned i; | 131 | unsigned i; |
132 | int r = 0; | 132 | int r = 0; |
133 | bool need_pipe_sync = false; | ||
133 | 134 | ||
134 | if (num_ibs == 0) | 135 | if (num_ibs == 0) |
135 | return -EINVAL; | 136 | return -EINVAL; |
@@ -165,15 +166,15 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, | |||
165 | if (ring->funcs->emit_pipeline_sync && job && | 166 | if (ring->funcs->emit_pipeline_sync && job && |
166 | ((tmp = amdgpu_sync_get_fence(&job->sched_sync)) || | 167 | ((tmp = amdgpu_sync_get_fence(&job->sched_sync)) || |
167 | amdgpu_vm_need_pipeline_sync(ring, job))) { | 168 | amdgpu_vm_need_pipeline_sync(ring, job))) { |
168 | amdgpu_ring_emit_pipeline_sync(ring); | 169 | need_pipe_sync = true; |
169 | dma_fence_put(tmp); | 170 | dma_fence_put(tmp); |
170 | } | 171 | } |
171 | 172 | ||
172 | if (ring->funcs->insert_start) | 173 | if (ring->funcs->insert_start) |
173 | ring->funcs->insert_start(ring); | 174 | ring->funcs->insert_start(ring); |
174 | 175 | ||
175 | if (vm) { | 176 | if (job) { |
176 | r = amdgpu_vm_flush(ring, job); | 177 | r = amdgpu_vm_flush(ring, job, need_pipe_sync); |
177 | if (r) { | 178 | if (r) { |
178 | amdgpu_ring_undo(ring); | 179 | amdgpu_ring_undo(ring); |
179 | return r; | 180 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 2480273c1dca..4bdd851f56d0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | |||
@@ -220,6 +220,10 @@ int amdgpu_irq_init(struct amdgpu_device *adev) | |||
220 | int r = 0; | 220 | int r = 0; |
221 | 221 | ||
222 | spin_lock_init(&adev->irq.lock); | 222 | spin_lock_init(&adev->irq.lock); |
223 | |||
224 | /* Disable vblank irqs aggressively for power-saving */ | ||
225 | adev->ddev->vblank_disable_immediate = true; | ||
226 | |||
223 | r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc); | 227 | r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc); |
224 | if (r) { | 228 | if (r) { |
225 | return r; | 229 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 3d641e10e6b6..4510627ae83e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | |||
@@ -81,6 +81,8 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size, | |||
81 | r = amdgpu_ib_get(adev, NULL, size, &(*job)->ibs[0]); | 81 | r = amdgpu_ib_get(adev, NULL, size, &(*job)->ibs[0]); |
82 | if (r) | 82 | if (r) |
83 | kfree(*job); | 83 | kfree(*job); |
84 | else | ||
85 | (*job)->vm_pd_addr = adev->gart.table_addr; | ||
84 | 86 | ||
85 | return r; | 87 | return r; |
86 | } | 88 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index b0b23101d1c8..09f833255ba1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -485,7 +485,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
485 | vram_gtt.vram_size -= adev->vram_pin_size; | 485 | vram_gtt.vram_size -= adev->vram_pin_size; |
486 | vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; | 486 | vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; |
487 | vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size); | 487 | vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size); |
488 | vram_gtt.gtt_size = adev->mc.gtt_size; | 488 | vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT].size; |
489 | vram_gtt.gtt_size *= PAGE_SIZE; | ||
489 | vram_gtt.gtt_size -= adev->gart_pin_size; | 490 | vram_gtt.gtt_size -= adev->gart_pin_size; |
490 | return copy_to_user(out, &vram_gtt, | 491 | return copy_to_user(out, &vram_gtt, |
491 | min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0; | 492 | min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0; |
@@ -510,9 +511,10 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
510 | mem.cpu_accessible_vram.max_allocation = | 511 | mem.cpu_accessible_vram.max_allocation = |
511 | mem.cpu_accessible_vram.usable_heap_size * 3 / 4; | 512 | mem.cpu_accessible_vram.usable_heap_size * 3 / 4; |
512 | 513 | ||
513 | mem.gtt.total_heap_size = adev->mc.gtt_size; | 514 | mem.gtt.total_heap_size = adev->mman.bdev.man[TTM_PL_TT].size; |
514 | mem.gtt.usable_heap_size = | 515 | mem.gtt.total_heap_size *= PAGE_SIZE; |
515 | adev->mc.gtt_size - adev->gart_pin_size; | 516 | mem.gtt.usable_heap_size = mem.gtt.total_heap_size |
517 | - adev->gart_pin_size; | ||
516 | mem.gtt.heap_usage = atomic64_read(&adev->gtt_usage); | 518 | mem.gtt.heap_usage = atomic64_read(&adev->gtt_usage); |
517 | mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4; | 519 | mem.gtt.max_allocation = mem.gtt.usable_heap_size * 3 / 4; |
518 | 520 | ||
@@ -571,8 +573,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
571 | dev_info.max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 10; | 573 | dev_info.max_engine_clock = amdgpu_dpm_get_sclk(adev, false) * 10; |
572 | dev_info.max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 10; | 574 | dev_info.max_memory_clock = amdgpu_dpm_get_mclk(adev, false) * 10; |
573 | } else { | 575 | } else { |
574 | dev_info.max_engine_clock = adev->pm.default_sclk * 10; | 576 | dev_info.max_engine_clock = adev->clock.default_sclk * 10; |
575 | dev_info.max_memory_clock = adev->pm.default_mclk * 10; | 577 | dev_info.max_memory_clock = adev->clock.default_mclk * 10; |
576 | } | 578 | } |
577 | dev_info.enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask; | 579 | dev_info.enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask; |
578 | dev_info.num_rb_pipes = adev->gfx.config.max_backends_per_se * | 580 | dev_info.num_rb_pipes = adev->gfx.config.max_backends_per_se * |
@@ -587,8 +589,9 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
587 | dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; | 589 | dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; |
588 | dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; | 590 | dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; |
589 | dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE); | 591 | dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE); |
590 | dev_info.pte_fragment_size = (1 << AMDGPU_LOG2_PAGES_PER_FRAG) * | 592 | dev_info.pte_fragment_size = |
591 | AMDGPU_GPU_PAGE_SIZE; | 593 | (1 << AMDGPU_LOG2_PAGES_PER_FRAG(adev)) * |
594 | AMDGPU_GPU_PAGE_SIZE; | ||
592 | dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE; | 595 | dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE; |
593 | 596 | ||
594 | dev_info.cu_active_number = adev->gfx.cu_info.number; | 597 | dev_info.cu_active_number = adev->gfx.cu_info.number; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h index 43a9d3aec6c4..b8abd4e18d51 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | |||
@@ -257,15 +257,7 @@ struct amdgpu_audio { | |||
257 | int num_pins; | 257 | int num_pins; |
258 | }; | 258 | }; |
259 | 259 | ||
260 | struct amdgpu_mode_mc_save { | ||
261 | u32 vga_render_control; | ||
262 | u32 vga_hdp_control; | ||
263 | bool crtc_enabled[AMDGPU_MAX_CRTCS]; | ||
264 | }; | ||
265 | |||
266 | struct amdgpu_display_funcs { | 260 | struct amdgpu_display_funcs { |
267 | /* vga render */ | ||
268 | void (*set_vga_render_state)(struct amdgpu_device *adev, bool render); | ||
269 | /* display watermarks */ | 261 | /* display watermarks */ |
270 | void (*bandwidth_update)(struct amdgpu_device *adev); | 262 | void (*bandwidth_update)(struct amdgpu_device *adev); |
271 | /* get frame count */ | 263 | /* get frame count */ |
@@ -300,10 +292,6 @@ struct amdgpu_display_funcs { | |||
300 | uint16_t connector_object_id, | 292 | uint16_t connector_object_id, |
301 | struct amdgpu_hpd *hpd, | 293 | struct amdgpu_hpd *hpd, |
302 | struct amdgpu_router *router); | 294 | struct amdgpu_router *router); |
303 | void (*stop_mc_access)(struct amdgpu_device *adev, | ||
304 | struct amdgpu_mode_mc_save *save); | ||
305 | void (*resume_mc_access)(struct amdgpu_device *adev, | ||
306 | struct amdgpu_mode_mc_save *save); | ||
307 | }; | 295 | }; |
308 | 296 | ||
309 | struct amdgpu_mode_info { | 297 | struct amdgpu_mode_info { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 8ee69652be8c..3ec43cf9ad78 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -93,6 +93,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) | |||
93 | 93 | ||
94 | bo = container_of(tbo, struct amdgpu_bo, tbo); | 94 | bo = container_of(tbo, struct amdgpu_bo, tbo); |
95 | 95 | ||
96 | amdgpu_bo_kunmap(bo); | ||
96 | amdgpu_update_memory_usage(adev, &bo->tbo.mem, NULL); | 97 | amdgpu_update_memory_usage(adev, &bo->tbo.mem, NULL); |
97 | 98 | ||
98 | drm_gem_object_release(&bo->gem_base); | 99 | drm_gem_object_release(&bo->gem_base); |
@@ -322,7 +323,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
322 | struct amdgpu_bo *bo; | 323 | struct amdgpu_bo *bo; |
323 | enum ttm_bo_type type; | 324 | enum ttm_bo_type type; |
324 | unsigned long page_align; | 325 | unsigned long page_align; |
325 | u64 initial_bytes_moved; | 326 | u64 initial_bytes_moved, bytes_moved; |
326 | size_t acc_size; | 327 | size_t acc_size; |
327 | int r; | 328 | int r; |
328 | 329 | ||
@@ -398,8 +399,14 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
398 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, | 399 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, |
399 | &bo->placement, page_align, !kernel, NULL, | 400 | &bo->placement, page_align, !kernel, NULL, |
400 | acc_size, sg, resv, &amdgpu_ttm_bo_destroy); | 401 | acc_size, sg, resv, &amdgpu_ttm_bo_destroy); |
401 | amdgpu_cs_report_moved_bytes(adev, | 402 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - |
402 | atomic64_read(&adev->num_bytes_moved) - initial_bytes_moved); | 403 | initial_bytes_moved; |
404 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && | ||
405 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | ||
406 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) | ||
407 | amdgpu_cs_report_moved_bytes(adev, bytes_moved, bytes_moved); | ||
408 | else | ||
409 | amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0); | ||
403 | 410 | ||
404 | if (unlikely(r != 0)) | 411 | if (unlikely(r != 0)) |
405 | return r; | 412 | return r; |
@@ -426,6 +433,10 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
426 | 433 | ||
427 | trace_amdgpu_bo_create(bo); | 434 | trace_amdgpu_bo_create(bo); |
428 | 435 | ||
436 | /* Treat CPU_ACCESS_REQUIRED only as a hint if given by UMD */ | ||
437 | if (type == ttm_bo_type_device) | ||
438 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | ||
439 | |||
429 | return 0; | 440 | return 0; |
430 | 441 | ||
431 | fail_unreserve: | 442 | fail_unreserve: |
@@ -535,7 +546,7 @@ int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev, | |||
535 | 546 | ||
536 | r = amdgpu_copy_buffer(ring, bo_addr, shadow_addr, | 547 | r = amdgpu_copy_buffer(ring, bo_addr, shadow_addr, |
537 | amdgpu_bo_size(bo), resv, fence, | 548 | amdgpu_bo_size(bo), resv, fence, |
538 | direct); | 549 | direct, false); |
539 | if (!r) | 550 | if (!r) |
540 | amdgpu_bo_fence(bo, *fence, true); | 551 | amdgpu_bo_fence(bo, *fence, true); |
541 | 552 | ||
@@ -588,7 +599,7 @@ int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev, | |||
588 | 599 | ||
589 | r = amdgpu_copy_buffer(ring, shadow_addr, bo_addr, | 600 | r = amdgpu_copy_buffer(ring, shadow_addr, bo_addr, |
590 | amdgpu_bo_size(bo), resv, fence, | 601 | amdgpu_bo_size(bo), resv, fence, |
591 | direct); | 602 | direct, false); |
592 | if (!r) | 603 | if (!r) |
593 | amdgpu_bo_fence(bo, *fence, true); | 604 | amdgpu_bo_fence(bo, *fence, true); |
594 | 605 | ||
@@ -724,15 +735,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, | |||
724 | dev_err(adev->dev, "%p pin failed\n", bo); | 735 | dev_err(adev->dev, "%p pin failed\n", bo); |
725 | goto error; | 736 | goto error; |
726 | } | 737 | } |
727 | r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem); | ||
728 | if (unlikely(r)) { | ||
729 | dev_err(adev->dev, "%p bind failed\n", bo); | ||
730 | goto error; | ||
731 | } | ||
732 | 738 | ||
733 | bo->pin_count = 1; | 739 | bo->pin_count = 1; |
734 | if (gpu_addr != NULL) | 740 | if (gpu_addr != NULL) { |
741 | r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem); | ||
742 | if (unlikely(r)) { | ||
743 | dev_err(adev->dev, "%p bind failed\n", bo); | ||
744 | goto error; | ||
745 | } | ||
735 | *gpu_addr = amdgpu_bo_gpu_offset(bo); | 746 | *gpu_addr = amdgpu_bo_gpu_offset(bo); |
747 | } | ||
736 | if (domain == AMDGPU_GEM_DOMAIN_VRAM) { | 748 | if (domain == AMDGPU_GEM_DOMAIN_VRAM) { |
737 | adev->vram_pin_size += amdgpu_bo_size(bo); | 749 | adev->vram_pin_size += amdgpu_bo_size(bo); |
738 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) | 750 | if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) |
@@ -921,6 +933,8 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, | |||
921 | abo = container_of(bo, struct amdgpu_bo, tbo); | 933 | abo = container_of(bo, struct amdgpu_bo, tbo); |
922 | amdgpu_vm_bo_invalidate(adev, abo); | 934 | amdgpu_vm_bo_invalidate(adev, abo); |
923 | 935 | ||
936 | amdgpu_bo_kunmap(abo); | ||
937 | |||
924 | /* remember the eviction */ | 938 | /* remember the eviction */ |
925 | if (evict) | 939 | if (evict) |
926 | atomic64_inc(&adev->num_evictions); | 940 | atomic64_inc(&adev->num_evictions); |
@@ -939,19 +953,22 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) | |||
939 | { | 953 | { |
940 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | 954 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); |
941 | struct amdgpu_bo *abo; | 955 | struct amdgpu_bo *abo; |
942 | unsigned long offset, size, lpfn; | 956 | unsigned long offset, size; |
943 | int i, r; | 957 | int r; |
944 | 958 | ||
945 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) | 959 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) |
946 | return 0; | 960 | return 0; |
947 | 961 | ||
948 | abo = container_of(bo, struct amdgpu_bo, tbo); | 962 | abo = container_of(bo, struct amdgpu_bo, tbo); |
963 | |||
964 | /* Remember that this BO was accessed by the CPU */ | ||
965 | abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | ||
966 | |||
949 | if (bo->mem.mem_type != TTM_PL_VRAM) | 967 | if (bo->mem.mem_type != TTM_PL_VRAM) |
950 | return 0; | 968 | return 0; |
951 | 969 | ||
952 | size = bo->mem.num_pages << PAGE_SHIFT; | 970 | size = bo->mem.num_pages << PAGE_SHIFT; |
953 | offset = bo->mem.start << PAGE_SHIFT; | 971 | offset = bo->mem.start << PAGE_SHIFT; |
954 | /* TODO: figure out how to map scattered VRAM to the CPU */ | ||
955 | if ((offset + size) <= adev->mc.visible_vram_size) | 972 | if ((offset + size) <= adev->mc.visible_vram_size) |
956 | return 0; | 973 | return 0; |
957 | 974 | ||
@@ -961,26 +978,21 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) | |||
961 | 978 | ||
962 | /* hurrah the memory is not visible ! */ | 979 | /* hurrah the memory is not visible ! */ |
963 | atomic64_inc(&adev->num_vram_cpu_page_faults); | 980 | atomic64_inc(&adev->num_vram_cpu_page_faults); |
964 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM); | 981 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM | |
965 | lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT; | 982 | AMDGPU_GEM_DOMAIN_GTT); |
966 | for (i = 0; i < abo->placement.num_placement; i++) { | 983 | |
967 | /* Force into visible VRAM */ | 984 | /* Avoid costly evictions; only set GTT as a busy placement */ |
968 | if ((abo->placements[i].flags & TTM_PL_FLAG_VRAM) && | 985 | abo->placement.num_busy_placement = 1; |
969 | (!abo->placements[i].lpfn || | 986 | abo->placement.busy_placement = &abo->placements[1]; |
970 | abo->placements[i].lpfn > lpfn)) | 987 | |
971 | abo->placements[i].lpfn = lpfn; | ||
972 | } | ||
973 | r = ttm_bo_validate(bo, &abo->placement, false, false); | 988 | r = ttm_bo_validate(bo, &abo->placement, false, false); |
974 | if (unlikely(r == -ENOMEM)) { | 989 | if (unlikely(r != 0)) |
975 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); | ||
976 | return ttm_bo_validate(bo, &abo->placement, false, false); | ||
977 | } else if (unlikely(r != 0)) { | ||
978 | return r; | 990 | return r; |
979 | } | ||
980 | 991 | ||
981 | offset = bo->mem.start << PAGE_SHIFT; | 992 | offset = bo->mem.start << PAGE_SHIFT; |
982 | /* this should never happen */ | 993 | /* this should never happen */ |
983 | if ((offset + size) > adev->mc.visible_vram_size) | 994 | if (bo->mem.mem_type == TTM_PL_VRAM && |
995 | (offset + size) > adev->mc.visible_vram_size) | ||
984 | return -EINVAL; | 996 | return -EINVAL; |
985 | 997 | ||
986 | return 0; | 998 | return 0; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 382485115b06..833b172a2c2a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | |||
@@ -120,7 +120,11 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo) | |||
120 | */ | 120 | */ |
121 | static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) | 121 | static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) |
122 | { | 122 | { |
123 | return bo->tbo.mem.mem_type != TTM_PL_SYSTEM; | 123 | switch (bo->tbo.mem.mem_type) { |
124 | case TTM_PL_TT: return amdgpu_ttm_is_bound(bo->tbo.ttm); | ||
125 | case TTM_PL_VRAM: return true; | ||
126 | default: return false; | ||
127 | } | ||
124 | } | 128 | } |
125 | 129 | ||
126 | int amdgpu_bo_create(struct amdgpu_device *adev, | 130 | int amdgpu_bo_create(struct amdgpu_device *adev, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index 4083be61b328..8c2204c7b384 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |||
@@ -63,8 +63,13 @@ static int psp_sw_init(void *handle) | |||
63 | psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk; | 63 | psp->smu_reload_quirk = psp_v3_1_smu_reload_quirk; |
64 | break; | 64 | break; |
65 | case CHIP_RAVEN: | 65 | case CHIP_RAVEN: |
66 | #if 0 | ||
67 | psp->init_microcode = psp_v10_0_init_microcode; | ||
68 | #endif | ||
66 | psp->prep_cmd_buf = psp_v10_0_prep_cmd_buf; | 69 | psp->prep_cmd_buf = psp_v10_0_prep_cmd_buf; |
67 | psp->ring_init = psp_v10_0_ring_init; | 70 | psp->ring_init = psp_v10_0_ring_init; |
71 | psp->ring_create = psp_v10_0_ring_create; | ||
72 | psp->ring_destroy = psp_v10_0_ring_destroy; | ||
68 | psp->cmd_submit = psp_v10_0_cmd_submit; | 73 | psp->cmd_submit = psp_v10_0_cmd_submit; |
69 | psp->compare_sram_data = psp_v10_0_compare_sram_data; | 74 | psp->compare_sram_data = psp_v10_0_compare_sram_data; |
70 | break; | 75 | break; |
@@ -95,9 +100,8 @@ int psp_wait_for(struct psp_context *psp, uint32_t reg_index, | |||
95 | int i; | 100 | int i; |
96 | struct amdgpu_device *adev = psp->adev; | 101 | struct amdgpu_device *adev = psp->adev; |
97 | 102 | ||
98 | val = RREG32(reg_index); | ||
99 | |||
100 | for (i = 0; i < adev->usec_timeout; i++) { | 103 | for (i = 0; i < adev->usec_timeout; i++) { |
104 | val = RREG32(reg_index); | ||
101 | if (check_changed) { | 105 | if (check_changed) { |
102 | if (val != reg_val) | 106 | if (val != reg_val) |
103 | return 0; | 107 | return 0; |
@@ -118,33 +122,18 @@ psp_cmd_submit_buf(struct psp_context *psp, | |||
118 | int index) | 122 | int index) |
119 | { | 123 | { |
120 | int ret; | 124 | int ret; |
121 | struct amdgpu_bo *cmd_buf_bo; | ||
122 | uint64_t cmd_buf_mc_addr; | ||
123 | struct psp_gfx_cmd_resp *cmd_buf_mem; | ||
124 | struct amdgpu_device *adev = psp->adev; | ||
125 | |||
126 | ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE, | ||
127 | AMDGPU_GEM_DOMAIN_VRAM, | ||
128 | &cmd_buf_bo, &cmd_buf_mc_addr, | ||
129 | (void **)&cmd_buf_mem); | ||
130 | if (ret) | ||
131 | return ret; | ||
132 | 125 | ||
133 | memset(cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE); | 126 | memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE); |
134 | 127 | ||
135 | memcpy(cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp)); | 128 | memcpy(psp->cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp)); |
136 | 129 | ||
137 | ret = psp_cmd_submit(psp, ucode, cmd_buf_mc_addr, | 130 | ret = psp_cmd_submit(psp, ucode, psp->cmd_buf_mc_addr, |
138 | fence_mc_addr, index); | 131 | fence_mc_addr, index); |
139 | 132 | ||
140 | while (*((unsigned int *)psp->fence_buf) != index) { | 133 | while (*((unsigned int *)psp->fence_buf) != index) { |
141 | msleep(1); | 134 | msleep(1); |
142 | } | 135 | } |
143 | 136 | ||
144 | amdgpu_bo_free_kernel(&cmd_buf_bo, | ||
145 | &cmd_buf_mc_addr, | ||
146 | (void **)&cmd_buf_mem); | ||
147 | |||
148 | return ret; | 137 | return ret; |
149 | } | 138 | } |
150 | 139 | ||
@@ -352,13 +341,20 @@ static int psp_load_fw(struct amdgpu_device *adev) | |||
352 | &psp->fence_buf_mc_addr, | 341 | &psp->fence_buf_mc_addr, |
353 | &psp->fence_buf); | 342 | &psp->fence_buf); |
354 | if (ret) | 343 | if (ret) |
344 | goto failed_mem2; | ||
345 | |||
346 | ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE, | ||
347 | AMDGPU_GEM_DOMAIN_VRAM, | ||
348 | &psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, | ||
349 | (void **)&psp->cmd_buf_mem); | ||
350 | if (ret) | ||
355 | goto failed_mem1; | 351 | goto failed_mem1; |
356 | 352 | ||
357 | memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE); | 353 | memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE); |
358 | 354 | ||
359 | ret = psp_ring_init(psp, PSP_RING_TYPE__KM); | 355 | ret = psp_ring_init(psp, PSP_RING_TYPE__KM); |
360 | if (ret) | 356 | if (ret) |
361 | goto failed_mem1; | 357 | goto failed_mem; |
362 | 358 | ||
363 | ret = psp_tmr_init(psp); | 359 | ret = psp_tmr_init(psp); |
364 | if (ret) | 360 | if (ret) |
@@ -379,9 +375,13 @@ static int psp_load_fw(struct amdgpu_device *adev) | |||
379 | return 0; | 375 | return 0; |
380 | 376 | ||
381 | failed_mem: | 377 | failed_mem: |
378 | amdgpu_bo_free_kernel(&psp->cmd_buf_bo, | ||
379 | &psp->cmd_buf_mc_addr, | ||
380 | (void **)&psp->cmd_buf_mem); | ||
381 | failed_mem1: | ||
382 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, | 382 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, |
383 | &psp->fence_buf_mc_addr, &psp->fence_buf); | 383 | &psp->fence_buf_mc_addr, &psp->fence_buf); |
384 | failed_mem1: | 384 | failed_mem2: |
385 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, | 385 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, |
386 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); | 386 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); |
387 | failed: | 387 | failed: |
@@ -435,16 +435,15 @@ static int psp_hw_fini(void *handle) | |||
435 | 435 | ||
436 | psp_ring_destroy(psp, PSP_RING_TYPE__KM); | 436 | psp_ring_destroy(psp, PSP_RING_TYPE__KM); |
437 | 437 | ||
438 | if (psp->tmr_buf) | 438 | amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf); |
439 | amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf); | 439 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, |
440 | 440 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); | |
441 | if (psp->fw_pri_buf) | 441 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, |
442 | amdgpu_bo_free_kernel(&psp->fw_pri_bo, | 442 | &psp->fence_buf_mc_addr, &psp->fence_buf); |
443 | &psp->fw_pri_mc_addr, &psp->fw_pri_buf); | 443 | amdgpu_bo_free_kernel(&psp->asd_shared_bo, &psp->asd_shared_mc_addr, |
444 | 444 | &psp->asd_shared_buf); | |
445 | if (psp->fence_buf_bo) | 445 | amdgpu_bo_free_kernel(&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, |
446 | amdgpu_bo_free_kernel(&psp->fence_buf_bo, | 446 | (void **)&psp->cmd_buf_mem); |
447 | &psp->fence_buf_mc_addr, &psp->fence_buf); | ||
448 | 447 | ||
449 | kfree(psp->cmd); | 448 | kfree(psp->cmd); |
450 | psp->cmd = NULL; | 449 | psp->cmd = NULL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h index 1a1c8b469f93..538fa9dbfb21 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | |||
@@ -108,6 +108,11 @@ struct psp_context | |||
108 | struct amdgpu_bo *fence_buf_bo; | 108 | struct amdgpu_bo *fence_buf_bo; |
109 | uint64_t fence_buf_mc_addr; | 109 | uint64_t fence_buf_mc_addr; |
110 | void *fence_buf; | 110 | void *fence_buf; |
111 | |||
112 | /* cmd buffer */ | ||
113 | struct amdgpu_bo *cmd_buf_bo; | ||
114 | uint64_t cmd_buf_mc_addr; | ||
115 | struct psp_gfx_cmd_resp *cmd_buf_mem; | ||
111 | }; | 116 | }; |
112 | 117 | ||
113 | struct amdgpu_psp_funcs { | 118 | struct amdgpu_psp_funcs { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 75165e07b1cd..15b7149d1204 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -212,10 +212,19 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | r = amdgpu_wb_get(adev, &ring->fence_offs); | 215 | if (amdgpu_sriov_vf(adev) && ring->funcs->type == AMDGPU_RING_TYPE_GFX) { |
216 | if (r) { | 216 | r = amdgpu_wb_get_256Bit(adev, &ring->fence_offs); |
217 | dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); | 217 | if (r) { |
218 | return r; | 218 | dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); |
219 | return r; | ||
220 | } | ||
221 | |||
222 | } else { | ||
223 | r = amdgpu_wb_get(adev, &ring->fence_offs); | ||
224 | if (r) { | ||
225 | dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); | ||
226 | return r; | ||
227 | } | ||
219 | } | 228 | } |
220 | 229 | ||
221 | r = amdgpu_wb_get(adev, &ring->cond_exe_offs); | 230 | r = amdgpu_wb_get(adev, &ring->cond_exe_offs); |
@@ -278,17 +287,18 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) | |||
278 | ring->ready = false; | 287 | ring->ready = false; |
279 | 288 | ||
280 | if (ring->funcs->support_64bit_ptrs) { | 289 | if (ring->funcs->support_64bit_ptrs) { |
281 | amdgpu_wb_free_64bit(ring->adev, ring->cond_exe_offs); | ||
282 | amdgpu_wb_free_64bit(ring->adev, ring->fence_offs); | ||
283 | amdgpu_wb_free_64bit(ring->adev, ring->rptr_offs); | 290 | amdgpu_wb_free_64bit(ring->adev, ring->rptr_offs); |
284 | amdgpu_wb_free_64bit(ring->adev, ring->wptr_offs); | 291 | amdgpu_wb_free_64bit(ring->adev, ring->wptr_offs); |
285 | } else { | 292 | } else { |
286 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | ||
287 | amdgpu_wb_free(ring->adev, ring->fence_offs); | ||
288 | amdgpu_wb_free(ring->adev, ring->rptr_offs); | 293 | amdgpu_wb_free(ring->adev, ring->rptr_offs); |
289 | amdgpu_wb_free(ring->adev, ring->wptr_offs); | 294 | amdgpu_wb_free(ring->adev, ring->wptr_offs); |
290 | } | 295 | } |
291 | 296 | ||
297 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | ||
298 | if (amdgpu_sriov_vf(ring->adev) && ring->funcs->type == AMDGPU_RING_TYPE_GFX) | ||
299 | amdgpu_wb_free_256bit(ring->adev, ring->fence_offs); | ||
300 | else | ||
301 | amdgpu_wb_free(ring->adev, ring->fence_offs); | ||
292 | 302 | ||
293 | amdgpu_bo_free_kernel(&ring->ring_obj, | 303 | amdgpu_bo_free_kernel(&ring->ring_obj, |
294 | &ring->gpu_addr, | 304 | &ring->gpu_addr, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index bc8dec992f73..322d25299a00 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | |||
@@ -212,4 +212,44 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring) | |||
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) | ||
216 | { | ||
217 | if (ring->count_dw <= 0) | ||
218 | DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n"); | ||
219 | ring->ring[ring->wptr++ & ring->buf_mask] = v; | ||
220 | ring->wptr &= ring->ptr_mask; | ||
221 | ring->count_dw--; | ||
222 | } | ||
223 | |||
224 | static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, | ||
225 | void *src, int count_dw) | ||
226 | { | ||
227 | unsigned occupied, chunk1, chunk2; | ||
228 | void *dst; | ||
229 | |||
230 | if (unlikely(ring->count_dw < count_dw)) | ||
231 | DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n"); | ||
232 | |||
233 | occupied = ring->wptr & ring->buf_mask; | ||
234 | dst = (void *)&ring->ring[occupied]; | ||
235 | chunk1 = ring->buf_mask + 1 - occupied; | ||
236 | chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1; | ||
237 | chunk2 = count_dw - chunk1; | ||
238 | chunk1 <<= 2; | ||
239 | chunk2 <<= 2; | ||
240 | |||
241 | if (chunk1) | ||
242 | memcpy(dst, src, chunk1); | ||
243 | |||
244 | if (chunk2) { | ||
245 | src += chunk1; | ||
246 | dst = (void *)ring->ring; | ||
247 | memcpy(dst, src, chunk2); | ||
248 | } | ||
249 | |||
250 | ring->wptr += count_dw; | ||
251 | ring->wptr &= ring->ptr_mask; | ||
252 | ring->count_dw -= count_dw; | ||
253 | } | ||
254 | |||
215 | #endif | 255 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c index 15510dadde01..3c4d7574d704 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | |||
@@ -33,7 +33,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
33 | struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; | 33 | struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; |
34 | struct amdgpu_bo *vram_obj = NULL; | 34 | struct amdgpu_bo *vram_obj = NULL; |
35 | struct amdgpu_bo **gtt_obj = NULL; | 35 | struct amdgpu_bo **gtt_obj = NULL; |
36 | uint64_t gtt_addr, vram_addr; | 36 | uint64_t gart_addr, vram_addr; |
37 | unsigned n, size; | 37 | unsigned n, size; |
38 | int i, r; | 38 | int i, r; |
39 | 39 | ||
@@ -42,7 +42,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
42 | /* Number of tests = | 42 | /* Number of tests = |
43 | * (Total GTT - IB pool - writeback page - ring buffers) / test size | 43 | * (Total GTT - IB pool - writeback page - ring buffers) / test size |
44 | */ | 44 | */ |
45 | n = adev->mc.gtt_size - AMDGPU_IB_POOL_SIZE*64*1024; | 45 | n = adev->mc.gart_size - AMDGPU_IB_POOL_SIZE*64*1024; |
46 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) | 46 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) |
47 | if (adev->rings[i]) | 47 | if (adev->rings[i]) |
48 | n -= adev->rings[i]->ring_size; | 48 | n -= adev->rings[i]->ring_size; |
@@ -76,7 +76,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
76 | } | 76 | } |
77 | for (i = 0; i < n; i++) { | 77 | for (i = 0; i < n; i++) { |
78 | void *gtt_map, *vram_map; | 78 | void *gtt_map, *vram_map; |
79 | void **gtt_start, **gtt_end; | 79 | void **gart_start, **gart_end; |
80 | void **vram_start, **vram_end; | 80 | void **vram_start, **vram_end; |
81 | struct dma_fence *fence = NULL; | 81 | struct dma_fence *fence = NULL; |
82 | 82 | ||
@@ -91,7 +91,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
91 | r = amdgpu_bo_reserve(gtt_obj[i], false); | 91 | r = amdgpu_bo_reserve(gtt_obj[i], false); |
92 | if (unlikely(r != 0)) | 92 | if (unlikely(r != 0)) |
93 | goto out_lclean_unref; | 93 | goto out_lclean_unref; |
94 | r = amdgpu_bo_pin(gtt_obj[i], AMDGPU_GEM_DOMAIN_GTT, >t_addr); | 94 | r = amdgpu_bo_pin(gtt_obj[i], AMDGPU_GEM_DOMAIN_GTT, &gart_addr); |
95 | if (r) { | 95 | if (r) { |
96 | DRM_ERROR("Failed to pin GTT object %d\n", i); | 96 | DRM_ERROR("Failed to pin GTT object %d\n", i); |
97 | goto out_lclean_unres; | 97 | goto out_lclean_unres; |
@@ -103,15 +103,15 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
103 | goto out_lclean_unpin; | 103 | goto out_lclean_unpin; |
104 | } | 104 | } |
105 | 105 | ||
106 | for (gtt_start = gtt_map, gtt_end = gtt_map + size; | 106 | for (gart_start = gtt_map, gart_end = gtt_map + size; |
107 | gtt_start < gtt_end; | 107 | gart_start < gart_end; |
108 | gtt_start++) | 108 | gart_start++) |
109 | *gtt_start = gtt_start; | 109 | *gart_start = gart_start; |
110 | 110 | ||
111 | amdgpu_bo_kunmap(gtt_obj[i]); | 111 | amdgpu_bo_kunmap(gtt_obj[i]); |
112 | 112 | ||
113 | r = amdgpu_copy_buffer(ring, gtt_addr, vram_addr, | 113 | r = amdgpu_copy_buffer(ring, gart_addr, vram_addr, |
114 | size, NULL, &fence, false); | 114 | size, NULL, &fence, false, false); |
115 | 115 | ||
116 | if (r) { | 116 | if (r) { |
117 | DRM_ERROR("Failed GTT->VRAM copy %d\n", i); | 117 | DRM_ERROR("Failed GTT->VRAM copy %d\n", i); |
@@ -132,21 +132,21 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
132 | goto out_lclean_unpin; | 132 | goto out_lclean_unpin; |
133 | } | 133 | } |
134 | 134 | ||
135 | for (gtt_start = gtt_map, gtt_end = gtt_map + size, | 135 | for (gart_start = gtt_map, gart_end = gtt_map + size, |
136 | vram_start = vram_map, vram_end = vram_map + size; | 136 | vram_start = vram_map, vram_end = vram_map + size; |
137 | vram_start < vram_end; | 137 | vram_start < vram_end; |
138 | gtt_start++, vram_start++) { | 138 | gart_start++, vram_start++) { |
139 | if (*vram_start != gtt_start) { | 139 | if (*vram_start != gart_start) { |
140 | DRM_ERROR("Incorrect GTT->VRAM copy %d: Got 0x%p, " | 140 | DRM_ERROR("Incorrect GTT->VRAM copy %d: Got 0x%p, " |
141 | "expected 0x%p (GTT/VRAM offset " | 141 | "expected 0x%p (GTT/VRAM offset " |
142 | "0x%16llx/0x%16llx)\n", | 142 | "0x%16llx/0x%16llx)\n", |
143 | i, *vram_start, gtt_start, | 143 | i, *vram_start, gart_start, |
144 | (unsigned long long) | 144 | (unsigned long long) |
145 | (gtt_addr - adev->mc.gtt_start + | 145 | (gart_addr - adev->mc.gart_start + |
146 | (void*)gtt_start - gtt_map), | 146 | (void*)gart_start - gtt_map), |
147 | (unsigned long long) | 147 | (unsigned long long) |
148 | (vram_addr - adev->mc.vram_start + | 148 | (vram_addr - adev->mc.vram_start + |
149 | (void*)gtt_start - gtt_map)); | 149 | (void*)gart_start - gtt_map)); |
150 | amdgpu_bo_kunmap(vram_obj); | 150 | amdgpu_bo_kunmap(vram_obj); |
151 | goto out_lclean_unpin; | 151 | goto out_lclean_unpin; |
152 | } | 152 | } |
@@ -155,8 +155,8 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
155 | 155 | ||
156 | amdgpu_bo_kunmap(vram_obj); | 156 | amdgpu_bo_kunmap(vram_obj); |
157 | 157 | ||
158 | r = amdgpu_copy_buffer(ring, vram_addr, gtt_addr, | 158 | r = amdgpu_copy_buffer(ring, vram_addr, gart_addr, |
159 | size, NULL, &fence, false); | 159 | size, NULL, &fence, false, false); |
160 | 160 | ||
161 | if (r) { | 161 | if (r) { |
162 | DRM_ERROR("Failed VRAM->GTT copy %d\n", i); | 162 | DRM_ERROR("Failed VRAM->GTT copy %d\n", i); |
@@ -177,20 +177,20 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
177 | goto out_lclean_unpin; | 177 | goto out_lclean_unpin; |
178 | } | 178 | } |
179 | 179 | ||
180 | for (gtt_start = gtt_map, gtt_end = gtt_map + size, | 180 | for (gart_start = gtt_map, gart_end = gtt_map + size, |
181 | vram_start = vram_map, vram_end = vram_map + size; | 181 | vram_start = vram_map, vram_end = vram_map + size; |
182 | gtt_start < gtt_end; | 182 | gart_start < gart_end; |
183 | gtt_start++, vram_start++) { | 183 | gart_start++, vram_start++) { |
184 | if (*gtt_start != vram_start) { | 184 | if (*gart_start != vram_start) { |
185 | DRM_ERROR("Incorrect VRAM->GTT copy %d: Got 0x%p, " | 185 | DRM_ERROR("Incorrect VRAM->GTT copy %d: Got 0x%p, " |
186 | "expected 0x%p (VRAM/GTT offset " | 186 | "expected 0x%p (VRAM/GTT offset " |
187 | "0x%16llx/0x%16llx)\n", | 187 | "0x%16llx/0x%16llx)\n", |
188 | i, *gtt_start, vram_start, | 188 | i, *gart_start, vram_start, |
189 | (unsigned long long) | 189 | (unsigned long long) |
190 | (vram_addr - adev->mc.vram_start + | 190 | (vram_addr - adev->mc.vram_start + |
191 | (void*)vram_start - vram_map), | 191 | (void*)vram_start - vram_map), |
192 | (unsigned long long) | 192 | (unsigned long long) |
193 | (gtt_addr - adev->mc.gtt_start + | 193 | (gart_addr - adev->mc.gart_start + |
194 | (void*)vram_start - vram_map)); | 194 | (void*)vram_start - vram_map)); |
195 | amdgpu_bo_kunmap(gtt_obj[i]); | 195 | amdgpu_bo_kunmap(gtt_obj[i]); |
196 | goto out_lclean_unpin; | 196 | goto out_lclean_unpin; |
@@ -200,7 +200,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
200 | amdgpu_bo_kunmap(gtt_obj[i]); | 200 | amdgpu_bo_kunmap(gtt_obj[i]); |
201 | 201 | ||
202 | DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n", | 202 | DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n", |
203 | gtt_addr - adev->mc.gtt_start); | 203 | gart_addr - adev->mc.gart_start); |
204 | continue; | 204 | continue; |
205 | 205 | ||
206 | out_lclean_unpin: | 206 | out_lclean_unpin: |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h index 8601904e670a..509f7a63d40c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | |||
@@ -224,7 +224,7 @@ TRACE_EVENT(amdgpu_vm_bo_map, | |||
224 | __field(long, start) | 224 | __field(long, start) |
225 | __field(long, last) | 225 | __field(long, last) |
226 | __field(u64, offset) | 226 | __field(u64, offset) |
227 | __field(u32, flags) | 227 | __field(u64, flags) |
228 | ), | 228 | ), |
229 | 229 | ||
230 | TP_fast_assign( | 230 | TP_fast_assign( |
@@ -234,7 +234,7 @@ TRACE_EVENT(amdgpu_vm_bo_map, | |||
234 | __entry->offset = mapping->offset; | 234 | __entry->offset = mapping->offset; |
235 | __entry->flags = mapping->flags; | 235 | __entry->flags = mapping->flags; |
236 | ), | 236 | ), |
237 | TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%08x", | 237 | TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx", |
238 | __entry->bo, __entry->start, __entry->last, | 238 | __entry->bo, __entry->start, __entry->last, |
239 | __entry->offset, __entry->flags) | 239 | __entry->offset, __entry->flags) |
240 | ); | 240 | ); |
@@ -248,7 +248,7 @@ TRACE_EVENT(amdgpu_vm_bo_unmap, | |||
248 | __field(long, start) | 248 | __field(long, start) |
249 | __field(long, last) | 249 | __field(long, last) |
250 | __field(u64, offset) | 250 | __field(u64, offset) |
251 | __field(u32, flags) | 251 | __field(u64, flags) |
252 | ), | 252 | ), |
253 | 253 | ||
254 | TP_fast_assign( | 254 | TP_fast_assign( |
@@ -258,7 +258,7 @@ TRACE_EVENT(amdgpu_vm_bo_unmap, | |||
258 | __entry->offset = mapping->offset; | 258 | __entry->offset = mapping->offset; |
259 | __entry->flags = mapping->flags; | 259 | __entry->flags = mapping->flags; |
260 | ), | 260 | ), |
261 | TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%08x", | 261 | TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx", |
262 | __entry->bo, __entry->start, __entry->last, | 262 | __entry->bo, __entry->start, __entry->last, |
263 | __entry->offset, __entry->flags) | 263 | __entry->offset, __entry->flags) |
264 | ); | 264 | ); |
@@ -269,7 +269,7 @@ DECLARE_EVENT_CLASS(amdgpu_vm_mapping, | |||
269 | TP_STRUCT__entry( | 269 | TP_STRUCT__entry( |
270 | __field(u64, soffset) | 270 | __field(u64, soffset) |
271 | __field(u64, eoffset) | 271 | __field(u64, eoffset) |
272 | __field(u32, flags) | 272 | __field(u64, flags) |
273 | ), | 273 | ), |
274 | 274 | ||
275 | TP_fast_assign( | 275 | TP_fast_assign( |
@@ -277,7 +277,7 @@ DECLARE_EVENT_CLASS(amdgpu_vm_mapping, | |||
277 | __entry->eoffset = mapping->last + 1; | 277 | __entry->eoffset = mapping->last + 1; |
278 | __entry->flags = mapping->flags; | 278 | __entry->flags = mapping->flags; |
279 | ), | 279 | ), |
280 | TP_printk("soffs=%010llx, eoffs=%010llx, flags=%08x", | 280 | TP_printk("soffs=%010llx, eoffs=%010llx, flags=%llx", |
281 | __entry->soffset, __entry->eoffset, __entry->flags) | 281 | __entry->soffset, __entry->eoffset, __entry->flags) |
282 | ); | 282 | ); |
283 | 283 | ||
@@ -293,14 +293,14 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_mapping, | |||
293 | 293 | ||
294 | TRACE_EVENT(amdgpu_vm_set_ptes, | 294 | TRACE_EVENT(amdgpu_vm_set_ptes, |
295 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, | 295 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, |
296 | uint32_t incr, uint32_t flags), | 296 | uint32_t incr, uint64_t flags), |
297 | TP_ARGS(pe, addr, count, incr, flags), | 297 | TP_ARGS(pe, addr, count, incr, flags), |
298 | TP_STRUCT__entry( | 298 | TP_STRUCT__entry( |
299 | __field(u64, pe) | 299 | __field(u64, pe) |
300 | __field(u64, addr) | 300 | __field(u64, addr) |
301 | __field(u32, count) | 301 | __field(u32, count) |
302 | __field(u32, incr) | 302 | __field(u32, incr) |
303 | __field(u32, flags) | 303 | __field(u64, flags) |
304 | ), | 304 | ), |
305 | 305 | ||
306 | TP_fast_assign( | 306 | TP_fast_assign( |
@@ -310,7 +310,7 @@ TRACE_EVENT(amdgpu_vm_set_ptes, | |||
310 | __entry->incr = incr; | 310 | __entry->incr = incr; |
311 | __entry->flags = flags; | 311 | __entry->flags = flags; |
312 | ), | 312 | ), |
313 | TP_printk("pe=%010Lx, addr=%010Lx, incr=%u, flags=%08x, count=%u", | 313 | TP_printk("pe=%010Lx, addr=%010Lx, incr=%u, flags=%llx, count=%u", |
314 | __entry->pe, __entry->addr, __entry->incr, | 314 | __entry->pe, __entry->addr, __entry->incr, |
315 | __entry->flags, __entry->count) | 315 | __entry->flags, __entry->count) |
316 | ); | 316 | ); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index c9b131b13ef7..e6f9a54c959d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -47,10 +47,15 @@ | |||
47 | 47 | ||
48 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) | 48 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
49 | 49 | ||
50 | static int amdgpu_map_buffer(struct ttm_buffer_object *bo, | ||
51 | struct ttm_mem_reg *mem, unsigned num_pages, | ||
52 | uint64_t offset, unsigned window, | ||
53 | struct amdgpu_ring *ring, | ||
54 | uint64_t *addr); | ||
55 | |||
50 | static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev); | 56 | static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev); |
51 | static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev); | 57 | static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev); |
52 | 58 | ||
53 | |||
54 | /* | 59 | /* |
55 | * Global memory. | 60 | * Global memory. |
56 | */ | 61 | */ |
@@ -97,6 +102,8 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
97 | goto error_bo; | 102 | goto error_bo; |
98 | } | 103 | } |
99 | 104 | ||
105 | mutex_init(&adev->mman.gtt_window_lock); | ||
106 | |||
100 | ring = adev->mman.buffer_funcs_ring; | 107 | ring = adev->mman.buffer_funcs_ring; |
101 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; | 108 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; |
102 | r = amd_sched_entity_init(&ring->sched, &adev->mman.entity, | 109 | r = amd_sched_entity_init(&ring->sched, &adev->mman.entity, |
@@ -123,6 +130,7 @@ static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) | |||
123 | if (adev->mman.mem_global_referenced) { | 130 | if (adev->mman.mem_global_referenced) { |
124 | amd_sched_entity_fini(adev->mman.entity.sched, | 131 | amd_sched_entity_fini(adev->mman.entity.sched, |
125 | &adev->mman.entity); | 132 | &adev->mman.entity); |
133 | mutex_destroy(&adev->mman.gtt_window_lock); | ||
126 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); | 134 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); |
127 | drm_global_item_unref(&adev->mman.mem_global_ref); | 135 | drm_global_item_unref(&adev->mman.mem_global_ref); |
128 | adev->mman.mem_global_referenced = false; | 136 | adev->mman.mem_global_referenced = false; |
@@ -150,7 +158,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
150 | break; | 158 | break; |
151 | case TTM_PL_TT: | 159 | case TTM_PL_TT: |
152 | man->func = &amdgpu_gtt_mgr_func; | 160 | man->func = &amdgpu_gtt_mgr_func; |
153 | man->gpu_offset = adev->mc.gtt_start; | 161 | man->gpu_offset = adev->mc.gart_start; |
154 | man->available_caching = TTM_PL_MASK_CACHING; | 162 | man->available_caching = TTM_PL_MASK_CACHING; |
155 | man->default_caching = TTM_PL_FLAG_CACHED; | 163 | man->default_caching = TTM_PL_FLAG_CACHED; |
156 | man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA; | 164 | man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA; |
@@ -186,12 +194,11 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
186 | { | 194 | { |
187 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); | 195 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); |
188 | struct amdgpu_bo *abo; | 196 | struct amdgpu_bo *abo; |
189 | static struct ttm_place placements = { | 197 | static const struct ttm_place placements = { |
190 | .fpfn = 0, | 198 | .fpfn = 0, |
191 | .lpfn = 0, | 199 | .lpfn = 0, |
192 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | 200 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM |
193 | }; | 201 | }; |
194 | unsigned i; | ||
195 | 202 | ||
196 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { | 203 | if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) { |
197 | placement->placement = &placements; | 204 | placement->placement = &placements; |
@@ -207,22 +214,36 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, | |||
207 | adev->mman.buffer_funcs_ring && | 214 | adev->mman.buffer_funcs_ring && |
208 | adev->mman.buffer_funcs_ring->ready == false) { | 215 | adev->mman.buffer_funcs_ring->ready == false) { |
209 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); | 216 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); |
217 | } else if (adev->mc.visible_vram_size < adev->mc.real_vram_size && | ||
218 | !(abo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)) { | ||
219 | unsigned fpfn = adev->mc.visible_vram_size >> PAGE_SHIFT; | ||
220 | struct drm_mm_node *node = bo->mem.mm_node; | ||
221 | unsigned long pages_left; | ||
222 | |||
223 | for (pages_left = bo->mem.num_pages; | ||
224 | pages_left; | ||
225 | pages_left -= node->size, node++) { | ||
226 | if (node->start < fpfn) | ||
227 | break; | ||
228 | } | ||
229 | |||
230 | if (!pages_left) | ||
231 | goto gtt; | ||
232 | |||
233 | /* Try evicting to the CPU inaccessible part of VRAM | ||
234 | * first, but only set GTT as busy placement, so this | ||
235 | * BO will be evicted to GTT rather than causing other | ||
236 | * BOs to be evicted from VRAM | ||
237 | */ | ||
238 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM | | ||
239 | AMDGPU_GEM_DOMAIN_GTT); | ||
240 | abo->placements[0].fpfn = fpfn; | ||
241 | abo->placements[0].lpfn = 0; | ||
242 | abo->placement.busy_placement = &abo->placements[1]; | ||
243 | abo->placement.num_busy_placement = 1; | ||
210 | } else { | 244 | } else { |
245 | gtt: | ||
211 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); | 246 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); |
212 | for (i = 0; i < abo->placement.num_placement; ++i) { | ||
213 | if (!(abo->placements[i].flags & | ||
214 | TTM_PL_FLAG_TT)) | ||
215 | continue; | ||
216 | |||
217 | if (abo->placements[i].lpfn) | ||
218 | continue; | ||
219 | |||
220 | /* set an upper limit to force directly | ||
221 | * allocating address space for the BO. | ||
222 | */ | ||
223 | abo->placements[i].lpfn = | ||
224 | adev->mc.gtt_size >> PAGE_SHIFT; | ||
225 | } | ||
226 | } | 247 | } |
227 | break; | 248 | break; |
228 | case TTM_PL_TT: | 249 | case TTM_PL_TT: |
@@ -252,29 +273,18 @@ static void amdgpu_move_null(struct ttm_buffer_object *bo, | |||
252 | new_mem->mm_node = NULL; | 273 | new_mem->mm_node = NULL; |
253 | } | 274 | } |
254 | 275 | ||
255 | static int amdgpu_mm_node_addr(struct ttm_buffer_object *bo, | 276 | static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo, |
256 | struct drm_mm_node *mm_node, | 277 | struct drm_mm_node *mm_node, |
257 | struct ttm_mem_reg *mem, | 278 | struct ttm_mem_reg *mem) |
258 | uint64_t *addr) | ||
259 | { | 279 | { |
260 | int r; | 280 | uint64_t addr = 0; |
261 | |||
262 | switch (mem->mem_type) { | ||
263 | case TTM_PL_TT: | ||
264 | r = amdgpu_ttm_bind(bo, mem); | ||
265 | if (r) | ||
266 | return r; | ||
267 | 281 | ||
268 | case TTM_PL_VRAM: | 282 | if (mem->mem_type != TTM_PL_TT || |
269 | *addr = mm_node->start << PAGE_SHIFT; | 283 | amdgpu_gtt_mgr_is_allocated(mem)) { |
270 | *addr += bo->bdev->man[mem->mem_type].gpu_offset; | 284 | addr = mm_node->start << PAGE_SHIFT; |
271 | break; | 285 | addr += bo->bdev->man[mem->mem_type].gpu_offset; |
272 | default: | ||
273 | DRM_ERROR("Unknown placement %d\n", mem->mem_type); | ||
274 | return -EINVAL; | ||
275 | } | 286 | } |
276 | 287 | return addr; | |
277 | return 0; | ||
278 | } | 288 | } |
279 | 289 | ||
280 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, | 290 | static int amdgpu_move_blit(struct ttm_buffer_object *bo, |
@@ -299,26 +309,40 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
299 | } | 309 | } |
300 | 310 | ||
301 | old_mm = old_mem->mm_node; | 311 | old_mm = old_mem->mm_node; |
302 | r = amdgpu_mm_node_addr(bo, old_mm, old_mem, &old_start); | ||
303 | if (r) | ||
304 | return r; | ||
305 | old_size = old_mm->size; | 312 | old_size = old_mm->size; |
306 | 313 | old_start = amdgpu_mm_node_addr(bo, old_mm, old_mem); | |
307 | 314 | ||
308 | new_mm = new_mem->mm_node; | 315 | new_mm = new_mem->mm_node; |
309 | r = amdgpu_mm_node_addr(bo, new_mm, new_mem, &new_start); | ||
310 | if (r) | ||
311 | return r; | ||
312 | new_size = new_mm->size; | 316 | new_size = new_mm->size; |
317 | new_start = amdgpu_mm_node_addr(bo, new_mm, new_mem); | ||
313 | 318 | ||
314 | num_pages = new_mem->num_pages; | 319 | num_pages = new_mem->num_pages; |
320 | mutex_lock(&adev->mman.gtt_window_lock); | ||
315 | while (num_pages) { | 321 | while (num_pages) { |
316 | unsigned long cur_pages = min(old_size, new_size); | 322 | unsigned long cur_pages = min(min(old_size, new_size), |
323 | (u64)AMDGPU_GTT_MAX_TRANSFER_SIZE); | ||
324 | uint64_t from = old_start, to = new_start; | ||
317 | struct dma_fence *next; | 325 | struct dma_fence *next; |
318 | 326 | ||
319 | r = amdgpu_copy_buffer(ring, old_start, new_start, | 327 | if (old_mem->mem_type == TTM_PL_TT && |
328 | !amdgpu_gtt_mgr_is_allocated(old_mem)) { | ||
329 | r = amdgpu_map_buffer(bo, old_mem, cur_pages, | ||
330 | old_start, 0, ring, &from); | ||
331 | if (r) | ||
332 | goto error; | ||
333 | } | ||
334 | |||
335 | if (new_mem->mem_type == TTM_PL_TT && | ||
336 | !amdgpu_gtt_mgr_is_allocated(new_mem)) { | ||
337 | r = amdgpu_map_buffer(bo, new_mem, cur_pages, | ||
338 | new_start, 1, ring, &to); | ||
339 | if (r) | ||
340 | goto error; | ||
341 | } | ||
342 | |||
343 | r = amdgpu_copy_buffer(ring, from, to, | ||
320 | cur_pages * PAGE_SIZE, | 344 | cur_pages * PAGE_SIZE, |
321 | bo->resv, &next, false); | 345 | bo->resv, &next, false, true); |
322 | if (r) | 346 | if (r) |
323 | goto error; | 347 | goto error; |
324 | 348 | ||
@@ -331,10 +355,7 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
331 | 355 | ||
332 | old_size -= cur_pages; | 356 | old_size -= cur_pages; |
333 | if (!old_size) { | 357 | if (!old_size) { |
334 | r = amdgpu_mm_node_addr(bo, ++old_mm, old_mem, | 358 | old_start = amdgpu_mm_node_addr(bo, ++old_mm, old_mem); |
335 | &old_start); | ||
336 | if (r) | ||
337 | goto error; | ||
338 | old_size = old_mm->size; | 359 | old_size = old_mm->size; |
339 | } else { | 360 | } else { |
340 | old_start += cur_pages * PAGE_SIZE; | 361 | old_start += cur_pages * PAGE_SIZE; |
@@ -342,22 +363,21 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, | |||
342 | 363 | ||
343 | new_size -= cur_pages; | 364 | new_size -= cur_pages; |
344 | if (!new_size) { | 365 | if (!new_size) { |
345 | r = amdgpu_mm_node_addr(bo, ++new_mm, new_mem, | 366 | new_start = amdgpu_mm_node_addr(bo, ++new_mm, new_mem); |
346 | &new_start); | ||
347 | if (r) | ||
348 | goto error; | ||
349 | |||
350 | new_size = new_mm->size; | 367 | new_size = new_mm->size; |
351 | } else { | 368 | } else { |
352 | new_start += cur_pages * PAGE_SIZE; | 369 | new_start += cur_pages * PAGE_SIZE; |
353 | } | 370 | } |
354 | } | 371 | } |
372 | mutex_unlock(&adev->mman.gtt_window_lock); | ||
355 | 373 | ||
356 | r = ttm_bo_pipeline_move(bo, fence, evict, new_mem); | 374 | r = ttm_bo_pipeline_move(bo, fence, evict, new_mem); |
357 | dma_fence_put(fence); | 375 | dma_fence_put(fence); |
358 | return r; | 376 | return r; |
359 | 377 | ||
360 | error: | 378 | error: |
379 | mutex_unlock(&adev->mman.gtt_window_lock); | ||
380 | |||
361 | if (fence) | 381 | if (fence) |
362 | dma_fence_wait(fence, false); | 382 | dma_fence_wait(fence, false); |
363 | dma_fence_put(fence); | 383 | dma_fence_put(fence); |
@@ -384,7 +404,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, | |||
384 | placement.num_busy_placement = 1; | 404 | placement.num_busy_placement = 1; |
385 | placement.busy_placement = &placements; | 405 | placement.busy_placement = &placements; |
386 | placements.fpfn = 0; | 406 | placements.fpfn = 0; |
387 | placements.lpfn = adev->mc.gtt_size >> PAGE_SHIFT; | 407 | placements.lpfn = 0; |
388 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; | 408 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; |
389 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, | 409 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, |
390 | interruptible, no_wait_gpu); | 410 | interruptible, no_wait_gpu); |
@@ -431,7 +451,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, | |||
431 | placement.num_busy_placement = 1; | 451 | placement.num_busy_placement = 1; |
432 | placement.busy_placement = &placements; | 452 | placement.busy_placement = &placements; |
433 | placements.fpfn = 0; | 453 | placements.fpfn = 0; |
434 | placements.lpfn = adev->mc.gtt_size >> PAGE_SHIFT; | 454 | placements.lpfn = 0; |
435 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; | 455 | placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; |
436 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, | 456 | r = ttm_bo_mem_space(bo, &placement, &tmp_mem, |
437 | interruptible, no_wait_gpu); | 457 | interruptible, no_wait_gpu); |
@@ -507,6 +527,15 @@ memcpy: | |||
507 | } | 527 | } |
508 | } | 528 | } |
509 | 529 | ||
530 | if (bo->type == ttm_bo_type_device && | ||
531 | new_mem->mem_type == TTM_PL_VRAM && | ||
532 | old_mem->mem_type != TTM_PL_VRAM) { | ||
533 | /* amdgpu_bo_fault_reserve_notify will re-set this if the CPU | ||
534 | * accesses the BO after it's moved. | ||
535 | */ | ||
536 | abo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | ||
537 | } | ||
538 | |||
510 | /* update statistics */ | 539 | /* update statistics */ |
511 | atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &adev->num_bytes_moved); | 540 | atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &adev->num_bytes_moved); |
512 | return 0; | 541 | return 0; |
@@ -695,6 +724,31 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm) | |||
695 | sg_free_table(ttm->sg); | 724 | sg_free_table(ttm->sg); |
696 | } | 725 | } |
697 | 726 | ||
727 | static int amdgpu_ttm_do_bind(struct ttm_tt *ttm, struct ttm_mem_reg *mem) | ||
728 | { | ||
729 | struct amdgpu_ttm_tt *gtt = (void *)ttm; | ||
730 | uint64_t flags; | ||
731 | int r; | ||
732 | |||
733 | spin_lock(>t->adev->gtt_list_lock); | ||
734 | flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, mem); | ||
735 | gtt->offset = (u64)mem->start << PAGE_SHIFT; | ||
736 | r = amdgpu_gart_bind(gtt->adev, gtt->offset, ttm->num_pages, | ||
737 | ttm->pages, gtt->ttm.dma_address, flags); | ||
738 | |||
739 | if (r) { | ||
740 | DRM_ERROR("failed to bind %lu pages at 0x%08llX\n", | ||
741 | ttm->num_pages, gtt->offset); | ||
742 | goto error_gart_bind; | ||
743 | } | ||
744 | |||
745 | list_add_tail(>t->list, >t->adev->gtt_list); | ||
746 | error_gart_bind: | ||
747 | spin_unlock(>t->adev->gtt_list_lock); | ||
748 | return r; | ||
749 | |||
750 | } | ||
751 | |||
698 | static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | 752 | static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, |
699 | struct ttm_mem_reg *bo_mem) | 753 | struct ttm_mem_reg *bo_mem) |
700 | { | 754 | { |
@@ -718,7 +772,10 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, | |||
718 | bo_mem->mem_type == AMDGPU_PL_OA) | 772 | bo_mem->mem_type == AMDGPU_PL_OA) |
719 | return -EINVAL; | 773 | return -EINVAL; |
720 | 774 | ||
721 | return 0; | 775 | if (amdgpu_gtt_mgr_is_allocated(bo_mem)) |
776 | r = amdgpu_ttm_do_bind(ttm, bo_mem); | ||
777 | |||
778 | return r; | ||
722 | } | 779 | } |
723 | 780 | ||
724 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm) | 781 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm) |
@@ -731,8 +788,6 @@ bool amdgpu_ttm_is_bound(struct ttm_tt *ttm) | |||
731 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem) | 788 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem) |
732 | { | 789 | { |
733 | struct ttm_tt *ttm = bo->ttm; | 790 | struct ttm_tt *ttm = bo->ttm; |
734 | struct amdgpu_ttm_tt *gtt = (void *)bo->ttm; | ||
735 | uint64_t flags; | ||
736 | int r; | 791 | int r; |
737 | 792 | ||
738 | if (!ttm || amdgpu_ttm_is_bound(ttm)) | 793 | if (!ttm || amdgpu_ttm_is_bound(ttm)) |
@@ -745,22 +800,7 @@ int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem) | |||
745 | return r; | 800 | return r; |
746 | } | 801 | } |
747 | 802 | ||
748 | spin_lock(>t->adev->gtt_list_lock); | 803 | return amdgpu_ttm_do_bind(ttm, bo_mem); |
749 | flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem); | ||
750 | gtt->offset = (u64)bo_mem->start << PAGE_SHIFT; | ||
751 | r = amdgpu_gart_bind(gtt->adev, gtt->offset, ttm->num_pages, | ||
752 | ttm->pages, gtt->ttm.dma_address, flags); | ||
753 | |||
754 | if (r) { | ||
755 | DRM_ERROR("failed to bind %lu pages at 0x%08llX\n", | ||
756 | ttm->num_pages, gtt->offset); | ||
757 | goto error_gart_bind; | ||
758 | } | ||
759 | |||
760 | list_add_tail(>t->list, >t->adev->gtt_list); | ||
761 | error_gart_bind: | ||
762 | spin_unlock(>t->adev->gtt_list_lock); | ||
763 | return r; | ||
764 | } | 804 | } |
765 | 805 | ||
766 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) | 806 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev) |
@@ -1075,6 +1115,67 @@ static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, | |||
1075 | return ttm_bo_eviction_valuable(bo, place); | 1115 | return ttm_bo_eviction_valuable(bo, place); |
1076 | } | 1116 | } |
1077 | 1117 | ||
1118 | static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo, | ||
1119 | unsigned long offset, | ||
1120 | void *buf, int len, int write) | ||
1121 | { | ||
1122 | struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo); | ||
1123 | struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev); | ||
1124 | struct drm_mm_node *nodes = abo->tbo.mem.mm_node; | ||
1125 | uint32_t value = 0; | ||
1126 | int ret = 0; | ||
1127 | uint64_t pos; | ||
1128 | unsigned long flags; | ||
1129 | |||
1130 | if (bo->mem.mem_type != TTM_PL_VRAM) | ||
1131 | return -EIO; | ||
1132 | |||
1133 | while (offset >= (nodes->size << PAGE_SHIFT)) { | ||
1134 | offset -= nodes->size << PAGE_SHIFT; | ||
1135 | ++nodes; | ||
1136 | } | ||
1137 | pos = (nodes->start << PAGE_SHIFT) + offset; | ||
1138 | |||
1139 | while (len && pos < adev->mc.mc_vram_size) { | ||
1140 | uint64_t aligned_pos = pos & ~(uint64_t)3; | ||
1141 | uint32_t bytes = 4 - (pos & 3); | ||
1142 | uint32_t shift = (pos & 3) * 8; | ||
1143 | uint32_t mask = 0xffffffff << shift; | ||
1144 | |||
1145 | if (len < bytes) { | ||
1146 | mask &= 0xffffffff >> (bytes - len) * 8; | ||
1147 | bytes = len; | ||
1148 | } | ||
1149 | |||
1150 | spin_lock_irqsave(&adev->mmio_idx_lock, flags); | ||
1151 | WREG32(mmMM_INDEX, ((uint32_t)aligned_pos) | 0x80000000); | ||
1152 | WREG32(mmMM_INDEX_HI, aligned_pos >> 31); | ||
1153 | if (!write || mask != 0xffffffff) | ||
1154 | value = RREG32(mmMM_DATA); | ||
1155 | if (write) { | ||
1156 | value &= ~mask; | ||
1157 | value |= (*(uint32_t *)buf << shift) & mask; | ||
1158 | WREG32(mmMM_DATA, value); | ||
1159 | } | ||
1160 | spin_unlock_irqrestore(&adev->mmio_idx_lock, flags); | ||
1161 | if (!write) { | ||
1162 | value = (value & mask) >> shift; | ||
1163 | memcpy(buf, &value, bytes); | ||
1164 | } | ||
1165 | |||
1166 | ret += bytes; | ||
1167 | buf = (uint8_t *)buf + bytes; | ||
1168 | pos += bytes; | ||
1169 | len -= bytes; | ||
1170 | if (pos >= (nodes->start + nodes->size) << PAGE_SHIFT) { | ||
1171 | ++nodes; | ||
1172 | pos = (nodes->start << PAGE_SHIFT); | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | return ret; | ||
1177 | } | ||
1178 | |||
1078 | static struct ttm_bo_driver amdgpu_bo_driver = { | 1179 | static struct ttm_bo_driver amdgpu_bo_driver = { |
1079 | .ttm_tt_create = &amdgpu_ttm_tt_create, | 1180 | .ttm_tt_create = &amdgpu_ttm_tt_create, |
1080 | .ttm_tt_populate = &amdgpu_ttm_tt_populate, | 1181 | .ttm_tt_populate = &amdgpu_ttm_tt_populate, |
@@ -1090,11 +1191,14 @@ static struct ttm_bo_driver amdgpu_bo_driver = { | |||
1090 | .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, | 1191 | .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, |
1091 | .io_mem_free = &amdgpu_ttm_io_mem_free, | 1192 | .io_mem_free = &amdgpu_ttm_io_mem_free, |
1092 | .io_mem_pfn = amdgpu_ttm_io_mem_pfn, | 1193 | .io_mem_pfn = amdgpu_ttm_io_mem_pfn, |
1194 | .access_memory = &amdgpu_ttm_access_memory | ||
1093 | }; | 1195 | }; |
1094 | 1196 | ||
1095 | int amdgpu_ttm_init(struct amdgpu_device *adev) | 1197 | int amdgpu_ttm_init(struct amdgpu_device *adev) |
1096 | { | 1198 | { |
1199 | uint64_t gtt_size; | ||
1097 | int r; | 1200 | int r; |
1201 | u64 vis_vram_limit; | ||
1098 | 1202 | ||
1099 | r = amdgpu_ttm_global_init(adev); | 1203 | r = amdgpu_ttm_global_init(adev); |
1100 | if (r) { | 1204 | if (r) { |
@@ -1118,6 +1222,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1118 | DRM_ERROR("Failed initializing VRAM heap.\n"); | 1222 | DRM_ERROR("Failed initializing VRAM heap.\n"); |
1119 | return r; | 1223 | return r; |
1120 | } | 1224 | } |
1225 | |||
1226 | /* Reduce size of CPU-visible VRAM if requested */ | ||
1227 | vis_vram_limit = (u64)amdgpu_vis_vram_limit * 1024 * 1024; | ||
1228 | if (amdgpu_vis_vram_limit > 0 && | ||
1229 | vis_vram_limit <= adev->mc.visible_vram_size) | ||
1230 | adev->mc.visible_vram_size = vis_vram_limit; | ||
1231 | |||
1121 | /* Change the size here instead of the init above so only lpfn is affected */ | 1232 | /* Change the size here instead of the init above so only lpfn is affected */ |
1122 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size); | 1233 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size); |
1123 | 1234 | ||
@@ -1140,14 +1251,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1140 | } | 1251 | } |
1141 | DRM_INFO("amdgpu: %uM of VRAM memory ready\n", | 1252 | DRM_INFO("amdgpu: %uM of VRAM memory ready\n", |
1142 | (unsigned) (adev->mc.real_vram_size / (1024 * 1024))); | 1253 | (unsigned) (adev->mc.real_vram_size / (1024 * 1024))); |
1143 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, | 1254 | |
1144 | adev->mc.gtt_size >> PAGE_SHIFT); | 1255 | if (amdgpu_gtt_size == -1) |
1256 | gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), | ||
1257 | adev->mc.mc_vram_size); | ||
1258 | else | ||
1259 | gtt_size = (uint64_t)amdgpu_gtt_size << 20; | ||
1260 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); | ||
1145 | if (r) { | 1261 | if (r) { |
1146 | DRM_ERROR("Failed initializing GTT heap.\n"); | 1262 | DRM_ERROR("Failed initializing GTT heap.\n"); |
1147 | return r; | 1263 | return r; |
1148 | } | 1264 | } |
1149 | DRM_INFO("amdgpu: %uM of GTT memory ready.\n", | 1265 | DRM_INFO("amdgpu: %uM of GTT memory ready.\n", |
1150 | (unsigned)(adev->mc.gtt_size / (1024 * 1024))); | 1266 | (unsigned)(gtt_size / (1024 * 1024))); |
1151 | 1267 | ||
1152 | adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT; | 1268 | adev->gds.mem.total_size = adev->gds.mem.total_size << AMDGPU_GDS_SHIFT; |
1153 | adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT; | 1269 | adev->gds.mem.gfx_partition_size = adev->gds.mem.gfx_partition_size << AMDGPU_GDS_SHIFT; |
@@ -1256,12 +1372,77 @@ int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1256 | return ttm_bo_mmap(filp, vma, &adev->mman.bdev); | 1372 | return ttm_bo_mmap(filp, vma, &adev->mman.bdev); |
1257 | } | 1373 | } |
1258 | 1374 | ||
1259 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, | 1375 | static int amdgpu_map_buffer(struct ttm_buffer_object *bo, |
1260 | uint64_t src_offset, | 1376 | struct ttm_mem_reg *mem, unsigned num_pages, |
1261 | uint64_t dst_offset, | 1377 | uint64_t offset, unsigned window, |
1262 | uint32_t byte_count, | 1378 | struct amdgpu_ring *ring, |
1379 | uint64_t *addr) | ||
1380 | { | ||
1381 | struct amdgpu_ttm_tt *gtt = (void *)bo->ttm; | ||
1382 | struct amdgpu_device *adev = ring->adev; | ||
1383 | struct ttm_tt *ttm = bo->ttm; | ||
1384 | struct amdgpu_job *job; | ||
1385 | unsigned num_dw, num_bytes; | ||
1386 | dma_addr_t *dma_address; | ||
1387 | struct dma_fence *fence; | ||
1388 | uint64_t src_addr, dst_addr; | ||
1389 | uint64_t flags; | ||
1390 | int r; | ||
1391 | |||
1392 | BUG_ON(adev->mman.buffer_funcs->copy_max_bytes < | ||
1393 | AMDGPU_GTT_MAX_TRANSFER_SIZE * 8); | ||
1394 | |||
1395 | *addr = adev->mc.gart_start; | ||
1396 | *addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE * | ||
1397 | AMDGPU_GPU_PAGE_SIZE; | ||
1398 | |||
1399 | num_dw = adev->mman.buffer_funcs->copy_num_dw; | ||
1400 | while (num_dw & 0x7) | ||
1401 | num_dw++; | ||
1402 | |||
1403 | num_bytes = num_pages * 8; | ||
1404 | |||
1405 | r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job); | ||
1406 | if (r) | ||
1407 | return r; | ||
1408 | |||
1409 | src_addr = num_dw * 4; | ||
1410 | src_addr += job->ibs[0].gpu_addr; | ||
1411 | |||
1412 | dst_addr = adev->gart.table_addr; | ||
1413 | dst_addr += window * AMDGPU_GTT_MAX_TRANSFER_SIZE * 8; | ||
1414 | amdgpu_emit_copy_buffer(adev, &job->ibs[0], src_addr, | ||
1415 | dst_addr, num_bytes); | ||
1416 | |||
1417 | amdgpu_ring_pad_ib(ring, &job->ibs[0]); | ||
1418 | WARN_ON(job->ibs[0].length_dw > num_dw); | ||
1419 | |||
1420 | dma_address = >t->ttm.dma_address[offset >> PAGE_SHIFT]; | ||
1421 | flags = amdgpu_ttm_tt_pte_flags(adev, ttm, mem); | ||
1422 | r = amdgpu_gart_map(adev, 0, num_pages, dma_address, flags, | ||
1423 | &job->ibs[0].ptr[num_dw]); | ||
1424 | if (r) | ||
1425 | goto error_free; | ||
1426 | |||
1427 | r = amdgpu_job_submit(job, ring, &adev->mman.entity, | ||
1428 | AMDGPU_FENCE_OWNER_UNDEFINED, &fence); | ||
1429 | if (r) | ||
1430 | goto error_free; | ||
1431 | |||
1432 | dma_fence_put(fence); | ||
1433 | |||
1434 | return r; | ||
1435 | |||
1436 | error_free: | ||
1437 | amdgpu_job_free(job); | ||
1438 | return r; | ||
1439 | } | ||
1440 | |||
1441 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, | ||
1442 | uint64_t dst_offset, uint32_t byte_count, | ||
1263 | struct reservation_object *resv, | 1443 | struct reservation_object *resv, |
1264 | struct dma_fence **fence, bool direct_submit) | 1444 | struct dma_fence **fence, bool direct_submit, |
1445 | bool vm_needs_flush) | ||
1265 | { | 1446 | { |
1266 | struct amdgpu_device *adev = ring->adev; | 1447 | struct amdgpu_device *adev = ring->adev; |
1267 | struct amdgpu_job *job; | 1448 | struct amdgpu_job *job; |
@@ -1283,6 +1464,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, | |||
1283 | if (r) | 1464 | if (r) |
1284 | return r; | 1465 | return r; |
1285 | 1466 | ||
1467 | job->vm_needs_flush = vm_needs_flush; | ||
1286 | if (resv) { | 1468 | if (resv) { |
1287 | r = amdgpu_sync_resv(adev, &job->sync, resv, | 1469 | r = amdgpu_sync_resv(adev, &job->sync, resv, |
1288 | AMDGPU_FENCE_OWNER_UNDEFINED); | 1470 | AMDGPU_FENCE_OWNER_UNDEFINED); |
@@ -1347,6 +1529,12 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, | |||
1347 | return -EINVAL; | 1529 | return -EINVAL; |
1348 | } | 1530 | } |
1349 | 1531 | ||
1532 | if (bo->tbo.mem.mem_type == TTM_PL_TT) { | ||
1533 | r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem); | ||
1534 | if (r) | ||
1535 | return r; | ||
1536 | } | ||
1537 | |||
1350 | num_pages = bo->tbo.num_pages; | 1538 | num_pages = bo->tbo.num_pages; |
1351 | mm_node = bo->tbo.mem.mm_node; | 1539 | mm_node = bo->tbo.mem.mm_node; |
1352 | num_loops = 0; | 1540 | num_loops = 0; |
@@ -1382,11 +1570,7 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, | |||
1382 | uint32_t byte_count = mm_node->size << PAGE_SHIFT; | 1570 | uint32_t byte_count = mm_node->size << PAGE_SHIFT; |
1383 | uint64_t dst_addr; | 1571 | uint64_t dst_addr; |
1384 | 1572 | ||
1385 | r = amdgpu_mm_node_addr(&bo->tbo, mm_node, | 1573 | dst_addr = amdgpu_mm_node_addr(&bo->tbo, mm_node, &bo->tbo.mem); |
1386 | &bo->tbo.mem, &dst_addr); | ||
1387 | if (r) | ||
1388 | return r; | ||
1389 | |||
1390 | while (byte_count) { | 1574 | while (byte_count) { |
1391 | uint32_t cur_size_in_bytes = min(byte_count, max_bytes); | 1575 | uint32_t cur_size_in_bytes = min(byte_count, max_bytes); |
1392 | 1576 | ||
@@ -1574,7 +1758,7 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) | |||
1574 | adev, &amdgpu_ttm_gtt_fops); | 1758 | adev, &amdgpu_ttm_gtt_fops); |
1575 | if (IS_ERR(ent)) | 1759 | if (IS_ERR(ent)) |
1576 | return PTR_ERR(ent); | 1760 | return PTR_ERR(ent); |
1577 | i_size_write(ent->d_inode, adev->mc.gtt_size); | 1761 | i_size_write(ent->d_inode, adev->mc.gart_size); |
1578 | adev->mman.gtt = ent; | 1762 | adev->mman.gtt = ent; |
1579 | 1763 | ||
1580 | #endif | 1764 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 6bdede8ff12b..f137c2458ee8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -34,6 +34,9 @@ | |||
34 | #define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) | 34 | #define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) |
35 | #define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) | 35 | #define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) |
36 | 36 | ||
37 | #define AMDGPU_GTT_MAX_TRANSFER_SIZE 512 | ||
38 | #define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2 | ||
39 | |||
37 | struct amdgpu_mman { | 40 | struct amdgpu_mman { |
38 | struct ttm_bo_global_ref bo_global_ref; | 41 | struct ttm_bo_global_ref bo_global_ref; |
39 | struct drm_global_reference mem_global_ref; | 42 | struct drm_global_reference mem_global_ref; |
@@ -49,6 +52,8 @@ struct amdgpu_mman { | |||
49 | /* buffer handling */ | 52 | /* buffer handling */ |
50 | const struct amdgpu_buffer_funcs *buffer_funcs; | 53 | const struct amdgpu_buffer_funcs *buffer_funcs; |
51 | struct amdgpu_ring *buffer_funcs_ring; | 54 | struct amdgpu_ring *buffer_funcs_ring; |
55 | |||
56 | struct mutex gtt_window_lock; | ||
52 | /* Scheduler entity for buffer moves */ | 57 | /* Scheduler entity for buffer moves */ |
53 | struct amd_sched_entity entity; | 58 | struct amd_sched_entity entity; |
54 | }; | 59 | }; |
@@ -56,17 +61,17 @@ struct amdgpu_mman { | |||
56 | extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; | 61 | extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; |
57 | extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; | 62 | extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; |
58 | 63 | ||
64 | bool amdgpu_gtt_mgr_is_allocated(struct ttm_mem_reg *mem); | ||
59 | int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, | 65 | int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man, |
60 | struct ttm_buffer_object *tbo, | 66 | struct ttm_buffer_object *tbo, |
61 | const struct ttm_place *place, | 67 | const struct ttm_place *place, |
62 | struct ttm_mem_reg *mem); | 68 | struct ttm_mem_reg *mem); |
63 | 69 | ||
64 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, | 70 | int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, |
65 | uint64_t src_offset, | 71 | uint64_t dst_offset, uint32_t byte_count, |
66 | uint64_t dst_offset, | ||
67 | uint32_t byte_count, | ||
68 | struct reservation_object *resv, | 72 | struct reservation_object *resv, |
69 | struct dma_fence **fence, bool direct_submit); | 73 | struct dma_fence **fence, bool direct_submit, |
74 | bool vm_needs_flush); | ||
70 | int amdgpu_fill_buffer(struct amdgpu_bo *bo, | 75 | int amdgpu_fill_buffer(struct amdgpu_bo *bo, |
71 | uint32_t src_data, | 76 | uint32_t src_data, |
72 | struct reservation_object *resv, | 77 | struct reservation_object *resv, |
@@ -75,5 +80,6 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo, | |||
75 | int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma); | 80 | int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma); |
76 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm); | 81 | bool amdgpu_ttm_is_bound(struct ttm_tt *ttm); |
77 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem); | 82 | int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem); |
83 | int amdgpu_ttm_recover_gart(struct amdgpu_device *adev); | ||
78 | 84 | ||
79 | #endif | 85 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 4f50eeb65855..fcfb9d4f7477 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | |||
@@ -275,14 +275,10 @@ amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type) | |||
275 | else | 275 | else |
276 | return AMDGPU_FW_LOAD_PSP; | 276 | return AMDGPU_FW_LOAD_PSP; |
277 | case CHIP_RAVEN: | 277 | case CHIP_RAVEN: |
278 | #if 0 | 278 | if (load_type != 2) |
279 | if (!load_type) | ||
280 | return AMDGPU_FW_LOAD_DIRECT; | 279 | return AMDGPU_FW_LOAD_DIRECT; |
281 | else | 280 | else |
282 | return AMDGPU_FW_LOAD_PSP; | 281 | return AMDGPU_FW_LOAD_PSP; |
283 | #else | ||
284 | return AMDGPU_FW_LOAD_DIRECT; | ||
285 | #endif | ||
286 | default: | 282 | default: |
287 | DRM_ERROR("Unknow firmware load type\n"); | 283 | DRM_ERROR("Unknow firmware load type\n"); |
288 | } | 284 | } |
@@ -377,6 +373,11 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | |||
377 | struct amdgpu_firmware_info *ucode = NULL; | 373 | struct amdgpu_firmware_info *ucode = NULL; |
378 | const struct common_firmware_header *header = NULL; | 374 | const struct common_firmware_header *header = NULL; |
379 | 375 | ||
376 | if (!adev->firmware.fw_size) { | ||
377 | dev_warn(adev->dev, "No ip firmware need to load\n"); | ||
378 | return 0; | ||
379 | } | ||
380 | |||
380 | err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true, | 381 | err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true, |
381 | amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, | 382 | amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, |
382 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, | 383 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, |
@@ -459,6 +460,9 @@ int amdgpu_ucode_fini_bo(struct amdgpu_device *adev) | |||
459 | int i; | 460 | int i; |
460 | struct amdgpu_firmware_info *ucode = NULL; | 461 | struct amdgpu_firmware_info *ucode = NULL; |
461 | 462 | ||
463 | if (!adev->firmware.fw_size) | ||
464 | return 0; | ||
465 | |||
462 | for (i = 0; i < adev->firmware.max_ucodes; i++) { | 466 | for (i = 0; i < adev->firmware.max_ucodes; i++) { |
463 | ucode = &adev->firmware.ucode[i]; | 467 | ucode = &adev->firmware.ucode[i]; |
464 | if (ucode->fw) { | 468 | if (ucode->fw) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c new file mode 100644 index 000000000000..45ac91861965 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "amdgpu.h" | ||
25 | #include "amdgpu_vf_error.h" | ||
26 | #include "mxgpu_ai.h" | ||
27 | |||
28 | #define AMDGPU_VF_ERROR_ENTRY_SIZE 16 | ||
29 | |||
30 | /* struct error_entry - amdgpu VF error information. */ | ||
31 | struct amdgpu_vf_error_buffer { | ||
32 | int read_count; | ||
33 | int write_count; | ||
34 | uint16_t code[AMDGPU_VF_ERROR_ENTRY_SIZE]; | ||
35 | uint16_t flags[AMDGPU_VF_ERROR_ENTRY_SIZE]; | ||
36 | uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE]; | ||
37 | }; | ||
38 | |||
39 | struct amdgpu_vf_error_buffer admgpu_vf_errors; | ||
40 | |||
41 | |||
42 | void amdgpu_vf_error_put(uint16_t sub_error_code, uint16_t error_flags, uint64_t error_data) | ||
43 | { | ||
44 | int index; | ||
45 | uint16_t error_code = AMDGIM_ERROR_CODE(AMDGIM_ERROR_CATEGORY_VF, sub_error_code); | ||
46 | |||
47 | index = admgpu_vf_errors.write_count % AMDGPU_VF_ERROR_ENTRY_SIZE; | ||
48 | admgpu_vf_errors.code [index] = error_code; | ||
49 | admgpu_vf_errors.flags [index] = error_flags; | ||
50 | admgpu_vf_errors.data [index] = error_data; | ||
51 | admgpu_vf_errors.write_count ++; | ||
52 | } | ||
53 | |||
54 | |||
55 | void amdgpu_vf_error_trans_all(struct amdgpu_device *adev) | ||
56 | { | ||
57 | /* u32 pf2vf_flags = 0; */ | ||
58 | u32 data1, data2, data3; | ||
59 | int index; | ||
60 | |||
61 | if ((NULL == adev) || (!amdgpu_sriov_vf(adev)) || (!adev->virt.ops) || (!adev->virt.ops->trans_msg)) { | ||
62 | return; | ||
63 | } | ||
64 | /* | ||
65 | TODO: Enable these code when pv2vf_info is merged | ||
66 | AMDGPU_FW_VRAM_PF2VF_READ (adev, feature_flags, &pf2vf_flags); | ||
67 | if (!(pf2vf_flags & AMDGIM_FEATURE_ERROR_LOG_COLLECT)) { | ||
68 | return; | ||
69 | } | ||
70 | */ | ||
71 | /* The errors are overlay of array, correct read_count as full. */ | ||
72 | if (admgpu_vf_errors.write_count - admgpu_vf_errors.read_count > AMDGPU_VF_ERROR_ENTRY_SIZE) { | ||
73 | admgpu_vf_errors.read_count = admgpu_vf_errors.write_count - AMDGPU_VF_ERROR_ENTRY_SIZE; | ||
74 | } | ||
75 | |||
76 | while (admgpu_vf_errors.read_count < admgpu_vf_errors.write_count) { | ||
77 | index =admgpu_vf_errors.read_count % AMDGPU_VF_ERROR_ENTRY_SIZE; | ||
78 | data1 = AMDGIM_ERROR_CODE_FLAGS_TO_MAILBOX (admgpu_vf_errors.code[index], admgpu_vf_errors.flags[index]); | ||
79 | data2 = admgpu_vf_errors.data[index] & 0xFFFFFFFF; | ||
80 | data3 = (admgpu_vf_errors.data[index] >> 32) & 0xFFFFFFFF; | ||
81 | |||
82 | adev->virt.ops->trans_msg(adev, IDH_LOG_VF_ERROR, data1, data2, data3); | ||
83 | admgpu_vf_errors.read_count ++; | ||
84 | } | ||
85 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h new file mode 100644 index 000000000000..2a3278ec76ba --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vf_error.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __VF_ERROR_H__ | ||
25 | #define __VF_ERROR_H__ | ||
26 | |||
27 | #define AMDGIM_ERROR_CODE_FLAGS_TO_MAILBOX(c,f) (((c & 0xFFFF) << 16) | (f & 0xFFFF)) | ||
28 | #define AMDGIM_ERROR_CODE(t,c) (((t&0xF)<<12)|(c&0xFFF)) | ||
29 | |||
30 | /* Please keep enum same as AMD GIM driver */ | ||
31 | enum AMDGIM_ERROR_VF { | ||
32 | AMDGIM_ERROR_VF_ATOMBIOS_INIT_FAIL = 0, | ||
33 | AMDGIM_ERROR_VF_NO_VBIOS, | ||
34 | AMDGIM_ERROR_VF_GPU_POST_ERROR, | ||
35 | AMDGIM_ERROR_VF_ATOMBIOS_GET_CLOCK_FAIL, | ||
36 | AMDGIM_ERROR_VF_FENCE_INIT_FAIL, | ||
37 | |||
38 | AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, | ||
39 | AMDGIM_ERROR_VF_IB_INIT_FAIL, | ||
40 | AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, | ||
41 | AMDGIM_ERROR_VF_ASIC_RESUME_FAIL, | ||
42 | AMDGIM_ERROR_VF_GPU_RESET_FAIL, | ||
43 | |||
44 | AMDGIM_ERROR_VF_TEST, | ||
45 | AMDGIM_ERROR_VF_MAX | ||
46 | }; | ||
47 | |||
48 | enum AMDGIM_ERROR_CATEGORY { | ||
49 | AMDGIM_ERROR_CATEGORY_NON_USED = 0, | ||
50 | AMDGIM_ERROR_CATEGORY_GIM, | ||
51 | AMDGIM_ERROR_CATEGORY_PF, | ||
52 | AMDGIM_ERROR_CATEGORY_VF, | ||
53 | AMDGIM_ERROR_CATEGORY_VBIOS, | ||
54 | AMDGIM_ERROR_CATEGORY_MONITOR, | ||
55 | |||
56 | AMDGIM_ERROR_CATEGORY_MAX | ||
57 | }; | ||
58 | |||
59 | void amdgpu_vf_error_put(uint16_t sub_error_code, uint16_t error_flags, uint64_t error_data); | ||
60 | void amdgpu_vf_error_trans_all (struct amdgpu_device *adev); | ||
61 | |||
62 | #endif /* __VF_ERROR_H__ */ | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h index 9e1062edb76e..e5b1baf387c1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | |||
@@ -43,6 +43,7 @@ struct amdgpu_virt_ops { | |||
43 | int (*req_full_gpu)(struct amdgpu_device *adev, bool init); | 43 | int (*req_full_gpu)(struct amdgpu_device *adev, bool init); |
44 | int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); | 44 | int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); |
45 | int (*reset_gpu)(struct amdgpu_device *adev); | 45 | int (*reset_gpu)(struct amdgpu_device *adev); |
46 | void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1, u32 data2, u32 data3); | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | /* GPU virtualization */ | 49 | /* GPU virtualization */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 5795f81369f0..250c8e80e646 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -77,8 +77,6 @@ struct amdgpu_pte_update_params { | |||
77 | void (*func)(struct amdgpu_pte_update_params *params, uint64_t pe, | 77 | void (*func)(struct amdgpu_pte_update_params *params, uint64_t pe, |
78 | uint64_t addr, unsigned count, uint32_t incr, | 78 | uint64_t addr, unsigned count, uint32_t incr, |
79 | uint64_t flags); | 79 | uint64_t flags); |
80 | /* indicate update pt or its shadow */ | ||
81 | bool shadow; | ||
82 | /* The next two are used during VM update by CPU | 80 | /* The next two are used during VM update by CPU |
83 | * DMA addresses to use for mapping | 81 | * DMA addresses to use for mapping |
84 | * Kernel pointer of PD/PT BO that needs to be updated | 82 | * Kernel pointer of PD/PT BO that needs to be updated |
@@ -161,11 +159,17 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, | |||
161 | */ | 159 | */ |
162 | static int amdgpu_vm_validate_level(struct amdgpu_vm_pt *parent, | 160 | static int amdgpu_vm_validate_level(struct amdgpu_vm_pt *parent, |
163 | int (*validate)(void *, struct amdgpu_bo *), | 161 | int (*validate)(void *, struct amdgpu_bo *), |
164 | void *param) | 162 | void *param, bool use_cpu_for_update) |
165 | { | 163 | { |
166 | unsigned i; | 164 | unsigned i; |
167 | int r; | 165 | int r; |
168 | 166 | ||
167 | if (use_cpu_for_update) { | ||
168 | r = amdgpu_bo_kmap(parent->bo, NULL); | ||
169 | if (r) | ||
170 | return r; | ||
171 | } | ||
172 | |||
169 | if (!parent->entries) | 173 | if (!parent->entries) |
170 | return 0; | 174 | return 0; |
171 | 175 | ||
@@ -183,7 +187,8 @@ static int amdgpu_vm_validate_level(struct amdgpu_vm_pt *parent, | |||
183 | * Recurse into the sub directory. This is harmless because we | 187 | * Recurse into the sub directory. This is harmless because we |
184 | * have only a maximum of 5 layers. | 188 | * have only a maximum of 5 layers. |
185 | */ | 189 | */ |
186 | r = amdgpu_vm_validate_level(entry, validate, param); | 190 | r = amdgpu_vm_validate_level(entry, validate, param, |
191 | use_cpu_for_update); | ||
187 | if (r) | 192 | if (r) |
188 | return r; | 193 | return r; |
189 | } | 194 | } |
@@ -214,7 +219,8 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
214 | if (num_evictions == vm->last_eviction_counter) | 219 | if (num_evictions == vm->last_eviction_counter) |
215 | return 0; | 220 | return 0; |
216 | 221 | ||
217 | return amdgpu_vm_validate_level(&vm->root, validate, param); | 222 | return amdgpu_vm_validate_level(&vm->root, validate, param, |
223 | vm->use_cpu_for_update); | ||
218 | } | 224 | } |
219 | 225 | ||
220 | /** | 226 | /** |
@@ -331,6 +337,14 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
331 | if (r) | 337 | if (r) |
332 | return r; | 338 | return r; |
333 | 339 | ||
340 | if (vm->use_cpu_for_update) { | ||
341 | r = amdgpu_bo_kmap(pt, NULL); | ||
342 | if (r) { | ||
343 | amdgpu_bo_unref(&pt); | ||
344 | return r; | ||
345 | } | ||
346 | } | ||
347 | |||
334 | /* Keep a reference to the root directory to avoid | 348 | /* Keep a reference to the root directory to avoid |
335 | * freeing them up in the wrong order. | 349 | * freeing them up in the wrong order. |
336 | */ | 350 | */ |
@@ -338,6 +352,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
338 | 352 | ||
339 | entry->bo = pt; | 353 | entry->bo = pt; |
340 | entry->addr = 0; | 354 | entry->addr = 0; |
355 | entry->huge_page = false; | ||
341 | } | 356 | } |
342 | 357 | ||
343 | if (level < adev->vm_manager.num_level) { | 358 | if (level < adev->vm_manager.num_level) { |
@@ -424,7 +439,7 @@ static int amdgpu_vm_grab_reserved_vmid_locked(struct amdgpu_vm *vm, | |||
424 | struct dma_fence *updates = sync->last_vm_update; | 439 | struct dma_fence *updates = sync->last_vm_update; |
425 | int r = 0; | 440 | int r = 0; |
426 | struct dma_fence *flushed, *tmp; | 441 | struct dma_fence *flushed, *tmp; |
427 | bool needs_flush = false; | 442 | bool needs_flush = vm->use_cpu_for_update; |
428 | 443 | ||
429 | flushed = id->flushed_updates; | 444 | flushed = id->flushed_updates; |
430 | if ((amdgpu_vm_had_gpu_reset(adev, id)) || | 445 | if ((amdgpu_vm_had_gpu_reset(adev, id)) || |
@@ -545,11 +560,11 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, | |||
545 | } | 560 | } |
546 | kfree(fences); | 561 | kfree(fences); |
547 | 562 | ||
548 | job->vm_needs_flush = false; | 563 | job->vm_needs_flush = vm->use_cpu_for_update; |
549 | /* Check if we can use a VMID already assigned to this VM */ | 564 | /* Check if we can use a VMID already assigned to this VM */ |
550 | list_for_each_entry_reverse(id, &id_mgr->ids_lru, list) { | 565 | list_for_each_entry_reverse(id, &id_mgr->ids_lru, list) { |
551 | struct dma_fence *flushed; | 566 | struct dma_fence *flushed; |
552 | bool needs_flush = false; | 567 | bool needs_flush = vm->use_cpu_for_update; |
553 | 568 | ||
554 | /* Check all the prerequisites to using this VMID */ | 569 | /* Check all the prerequisites to using this VMID */ |
555 | if (amdgpu_vm_had_gpu_reset(adev, id)) | 570 | if (amdgpu_vm_had_gpu_reset(adev, id)) |
@@ -745,7 +760,7 @@ static bool amdgpu_vm_is_large_bar(struct amdgpu_device *adev) | |||
745 | * | 760 | * |
746 | * Emit a VM flush when it is necessary. | 761 | * Emit a VM flush when it is necessary. |
747 | */ | 762 | */ |
748 | int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) | 763 | int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_pipe_sync) |
749 | { | 764 | { |
750 | struct amdgpu_device *adev = ring->adev; | 765 | struct amdgpu_device *adev = ring->adev; |
751 | unsigned vmhub = ring->funcs->vmhub; | 766 | unsigned vmhub = ring->funcs->vmhub; |
@@ -767,12 +782,15 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) | |||
767 | vm_flush_needed = true; | 782 | vm_flush_needed = true; |
768 | } | 783 | } |
769 | 784 | ||
770 | if (!vm_flush_needed && !gds_switch_needed) | 785 | if (!vm_flush_needed && !gds_switch_needed && !need_pipe_sync) |
771 | return 0; | 786 | return 0; |
772 | 787 | ||
773 | if (ring->funcs->init_cond_exec) | 788 | if (ring->funcs->init_cond_exec) |
774 | patch_offset = amdgpu_ring_init_cond_exec(ring); | 789 | patch_offset = amdgpu_ring_init_cond_exec(ring); |
775 | 790 | ||
791 | if (need_pipe_sync) | ||
792 | amdgpu_ring_emit_pipeline_sync(ring); | ||
793 | |||
776 | if (ring->funcs->emit_vm_flush && vm_flush_needed) { | 794 | if (ring->funcs->emit_vm_flush && vm_flush_needed) { |
777 | struct dma_fence *fence; | 795 | struct dma_fence *fence; |
778 | 796 | ||
@@ -981,6 +999,8 @@ static void amdgpu_vm_cpu_set_ptes(struct amdgpu_pte_update_params *params, | |||
981 | unsigned int i; | 999 | unsigned int i; |
982 | uint64_t value; | 1000 | uint64_t value; |
983 | 1001 | ||
1002 | trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags); | ||
1003 | |||
984 | for (i = 0; i < count; i++) { | 1004 | for (i = 0; i < count; i++) { |
985 | value = params->pages_addr ? | 1005 | value = params->pages_addr ? |
986 | amdgpu_vm_map_gart(params->pages_addr, addr) : | 1006 | amdgpu_vm_map_gart(params->pages_addr, addr) : |
@@ -989,19 +1009,16 @@ static void amdgpu_vm_cpu_set_ptes(struct amdgpu_pte_update_params *params, | |||
989 | i, value, flags); | 1009 | i, value, flags); |
990 | addr += incr; | 1010 | addr += incr; |
991 | } | 1011 | } |
992 | |||
993 | /* Flush HDP */ | ||
994 | mb(); | ||
995 | amdgpu_gart_flush_gpu_tlb(params->adev, 0); | ||
996 | } | 1012 | } |
997 | 1013 | ||
998 | static int amdgpu_vm_bo_wait(struct amdgpu_device *adev, struct amdgpu_bo *bo) | 1014 | static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, |
1015 | void *owner) | ||
999 | { | 1016 | { |
1000 | struct amdgpu_sync sync; | 1017 | struct amdgpu_sync sync; |
1001 | int r; | 1018 | int r; |
1002 | 1019 | ||
1003 | amdgpu_sync_create(&sync); | 1020 | amdgpu_sync_create(&sync); |
1004 | amdgpu_sync_resv(adev, &sync, bo->tbo.resv, AMDGPU_FENCE_OWNER_VM); | 1021 | amdgpu_sync_resv(adev, &sync, vm->root.bo->tbo.resv, owner); |
1005 | r = amdgpu_sync_wait(&sync, true); | 1022 | r = amdgpu_sync_wait(&sync, true); |
1006 | amdgpu_sync_free(&sync); | 1023 | amdgpu_sync_free(&sync); |
1007 | 1024 | ||
@@ -1042,16 +1059,12 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, | |||
1042 | params.adev = adev; | 1059 | params.adev = adev; |
1043 | shadow = parent->bo->shadow; | 1060 | shadow = parent->bo->shadow; |
1044 | 1061 | ||
1045 | WARN_ON(vm->use_cpu_for_update && shadow); | 1062 | if (vm->use_cpu_for_update) { |
1046 | if (vm->use_cpu_for_update && !shadow) { | 1063 | pd_addr = (unsigned long)parent->bo->kptr; |
1047 | r = amdgpu_bo_kmap(parent->bo, (void **)&pd_addr); | 1064 | r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); |
1048 | if (r) | 1065 | if (unlikely(r)) |
1049 | return r; | ||
1050 | r = amdgpu_vm_bo_wait(adev, parent->bo); | ||
1051 | if (unlikely(r)) { | ||
1052 | amdgpu_bo_kunmap(parent->bo); | ||
1053 | return r; | 1066 | return r; |
1054 | } | 1067 | |
1055 | params.func = amdgpu_vm_cpu_set_ptes; | 1068 | params.func = amdgpu_vm_cpu_set_ptes; |
1056 | } else { | 1069 | } else { |
1057 | if (shadow) { | 1070 | if (shadow) { |
@@ -1105,7 +1118,8 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, | |||
1105 | 1118 | ||
1106 | pt = amdgpu_bo_gpu_offset(bo); | 1119 | pt = amdgpu_bo_gpu_offset(bo); |
1107 | pt = amdgpu_gart_get_vm_pde(adev, pt); | 1120 | pt = amdgpu_gart_get_vm_pde(adev, pt); |
1108 | if (parent->entries[pt_idx].addr == pt) | 1121 | if (parent->entries[pt_idx].addr == pt || |
1122 | parent->entries[pt_idx].huge_page) | ||
1109 | continue; | 1123 | continue; |
1110 | 1124 | ||
1111 | parent->entries[pt_idx].addr = pt; | 1125 | parent->entries[pt_idx].addr = pt; |
@@ -1146,28 +1160,29 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev, | |||
1146 | count, incr, AMDGPU_PTE_VALID); | 1160 | count, incr, AMDGPU_PTE_VALID); |
1147 | } | 1161 | } |
1148 | 1162 | ||
1149 | if (params.func == amdgpu_vm_cpu_set_ptes) | 1163 | if (!vm->use_cpu_for_update) { |
1150 | amdgpu_bo_kunmap(parent->bo); | 1164 | if (params.ib->length_dw == 0) { |
1151 | else if (params.ib->length_dw == 0) { | 1165 | amdgpu_job_free(job); |
1152 | amdgpu_job_free(job); | 1166 | } else { |
1153 | } else { | 1167 | amdgpu_ring_pad_ib(ring, params.ib); |
1154 | amdgpu_ring_pad_ib(ring, params.ib); | 1168 | amdgpu_sync_resv(adev, &job->sync, parent->bo->tbo.resv, |
1155 | amdgpu_sync_resv(adev, &job->sync, parent->bo->tbo.resv, | ||
1156 | AMDGPU_FENCE_OWNER_VM); | ||
1157 | if (shadow) | ||
1158 | amdgpu_sync_resv(adev, &job->sync, shadow->tbo.resv, | ||
1159 | AMDGPU_FENCE_OWNER_VM); | 1169 | AMDGPU_FENCE_OWNER_VM); |
1170 | if (shadow) | ||
1171 | amdgpu_sync_resv(adev, &job->sync, | ||
1172 | shadow->tbo.resv, | ||
1173 | AMDGPU_FENCE_OWNER_VM); | ||
1174 | |||
1175 | WARN_ON(params.ib->length_dw > ndw); | ||
1176 | r = amdgpu_job_submit(job, ring, &vm->entity, | ||
1177 | AMDGPU_FENCE_OWNER_VM, &fence); | ||
1178 | if (r) | ||
1179 | goto error_free; | ||
1160 | 1180 | ||
1161 | WARN_ON(params.ib->length_dw > ndw); | 1181 | amdgpu_bo_fence(parent->bo, fence, true); |
1162 | r = amdgpu_job_submit(job, ring, &vm->entity, | 1182 | dma_fence_put(vm->last_dir_update); |
1163 | AMDGPU_FENCE_OWNER_VM, &fence); | 1183 | vm->last_dir_update = dma_fence_get(fence); |
1164 | if (r) | 1184 | dma_fence_put(fence); |
1165 | goto error_free; | 1185 | } |
1166 | |||
1167 | amdgpu_bo_fence(parent->bo, fence, true); | ||
1168 | dma_fence_put(vm->last_dir_update); | ||
1169 | vm->last_dir_update = dma_fence_get(fence); | ||
1170 | dma_fence_put(fence); | ||
1171 | } | 1186 | } |
1172 | /* | 1187 | /* |
1173 | * Recurse into the subdirectories. This recursion is harmless because | 1188 | * Recurse into the subdirectories. This recursion is harmless because |
@@ -1235,33 +1250,105 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, | |||
1235 | if (r) | 1250 | if (r) |
1236 | amdgpu_vm_invalidate_level(&vm->root); | 1251 | amdgpu_vm_invalidate_level(&vm->root); |
1237 | 1252 | ||
1253 | if (vm->use_cpu_for_update) { | ||
1254 | /* Flush HDP */ | ||
1255 | mb(); | ||
1256 | amdgpu_gart_flush_gpu_tlb(adev, 0); | ||
1257 | } | ||
1258 | |||
1238 | return r; | 1259 | return r; |
1239 | } | 1260 | } |
1240 | 1261 | ||
1241 | /** | 1262 | /** |
1242 | * amdgpu_vm_find_pt - find the page table for an address | 1263 | * amdgpu_vm_find_entry - find the entry for an address |
1243 | * | 1264 | * |
1244 | * @p: see amdgpu_pte_update_params definition | 1265 | * @p: see amdgpu_pte_update_params definition |
1245 | * @addr: virtual address in question | 1266 | * @addr: virtual address in question |
1267 | * @entry: resulting entry or NULL | ||
1268 | * @parent: parent entry | ||
1246 | * | 1269 | * |
1247 | * Find the page table BO for a virtual address, return NULL when none found. | 1270 | * Find the vm_pt entry and it's parent for the given address. |
1248 | */ | 1271 | */ |
1249 | static struct amdgpu_bo *amdgpu_vm_get_pt(struct amdgpu_pte_update_params *p, | 1272 | void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr, |
1250 | uint64_t addr) | 1273 | struct amdgpu_vm_pt **entry, |
1274 | struct amdgpu_vm_pt **parent) | ||
1251 | { | 1275 | { |
1252 | struct amdgpu_vm_pt *entry = &p->vm->root; | ||
1253 | unsigned idx, level = p->adev->vm_manager.num_level; | 1276 | unsigned idx, level = p->adev->vm_manager.num_level; |
1254 | 1277 | ||
1255 | while (entry->entries) { | 1278 | *parent = NULL; |
1279 | *entry = &p->vm->root; | ||
1280 | while ((*entry)->entries) { | ||
1256 | idx = addr >> (p->adev->vm_manager.block_size * level--); | 1281 | idx = addr >> (p->adev->vm_manager.block_size * level--); |
1257 | idx %= amdgpu_bo_size(entry->bo) / 8; | 1282 | idx %= amdgpu_bo_size((*entry)->bo) / 8; |
1258 | entry = &entry->entries[idx]; | 1283 | *parent = *entry; |
1284 | *entry = &(*entry)->entries[idx]; | ||
1259 | } | 1285 | } |
1260 | 1286 | ||
1261 | if (level) | 1287 | if (level) |
1262 | return NULL; | 1288 | *entry = NULL; |
1289 | } | ||
1290 | |||
1291 | /** | ||
1292 | * amdgpu_vm_handle_huge_pages - handle updating the PD with huge pages | ||
1293 | * | ||
1294 | * @p: see amdgpu_pte_update_params definition | ||
1295 | * @entry: vm_pt entry to check | ||
1296 | * @parent: parent entry | ||
1297 | * @nptes: number of PTEs updated with this operation | ||
1298 | * @dst: destination address where the PTEs should point to | ||
1299 | * @flags: access flags fro the PTEs | ||
1300 | * | ||
1301 | * Check if we can update the PD with a huge page. | ||
1302 | */ | ||
1303 | static int amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, | ||
1304 | struct amdgpu_vm_pt *entry, | ||
1305 | struct amdgpu_vm_pt *parent, | ||
1306 | unsigned nptes, uint64_t dst, | ||
1307 | uint64_t flags) | ||
1308 | { | ||
1309 | bool use_cpu_update = (p->func == amdgpu_vm_cpu_set_ptes); | ||
1310 | uint64_t pd_addr, pde; | ||
1311 | int r; | ||
1263 | 1312 | ||
1264 | return entry->bo; | 1313 | /* In the case of a mixed PT the PDE must point to it*/ |
1314 | if (p->adev->asic_type < CHIP_VEGA10 || | ||
1315 | nptes != AMDGPU_VM_PTE_COUNT(p->adev) || | ||
1316 | p->func == amdgpu_vm_do_copy_ptes || | ||
1317 | !(flags & AMDGPU_PTE_VALID)) { | ||
1318 | |||
1319 | dst = amdgpu_bo_gpu_offset(entry->bo); | ||
1320 | dst = amdgpu_gart_get_vm_pde(p->adev, dst); | ||
1321 | flags = AMDGPU_PTE_VALID; | ||
1322 | } else { | ||
1323 | flags |= AMDGPU_PDE_PTE; | ||
1324 | } | ||
1325 | |||
1326 | if (entry->addr == dst && | ||
1327 | entry->huge_page == !!(flags & AMDGPU_PDE_PTE)) | ||
1328 | return 0; | ||
1329 | |||
1330 | entry->addr = dst; | ||
1331 | entry->huge_page = !!(flags & AMDGPU_PDE_PTE); | ||
1332 | |||
1333 | if (use_cpu_update) { | ||
1334 | r = amdgpu_bo_kmap(parent->bo, (void *)&pd_addr); | ||
1335 | if (r) | ||
1336 | return r; | ||
1337 | |||
1338 | pde = pd_addr + (entry - parent->entries) * 8; | ||
1339 | amdgpu_vm_cpu_set_ptes(p, pde, dst, 1, 0, flags); | ||
1340 | } else { | ||
1341 | if (parent->bo->shadow) { | ||
1342 | pd_addr = amdgpu_bo_gpu_offset(parent->bo->shadow); | ||
1343 | pde = pd_addr + (entry - parent->entries) * 8; | ||
1344 | amdgpu_vm_do_set_ptes(p, pde, dst, 1, 0, flags); | ||
1345 | } | ||
1346 | pd_addr = amdgpu_bo_gpu_offset(parent->bo); | ||
1347 | pde = pd_addr + (entry - parent->entries) * 8; | ||
1348 | amdgpu_vm_do_set_ptes(p, pde, dst, 1, 0, flags); | ||
1349 | } | ||
1350 | |||
1351 | return 0; | ||
1265 | } | 1352 | } |
1266 | 1353 | ||
1267 | /** | 1354 | /** |
@@ -1287,49 +1374,47 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, | |||
1287 | uint64_t addr, pe_start; | 1374 | uint64_t addr, pe_start; |
1288 | struct amdgpu_bo *pt; | 1375 | struct amdgpu_bo *pt; |
1289 | unsigned nptes; | 1376 | unsigned nptes; |
1290 | int r; | ||
1291 | bool use_cpu_update = (params->func == amdgpu_vm_cpu_set_ptes); | 1377 | bool use_cpu_update = (params->func == amdgpu_vm_cpu_set_ptes); |
1292 | 1378 | int r; | |
1293 | 1379 | ||
1294 | /* walk over the address space and update the page tables */ | 1380 | /* walk over the address space and update the page tables */ |
1295 | for (addr = start; addr < end; addr += nptes) { | 1381 | for (addr = start; addr < end; addr += nptes, |
1296 | pt = amdgpu_vm_get_pt(params, addr); | 1382 | dst += nptes * AMDGPU_GPU_PAGE_SIZE) { |
1297 | if (!pt) { | 1383 | struct amdgpu_vm_pt *entry, *parent; |
1298 | pr_err("PT not found, aborting update_ptes\n"); | ||
1299 | return -EINVAL; | ||
1300 | } | ||
1301 | 1384 | ||
1302 | if (params->shadow) { | 1385 | amdgpu_vm_get_entry(params, addr, &entry, &parent); |
1303 | if (WARN_ONCE(use_cpu_update, | 1386 | if (!entry) |
1304 | "CPU VM update doesn't suuport shadow pages")) | 1387 | return -ENOENT; |
1305 | return 0; | ||
1306 | |||
1307 | if (!pt->shadow) | ||
1308 | return 0; | ||
1309 | pt = pt->shadow; | ||
1310 | } | ||
1311 | 1388 | ||
1312 | if ((addr & ~mask) == (end & ~mask)) | 1389 | if ((addr & ~mask) == (end & ~mask)) |
1313 | nptes = end - addr; | 1390 | nptes = end - addr; |
1314 | else | 1391 | else |
1315 | nptes = AMDGPU_VM_PTE_COUNT(adev) - (addr & mask); | 1392 | nptes = AMDGPU_VM_PTE_COUNT(adev) - (addr & mask); |
1316 | 1393 | ||
1394 | r = amdgpu_vm_handle_huge_pages(params, entry, parent, | ||
1395 | nptes, dst, flags); | ||
1396 | if (r) | ||
1397 | return r; | ||
1398 | |||
1399 | if (entry->huge_page) | ||
1400 | continue; | ||
1401 | |||
1402 | pt = entry->bo; | ||
1317 | if (use_cpu_update) { | 1403 | if (use_cpu_update) { |
1318 | r = amdgpu_bo_kmap(pt, (void *)&pe_start); | 1404 | pe_start = (unsigned long)pt->kptr; |
1319 | if (r) | 1405 | } else { |
1320 | return r; | 1406 | if (pt->shadow) { |
1321 | } else | 1407 | pe_start = amdgpu_bo_gpu_offset(pt->shadow); |
1408 | pe_start += (addr & mask) * 8; | ||
1409 | params->func(params, pe_start, dst, nptes, | ||
1410 | AMDGPU_GPU_PAGE_SIZE, flags); | ||
1411 | } | ||
1322 | pe_start = amdgpu_bo_gpu_offset(pt); | 1412 | pe_start = amdgpu_bo_gpu_offset(pt); |
1413 | } | ||
1323 | 1414 | ||
1324 | pe_start += (addr & mask) * 8; | 1415 | pe_start += (addr & mask) * 8; |
1325 | |||
1326 | params->func(params, pe_start, dst, nptes, | 1416 | params->func(params, pe_start, dst, nptes, |
1327 | AMDGPU_GPU_PAGE_SIZE, flags); | 1417 | AMDGPU_GPU_PAGE_SIZE, flags); |
1328 | |||
1329 | dst += nptes * AMDGPU_GPU_PAGE_SIZE; | ||
1330 | |||
1331 | if (use_cpu_update) | ||
1332 | amdgpu_bo_kunmap(pt); | ||
1333 | } | 1418 | } |
1334 | 1419 | ||
1335 | return 0; | 1420 | return 0; |
@@ -1372,8 +1457,9 @@ static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params, | |||
1372 | */ | 1457 | */ |
1373 | 1458 | ||
1374 | /* SI and newer are optimized for 64KB */ | 1459 | /* SI and newer are optimized for 64KB */ |
1375 | uint64_t frag_flags = AMDGPU_PTE_FRAG(AMDGPU_LOG2_PAGES_PER_FRAG); | 1460 | unsigned pages_per_frag = AMDGPU_LOG2_PAGES_PER_FRAG(params->adev); |
1376 | uint64_t frag_align = 1 << AMDGPU_LOG2_PAGES_PER_FRAG; | 1461 | uint64_t frag_flags = AMDGPU_PTE_FRAG(pages_per_frag); |
1462 | uint64_t frag_align = 1 << pages_per_frag; | ||
1377 | 1463 | ||
1378 | uint64_t frag_start = ALIGN(start, frag_align); | 1464 | uint64_t frag_start = ALIGN(start, frag_align); |
1379 | uint64_t frag_end = end & ~(frag_align - 1); | 1465 | uint64_t frag_end = end & ~(frag_align - 1); |
@@ -1445,6 +1531,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1445 | params.vm = vm; | 1531 | params.vm = vm; |
1446 | params.src = src; | 1532 | params.src = src; |
1447 | 1533 | ||
1534 | /* sync to everything on unmapping */ | ||
1535 | if (!(flags & AMDGPU_PTE_VALID)) | ||
1536 | owner = AMDGPU_FENCE_OWNER_UNDEFINED; | ||
1537 | |||
1448 | if (vm->use_cpu_for_update) { | 1538 | if (vm->use_cpu_for_update) { |
1449 | /* params.src is used as flag to indicate system Memory */ | 1539 | /* params.src is used as flag to indicate system Memory */ |
1450 | if (pages_addr) | 1540 | if (pages_addr) |
@@ -1453,23 +1543,18 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1453 | /* Wait for PT BOs to be free. PTs share the same resv. object | 1543 | /* Wait for PT BOs to be free. PTs share the same resv. object |
1454 | * as the root PD BO | 1544 | * as the root PD BO |
1455 | */ | 1545 | */ |
1456 | r = amdgpu_vm_bo_wait(adev, vm->root.bo); | 1546 | r = amdgpu_vm_wait_pd(adev, vm, owner); |
1457 | if (unlikely(r)) | 1547 | if (unlikely(r)) |
1458 | return r; | 1548 | return r; |
1459 | 1549 | ||
1460 | params.func = amdgpu_vm_cpu_set_ptes; | 1550 | params.func = amdgpu_vm_cpu_set_ptes; |
1461 | params.pages_addr = pages_addr; | 1551 | params.pages_addr = pages_addr; |
1462 | params.shadow = false; | ||
1463 | return amdgpu_vm_frag_ptes(¶ms, start, last + 1, | 1552 | return amdgpu_vm_frag_ptes(¶ms, start, last + 1, |
1464 | addr, flags); | 1553 | addr, flags); |
1465 | } | 1554 | } |
1466 | 1555 | ||
1467 | ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); | 1556 | ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); |
1468 | 1557 | ||
1469 | /* sync to everything on unmapping */ | ||
1470 | if (!(flags & AMDGPU_PTE_VALID)) | ||
1471 | owner = AMDGPU_FENCE_OWNER_UNDEFINED; | ||
1472 | |||
1473 | nptes = last - start + 1; | 1558 | nptes = last - start + 1; |
1474 | 1559 | ||
1475 | /* | 1560 | /* |
@@ -1481,6 +1566,9 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1481 | /* padding, etc. */ | 1566 | /* padding, etc. */ |
1482 | ndw = 64; | 1567 | ndw = 64; |
1483 | 1568 | ||
1569 | /* one PDE write for each huge page */ | ||
1570 | ndw += ((nptes >> adev->vm_manager.block_size) + 1) * 6; | ||
1571 | |||
1484 | if (src) { | 1572 | if (src) { |
1485 | /* only copy commands needed */ | 1573 | /* only copy commands needed */ |
1486 | ndw += ncmds * 7; | 1574 | ndw += ncmds * 7; |
@@ -1542,11 +1630,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1542 | if (r) | 1630 | if (r) |
1543 | goto error_free; | 1631 | goto error_free; |
1544 | 1632 | ||
1545 | params.shadow = true; | ||
1546 | r = amdgpu_vm_frag_ptes(¶ms, start, last + 1, addr, flags); | ||
1547 | if (r) | ||
1548 | goto error_free; | ||
1549 | params.shadow = false; | ||
1550 | r = amdgpu_vm_frag_ptes(¶ms, start, last + 1, addr, flags); | 1633 | r = amdgpu_vm_frag_ptes(¶ms, start, last + 1, addr, flags); |
1551 | if (r) | 1634 | if (r) |
1552 | goto error_free; | 1635 | goto error_free; |
@@ -1565,6 +1648,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1565 | 1648 | ||
1566 | error_free: | 1649 | error_free: |
1567 | amdgpu_job_free(job); | 1650 | amdgpu_job_free(job); |
1651 | amdgpu_vm_invalidate_level(&vm->root); | ||
1568 | return r; | 1652 | return r; |
1569 | } | 1653 | } |
1570 | 1654 | ||
@@ -1752,6 +1836,12 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, | |||
1752 | list_add(&bo_va->vm_status, &vm->cleared); | 1836 | list_add(&bo_va->vm_status, &vm->cleared); |
1753 | spin_unlock(&vm->status_lock); | 1837 | spin_unlock(&vm->status_lock); |
1754 | 1838 | ||
1839 | if (vm->use_cpu_for_update) { | ||
1840 | /* Flush HDP */ | ||
1841 | mb(); | ||
1842 | amdgpu_gart_flush_gpu_tlb(adev, 0); | ||
1843 | } | ||
1844 | |||
1755 | return 0; | 1845 | return 0; |
1756 | } | 1846 | } |
1757 | 1847 | ||
@@ -2457,6 +2547,13 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2457 | goto error_free_root; | 2547 | goto error_free_root; |
2458 | 2548 | ||
2459 | vm->last_eviction_counter = atomic64_read(&adev->num_evictions); | 2549 | vm->last_eviction_counter = atomic64_read(&adev->num_evictions); |
2550 | |||
2551 | if (vm->use_cpu_for_update) { | ||
2552 | r = amdgpu_bo_kmap(vm->root.bo, NULL); | ||
2553 | if (r) | ||
2554 | goto error_free_root; | ||
2555 | } | ||
2556 | |||
2460 | amdgpu_bo_unreserve(vm->root.bo); | 2557 | amdgpu_bo_unreserve(vm->root.bo); |
2461 | 2558 | ||
2462 | return 0; | 2559 | return 0; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 936f158bc5ec..34d9174ebff2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -51,7 +51,9 @@ struct amdgpu_bo_list_entry; | |||
51 | #define AMDGPU_VM_PTB_ALIGN_SIZE 32768 | 51 | #define AMDGPU_VM_PTB_ALIGN_SIZE 32768 |
52 | 52 | ||
53 | /* LOG2 number of continuous pages for the fragment field */ | 53 | /* LOG2 number of continuous pages for the fragment field */ |
54 | #define AMDGPU_LOG2_PAGES_PER_FRAG 4 | 54 | #define AMDGPU_LOG2_PAGES_PER_FRAG(adev) \ |
55 | ((adev)->asic_type < CHIP_VEGA10 ? 4 : \ | ||
56 | (adev)->vm_manager.block_size) | ||
55 | 57 | ||
56 | #define AMDGPU_PTE_VALID (1ULL << 0) | 58 | #define AMDGPU_PTE_VALID (1ULL << 0) |
57 | #define AMDGPU_PTE_SYSTEM (1ULL << 1) | 59 | #define AMDGPU_PTE_SYSTEM (1ULL << 1) |
@@ -68,6 +70,9 @@ struct amdgpu_bo_list_entry; | |||
68 | /* TILED for VEGA10, reserved for older ASICs */ | 70 | /* TILED for VEGA10, reserved for older ASICs */ |
69 | #define AMDGPU_PTE_PRT (1ULL << 51) | 71 | #define AMDGPU_PTE_PRT (1ULL << 51) |
70 | 72 | ||
73 | /* PDE is handled as PTE for VEGA10 */ | ||
74 | #define AMDGPU_PDE_PTE (1ULL << 54) | ||
75 | |||
71 | /* VEGA10 only */ | 76 | /* VEGA10 only */ |
72 | #define AMDGPU_PTE_MTYPE(a) ((uint64_t)a << 57) | 77 | #define AMDGPU_PTE_MTYPE(a) ((uint64_t)a << 57) |
73 | #define AMDGPU_PTE_MTYPE_MASK AMDGPU_PTE_MTYPE(3ULL) | 78 | #define AMDGPU_PTE_MTYPE_MASK AMDGPU_PTE_MTYPE(3ULL) |
@@ -98,6 +103,7 @@ struct amdgpu_bo_list_entry; | |||
98 | struct amdgpu_vm_pt { | 103 | struct amdgpu_vm_pt { |
99 | struct amdgpu_bo *bo; | 104 | struct amdgpu_bo *bo; |
100 | uint64_t addr; | 105 | uint64_t addr; |
106 | bool huge_page; | ||
101 | 107 | ||
102 | /* array of page tables, one for each directory entry */ | 108 | /* array of page tables, one for each directory entry */ |
103 | struct amdgpu_vm_pt *entries; | 109 | struct amdgpu_vm_pt *entries; |
@@ -222,7 +228,7 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, | |||
222 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, | 228 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, |
223 | struct amdgpu_sync *sync, struct dma_fence *fence, | 229 | struct amdgpu_sync *sync, struct dma_fence *fence, |
224 | struct amdgpu_job *job); | 230 | struct amdgpu_job *job); |
225 | int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job); | 231 | int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, bool need_pipe_sync); |
226 | void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vmhub, | 232 | void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vmhub, |
227 | unsigned vmid); | 233 | unsigned vmid); |
228 | void amdgpu_vm_reset_all_ids(struct amdgpu_device *adev); | 234 | void amdgpu_vm_reset_all_ids(struct amdgpu_device *adev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index 37a499ab30eb..567c4a5cf90c 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -1824,21 +1824,14 @@ static int cik_common_suspend(void *handle) | |||
1824 | { | 1824 | { |
1825 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1825 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1826 | 1826 | ||
1827 | amdgpu_amdkfd_suspend(adev); | ||
1828 | |||
1829 | return cik_common_hw_fini(adev); | 1827 | return cik_common_hw_fini(adev); |
1830 | } | 1828 | } |
1831 | 1829 | ||
1832 | static int cik_common_resume(void *handle) | 1830 | static int cik_common_resume(void *handle) |
1833 | { | 1831 | { |
1834 | int r; | ||
1835 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1832 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1836 | 1833 | ||
1837 | r = cik_common_hw_init(adev); | 1834 | return cik_common_hw_init(adev); |
1838 | if (r) | ||
1839 | return r; | ||
1840 | |||
1841 | return amdgpu_amdkfd_resume(adev); | ||
1842 | } | 1835 | } |
1843 | 1836 | ||
1844 | static bool cik_common_is_idle(void *handle) | 1837 | static bool cik_common_is_idle(void *handle) |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index c216e16826c9..f508f4d01e4a 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
@@ -342,6 +342,63 @@ static void cik_sdma_rlc_stop(struct amdgpu_device *adev) | |||
342 | } | 342 | } |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * cik_ctx_switch_enable - stop the async dma engines context switch | ||
346 | * | ||
347 | * @adev: amdgpu_device pointer | ||
348 | * @enable: enable/disable the DMA MEs context switch. | ||
349 | * | ||
350 | * Halt or unhalt the async dma engines context switch (VI). | ||
351 | */ | ||
352 | static void cik_ctx_switch_enable(struct amdgpu_device *adev, bool enable) | ||
353 | { | ||
354 | u32 f32_cntl, phase_quantum = 0; | ||
355 | int i; | ||
356 | |||
357 | if (amdgpu_sdma_phase_quantum) { | ||
358 | unsigned value = amdgpu_sdma_phase_quantum; | ||
359 | unsigned unit = 0; | ||
360 | |||
361 | while (value > (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
362 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT)) { | ||
363 | value = (value + 1) >> 1; | ||
364 | unit++; | ||
365 | } | ||
366 | if (unit > (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
367 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT)) { | ||
368 | value = (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
369 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT); | ||
370 | unit = (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
371 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT); | ||
372 | WARN_ONCE(1, | ||
373 | "clamping sdma_phase_quantum to %uK clock cycles\n", | ||
374 | value << unit); | ||
375 | } | ||
376 | phase_quantum = | ||
377 | value << SDMA0_PHASE0_QUANTUM__VALUE__SHIFT | | ||
378 | unit << SDMA0_PHASE0_QUANTUM__UNIT__SHIFT; | ||
379 | } | ||
380 | |||
381 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
382 | f32_cntl = RREG32(mmSDMA0_CNTL + sdma_offsets[i]); | ||
383 | if (enable) { | ||
384 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | ||
385 | AUTO_CTXSW_ENABLE, 1); | ||
386 | if (amdgpu_sdma_phase_quantum) { | ||
387 | WREG32(mmSDMA0_PHASE0_QUANTUM + sdma_offsets[i], | ||
388 | phase_quantum); | ||
389 | WREG32(mmSDMA0_PHASE1_QUANTUM + sdma_offsets[i], | ||
390 | phase_quantum); | ||
391 | } | ||
392 | } else { | ||
393 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | ||
394 | AUTO_CTXSW_ENABLE, 0); | ||
395 | } | ||
396 | |||
397 | WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl); | ||
398 | } | ||
399 | } | ||
400 | |||
401 | /** | ||
345 | * cik_sdma_enable - stop the async dma engines | 402 | * cik_sdma_enable - stop the async dma engines |
346 | * | 403 | * |
347 | * @adev: amdgpu_device pointer | 404 | * @adev: amdgpu_device pointer |
@@ -537,6 +594,8 @@ static int cik_sdma_start(struct amdgpu_device *adev) | |||
537 | 594 | ||
538 | /* halt the engine before programing */ | 595 | /* halt the engine before programing */ |
539 | cik_sdma_enable(adev, false); | 596 | cik_sdma_enable(adev, false); |
597 | /* enable sdma ring preemption */ | ||
598 | cik_ctx_switch_enable(adev, true); | ||
540 | 599 | ||
541 | /* start the gfx rings and rlc compute queues */ | 600 | /* start the gfx rings and rlc compute queues */ |
542 | r = cik_sdma_gfx_resume(adev); | 601 | r = cik_sdma_gfx_resume(adev); |
@@ -984,6 +1043,7 @@ static int cik_sdma_hw_fini(void *handle) | |||
984 | { | 1043 | { |
985 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1044 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
986 | 1045 | ||
1046 | cik_ctx_switch_enable(adev, false); | ||
987 | cik_sdma_enable(adev, false); | 1047 | cik_sdma_enable(adev, false); |
988 | 1048 | ||
989 | return 0; | 1049 | return 0; |
diff --git a/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h b/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h index 18fd01f3e4b2..003a131bad47 100644 --- a/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h +++ b/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h | |||
@@ -1,24 +1,25 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | *************************************************************************************************** | 2 | * Copyright 2017 Advanced Micro Devices, Inc. |
4 | * | 3 | * |
5 | * Trade secret of Advanced Micro Devices, Inc. | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * Copyright (c) 2010 Advanced Micro Devices, Inc. (unpublished) | 5 | * copy of this software and associated documentation files (the "Software"), |
7 | * | 6 | * to deal in the Software without restriction, including without limitation |
8 | * All rights reserved. This notice is intended as a precaution against inadvertent publication and | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | * does not imply publication or any waiver of confidentiality. The year included in the foregoing | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
10 | * notice is the year of creation of the work. | 9 | * Software is furnished to do so, subject to the following conditions: |
11 | * | 10 | * |
12 | *************************************************************************************************** | 11 | * The above copyright notice and this permission notice shall be included in |
13 | */ | 12 | * all copies or substantial portions of the Software. |
14 | /** | 13 | * |
15 | *************************************************************************************************** | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | * @brief gfx9 Clearstate Definitions | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | *************************************************************************************************** | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | * | 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
19 | * Do not edit! This is a machine-generated file! | 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
20 | * | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
21 | */ | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | ||
22 | */ | ||
22 | 23 | ||
23 | static const unsigned int gfx9_SECT_CONTEXT_def_1[] = | 24 | static const unsigned int gfx9_SECT_CONTEXT_def_1[] = |
24 | { | 25 | { |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index aff1f48c947e..4b6e2f7bfec9 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | |||
@@ -484,134 +484,6 @@ static bool dce_v10_0_is_display_hung(struct amdgpu_device *adev) | |||
484 | return true; | 484 | return true; |
485 | } | 485 | } |
486 | 486 | ||
487 | static void dce_v10_0_stop_mc_access(struct amdgpu_device *adev, | ||
488 | struct amdgpu_mode_mc_save *save) | ||
489 | { | ||
490 | u32 crtc_enabled, tmp; | ||
491 | int i; | ||
492 | |||
493 | save->vga_render_control = RREG32(mmVGA_RENDER_CONTROL); | ||
494 | save->vga_hdp_control = RREG32(mmVGA_HDP_CONTROL); | ||
495 | |||
496 | /* disable VGA render */ | ||
497 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
498 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
499 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
500 | |||
501 | /* blank the display controllers */ | ||
502 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
503 | crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]), | ||
504 | CRTC_CONTROL, CRTC_MASTER_EN); | ||
505 | if (crtc_enabled) { | ||
506 | #if 0 | ||
507 | u32 frame_count; | ||
508 | int j; | ||
509 | |||
510 | save->crtc_enabled[i] = true; | ||
511 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
512 | if (REG_GET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN) == 0) { | ||
513 | amdgpu_display_vblank_wait(adev, i); | ||
514 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
515 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 1); | ||
516 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
517 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
518 | } | ||
519 | /* wait for the next frame */ | ||
520 | frame_count = amdgpu_display_vblank_get_counter(adev, i); | ||
521 | for (j = 0; j < adev->usec_timeout; j++) { | ||
522 | if (amdgpu_display_vblank_get_counter(adev, i) != frame_count) | ||
523 | break; | ||
524 | udelay(1); | ||
525 | } | ||
526 | tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]); | ||
527 | if (REG_GET_FIELD(tmp, GRPH_UPDATE, GRPH_UPDATE_LOCK) == 0) { | ||
528 | tmp = REG_SET_FIELD(tmp, GRPH_UPDATE, GRPH_UPDATE_LOCK, 1); | ||
529 | WREG32(mmGRPH_UPDATE + crtc_offsets[i], tmp); | ||
530 | } | ||
531 | tmp = RREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i]); | ||
532 | if (REG_GET_FIELD(tmp, MASTER_UPDATE_LOCK, MASTER_UPDATE_LOCK) == 0) { | ||
533 | tmp = REG_SET_FIELD(tmp, MASTER_UPDATE_LOCK, MASTER_UPDATE_LOCK, 1); | ||
534 | WREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i], tmp); | ||
535 | } | ||
536 | #else | ||
537 | /* XXX this is a hack to avoid strange behavior with EFI on certain systems */ | ||
538 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
539 | tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]); | ||
540 | tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0); | ||
541 | WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp); | ||
542 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
543 | save->crtc_enabled[i] = false; | ||
544 | /* ***** */ | ||
545 | #endif | ||
546 | } else { | ||
547 | save->crtc_enabled[i] = false; | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | |||
552 | static void dce_v10_0_resume_mc_access(struct amdgpu_device *adev, | ||
553 | struct amdgpu_mode_mc_save *save) | ||
554 | { | ||
555 | u32 tmp, frame_count; | ||
556 | int i, j; | ||
557 | |||
558 | /* update crtc base addresses */ | ||
559 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
560 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
561 | upper_32_bits(adev->mc.vram_start)); | ||
562 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
563 | upper_32_bits(adev->mc.vram_start)); | ||
564 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
565 | (u32)adev->mc.vram_start); | ||
566 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
567 | (u32)adev->mc.vram_start); | ||
568 | |||
569 | if (save->crtc_enabled[i]) { | ||
570 | tmp = RREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i]); | ||
571 | if (REG_GET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE) != 0) { | ||
572 | tmp = REG_SET_FIELD(tmp, MASTER_UPDATE_MODE, MASTER_UPDATE_MODE, 0); | ||
573 | WREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i], tmp); | ||
574 | } | ||
575 | tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]); | ||
576 | if (REG_GET_FIELD(tmp, GRPH_UPDATE, GRPH_UPDATE_LOCK)) { | ||
577 | tmp = REG_SET_FIELD(tmp, GRPH_UPDATE, GRPH_UPDATE_LOCK, 0); | ||
578 | WREG32(mmGRPH_UPDATE + crtc_offsets[i], tmp); | ||
579 | } | ||
580 | tmp = RREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i]); | ||
581 | if (REG_GET_FIELD(tmp, MASTER_UPDATE_LOCK, MASTER_UPDATE_LOCK)) { | ||
582 | tmp = REG_SET_FIELD(tmp, MASTER_UPDATE_LOCK, MASTER_UPDATE_LOCK, 0); | ||
583 | WREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i], tmp); | ||
584 | } | ||
585 | for (j = 0; j < adev->usec_timeout; j++) { | ||
586 | tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]); | ||
587 | if (REG_GET_FIELD(tmp, GRPH_UPDATE, GRPH_SURFACE_UPDATE_PENDING) == 0) | ||
588 | break; | ||
589 | udelay(1); | ||
590 | } | ||
591 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
592 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 0); | ||
593 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
594 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
595 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
596 | /* wait for the next frame */ | ||
597 | frame_count = amdgpu_display_vblank_get_counter(adev, i); | ||
598 | for (j = 0; j < adev->usec_timeout; j++) { | ||
599 | if (amdgpu_display_vblank_get_counter(adev, i) != frame_count) | ||
600 | break; | ||
601 | udelay(1); | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | WREG32(mmVGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(adev->mc.vram_start)); | ||
607 | WREG32(mmVGA_MEMORY_BASE_ADDRESS, lower_32_bits(adev->mc.vram_start)); | ||
608 | |||
609 | /* Unlock vga access */ | ||
610 | WREG32(mmVGA_HDP_CONTROL, save->vga_hdp_control); | ||
611 | mdelay(1); | ||
612 | WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control); | ||
613 | } | ||
614 | |||
615 | static void dce_v10_0_set_vga_render_state(struct amdgpu_device *adev, | 487 | static void dce_v10_0_set_vga_render_state(struct amdgpu_device *adev, |
616 | bool render) | 488 | bool render) |
617 | { | 489 | { |
@@ -3025,6 +2897,8 @@ static int dce_v10_0_hw_init(void *handle) | |||
3025 | 2897 | ||
3026 | dce_v10_0_init_golden_registers(adev); | 2898 | dce_v10_0_init_golden_registers(adev); |
3027 | 2899 | ||
2900 | /* disable vga render */ | ||
2901 | dce_v10_0_set_vga_render_state(adev, false); | ||
3028 | /* init dig PHYs, disp eng pll */ | 2902 | /* init dig PHYs, disp eng pll */ |
3029 | amdgpu_atombios_encoder_init_dig(adev); | 2903 | amdgpu_atombios_encoder_init_dig(adev); |
3030 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); | 2904 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); |
@@ -3737,7 +3611,6 @@ static void dce_v10_0_encoder_add(struct amdgpu_device *adev, | |||
3737 | } | 3611 | } |
3738 | 3612 | ||
3739 | static const struct amdgpu_display_funcs dce_v10_0_display_funcs = { | 3613 | static const struct amdgpu_display_funcs dce_v10_0_display_funcs = { |
3740 | .set_vga_render_state = &dce_v10_0_set_vga_render_state, | ||
3741 | .bandwidth_update = &dce_v10_0_bandwidth_update, | 3614 | .bandwidth_update = &dce_v10_0_bandwidth_update, |
3742 | .vblank_get_counter = &dce_v10_0_vblank_get_counter, | 3615 | .vblank_get_counter = &dce_v10_0_vblank_get_counter, |
3743 | .vblank_wait = &dce_v10_0_vblank_wait, | 3616 | .vblank_wait = &dce_v10_0_vblank_wait, |
@@ -3750,8 +3623,6 @@ static const struct amdgpu_display_funcs dce_v10_0_display_funcs = { | |||
3750 | .page_flip_get_scanoutpos = &dce_v10_0_crtc_get_scanoutpos, | 3623 | .page_flip_get_scanoutpos = &dce_v10_0_crtc_get_scanoutpos, |
3751 | .add_encoder = &dce_v10_0_encoder_add, | 3624 | .add_encoder = &dce_v10_0_encoder_add, |
3752 | .add_connector = &amdgpu_connector_add, | 3625 | .add_connector = &amdgpu_connector_add, |
3753 | .stop_mc_access = &dce_v10_0_stop_mc_access, | ||
3754 | .resume_mc_access = &dce_v10_0_resume_mc_access, | ||
3755 | }; | 3626 | }; |
3756 | 3627 | ||
3757 | static void dce_v10_0_set_display_funcs(struct amdgpu_device *adev) | 3628 | static void dce_v10_0_set_display_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 2df650dfa727..6af489872ffd 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | |||
@@ -499,79 +499,6 @@ static bool dce_v11_0_is_display_hung(struct amdgpu_device *adev) | |||
499 | return true; | 499 | return true; |
500 | } | 500 | } |
501 | 501 | ||
502 | static void dce_v11_0_stop_mc_access(struct amdgpu_device *adev, | ||
503 | struct amdgpu_mode_mc_save *save) | ||
504 | { | ||
505 | u32 crtc_enabled, tmp; | ||
506 | int i; | ||
507 | |||
508 | save->vga_render_control = RREG32(mmVGA_RENDER_CONTROL); | ||
509 | save->vga_hdp_control = RREG32(mmVGA_HDP_CONTROL); | ||
510 | |||
511 | /* disable VGA render */ | ||
512 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
513 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
514 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
515 | |||
516 | /* blank the display controllers */ | ||
517 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
518 | crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]), | ||
519 | CRTC_CONTROL, CRTC_MASTER_EN); | ||
520 | if (crtc_enabled) { | ||
521 | #if 1 | ||
522 | save->crtc_enabled[i] = true; | ||
523 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
524 | if (REG_GET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN) == 0) { | ||
525 | /*it is correct only for RGB ; black is 0*/ | ||
526 | WREG32(mmCRTC_BLANK_DATA_COLOR + crtc_offsets[i], 0); | ||
527 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 1); | ||
528 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
529 | } | ||
530 | #else | ||
531 | /* XXX this is a hack to avoid strange behavior with EFI on certain systems */ | ||
532 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
533 | tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]); | ||
534 | tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0); | ||
535 | WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp); | ||
536 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
537 | save->crtc_enabled[i] = false; | ||
538 | /* ***** */ | ||
539 | #endif | ||
540 | } else { | ||
541 | save->crtc_enabled[i] = false; | ||
542 | } | ||
543 | } | ||
544 | } | ||
545 | |||
546 | static void dce_v11_0_resume_mc_access(struct amdgpu_device *adev, | ||
547 | struct amdgpu_mode_mc_save *save) | ||
548 | { | ||
549 | u32 tmp; | ||
550 | int i; | ||
551 | |||
552 | /* update crtc base addresses */ | ||
553 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
554 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
555 | upper_32_bits(adev->mc.vram_start)); | ||
556 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
557 | (u32)adev->mc.vram_start); | ||
558 | |||
559 | if (save->crtc_enabled[i]) { | ||
560 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
561 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 0); | ||
562 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
563 | } | ||
564 | } | ||
565 | |||
566 | WREG32(mmVGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(adev->mc.vram_start)); | ||
567 | WREG32(mmVGA_MEMORY_BASE_ADDRESS, lower_32_bits(adev->mc.vram_start)); | ||
568 | |||
569 | /* Unlock vga access */ | ||
570 | WREG32(mmVGA_HDP_CONTROL, save->vga_hdp_control); | ||
571 | mdelay(1); | ||
572 | WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control); | ||
573 | } | ||
574 | |||
575 | static void dce_v11_0_set_vga_render_state(struct amdgpu_device *adev, | 502 | static void dce_v11_0_set_vga_render_state(struct amdgpu_device *adev, |
576 | bool render) | 503 | bool render) |
577 | { | 504 | { |
@@ -3086,6 +3013,8 @@ static int dce_v11_0_hw_init(void *handle) | |||
3086 | 3013 | ||
3087 | dce_v11_0_init_golden_registers(adev); | 3014 | dce_v11_0_init_golden_registers(adev); |
3088 | 3015 | ||
3016 | /* disable vga render */ | ||
3017 | dce_v11_0_set_vga_render_state(adev, false); | ||
3089 | /* init dig PHYs, disp eng pll */ | 3018 | /* init dig PHYs, disp eng pll */ |
3090 | amdgpu_atombios_crtc_powergate_init(adev); | 3019 | amdgpu_atombios_crtc_powergate_init(adev); |
3091 | amdgpu_atombios_encoder_init_dig(adev); | 3020 | amdgpu_atombios_encoder_init_dig(adev); |
@@ -3806,7 +3735,6 @@ static void dce_v11_0_encoder_add(struct amdgpu_device *adev, | |||
3806 | } | 3735 | } |
3807 | 3736 | ||
3808 | static const struct amdgpu_display_funcs dce_v11_0_display_funcs = { | 3737 | static const struct amdgpu_display_funcs dce_v11_0_display_funcs = { |
3809 | .set_vga_render_state = &dce_v11_0_set_vga_render_state, | ||
3810 | .bandwidth_update = &dce_v11_0_bandwidth_update, | 3738 | .bandwidth_update = &dce_v11_0_bandwidth_update, |
3811 | .vblank_get_counter = &dce_v11_0_vblank_get_counter, | 3739 | .vblank_get_counter = &dce_v11_0_vblank_get_counter, |
3812 | .vblank_wait = &dce_v11_0_vblank_wait, | 3740 | .vblank_wait = &dce_v11_0_vblank_wait, |
@@ -3819,8 +3747,6 @@ static const struct amdgpu_display_funcs dce_v11_0_display_funcs = { | |||
3819 | .page_flip_get_scanoutpos = &dce_v11_0_crtc_get_scanoutpos, | 3747 | .page_flip_get_scanoutpos = &dce_v11_0_crtc_get_scanoutpos, |
3820 | .add_encoder = &dce_v11_0_encoder_add, | 3748 | .add_encoder = &dce_v11_0_encoder_add, |
3821 | .add_connector = &amdgpu_connector_add, | 3749 | .add_connector = &amdgpu_connector_add, |
3822 | .stop_mc_access = &dce_v11_0_stop_mc_access, | ||
3823 | .resume_mc_access = &dce_v11_0_resume_mc_access, | ||
3824 | }; | 3750 | }; |
3825 | 3751 | ||
3826 | static void dce_v11_0_set_display_funcs(struct amdgpu_device *adev) | 3752 | static void dce_v11_0_set_display_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index 0c3891fa62f1..126c5e4e7733 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | |||
@@ -392,117 +392,6 @@ static u32 dce_v6_0_hpd_get_gpio_reg(struct amdgpu_device *adev) | |||
392 | return mmDC_GPIO_HPD_A; | 392 | return mmDC_GPIO_HPD_A; |
393 | } | 393 | } |
394 | 394 | ||
395 | static u32 evergreen_get_vblank_counter(struct amdgpu_device* adev, int crtc) | ||
396 | { | ||
397 | if (crtc >= adev->mode_info.num_crtc) | ||
398 | return 0; | ||
399 | else | ||
400 | return RREG32(mmCRTC_STATUS_FRAME_COUNT + crtc_offsets[crtc]); | ||
401 | } | ||
402 | |||
403 | static void dce_v6_0_stop_mc_access(struct amdgpu_device *adev, | ||
404 | struct amdgpu_mode_mc_save *save) | ||
405 | { | ||
406 | u32 crtc_enabled, tmp, frame_count; | ||
407 | int i, j; | ||
408 | |||
409 | save->vga_render_control = RREG32(mmVGA_RENDER_CONTROL); | ||
410 | save->vga_hdp_control = RREG32(mmVGA_HDP_CONTROL); | ||
411 | |||
412 | /* disable VGA render */ | ||
413 | WREG32(mmVGA_RENDER_CONTROL, 0); | ||
414 | |||
415 | /* blank the display controllers */ | ||
416 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
417 | crtc_enabled = RREG32(mmCRTC_CONTROL + crtc_offsets[i]) & CRTC_CONTROL__CRTC_MASTER_EN_MASK; | ||
418 | if (crtc_enabled) { | ||
419 | save->crtc_enabled[i] = true; | ||
420 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
421 | |||
422 | if (!(tmp & CRTC_BLANK_CONTROL__CRTC_BLANK_DATA_EN_MASK)) { | ||
423 | dce_v6_0_vblank_wait(adev, i); | ||
424 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
425 | tmp |= CRTC_BLANK_CONTROL__CRTC_BLANK_DATA_EN_MASK; | ||
426 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
427 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
428 | } | ||
429 | /* wait for the next frame */ | ||
430 | frame_count = evergreen_get_vblank_counter(adev, i); | ||
431 | for (j = 0; j < adev->usec_timeout; j++) { | ||
432 | if (evergreen_get_vblank_counter(adev, i) != frame_count) | ||
433 | break; | ||
434 | udelay(1); | ||
435 | } | ||
436 | |||
437 | /* XXX this is a hack to avoid strange behavior with EFI on certain systems */ | ||
438 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
439 | tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]); | ||
440 | tmp &= ~CRTC_CONTROL__CRTC_MASTER_EN_MASK; | ||
441 | WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp); | ||
442 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
443 | save->crtc_enabled[i] = false; | ||
444 | /* ***** */ | ||
445 | } else { | ||
446 | save->crtc_enabled[i] = false; | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
451 | static void dce_v6_0_resume_mc_access(struct amdgpu_device *adev, | ||
452 | struct amdgpu_mode_mc_save *save) | ||
453 | { | ||
454 | u32 tmp; | ||
455 | int i, j; | ||
456 | |||
457 | /* update crtc base addresses */ | ||
458 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
459 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
460 | upper_32_bits(adev->mc.vram_start)); | ||
461 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
462 | upper_32_bits(adev->mc.vram_start)); | ||
463 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
464 | (u32)adev->mc.vram_start); | ||
465 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
466 | (u32)adev->mc.vram_start); | ||
467 | } | ||
468 | |||
469 | WREG32(mmVGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(adev->mc.vram_start)); | ||
470 | WREG32(mmVGA_MEMORY_BASE_ADDRESS, (u32)adev->mc.vram_start); | ||
471 | |||
472 | /* unlock regs and wait for update */ | ||
473 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
474 | if (save->crtc_enabled[i]) { | ||
475 | tmp = RREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i]); | ||
476 | if ((tmp & 0x7) != 0) { | ||
477 | tmp &= ~0x7; | ||
478 | WREG32(mmMASTER_UPDATE_MODE + crtc_offsets[i], tmp); | ||
479 | } | ||
480 | tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]); | ||
481 | if (tmp & GRPH_UPDATE__GRPH_UPDATE_LOCK_MASK) { | ||
482 | tmp &= ~GRPH_UPDATE__GRPH_UPDATE_LOCK_MASK; | ||
483 | WREG32(mmGRPH_UPDATE + crtc_offsets[i], tmp); | ||
484 | } | ||
485 | tmp = RREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i]); | ||
486 | if (tmp & 1) { | ||
487 | tmp &= ~1; | ||
488 | WREG32(mmMASTER_UPDATE_LOCK + crtc_offsets[i], tmp); | ||
489 | } | ||
490 | for (j = 0; j < adev->usec_timeout; j++) { | ||
491 | tmp = RREG32(mmGRPH_UPDATE + crtc_offsets[i]); | ||
492 | if ((tmp & GRPH_UPDATE__GRPH_SURFACE_UPDATE_PENDING_MASK) == 0) | ||
493 | break; | ||
494 | udelay(1); | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | |||
499 | /* Unlock vga access */ | ||
500 | WREG32(mmVGA_HDP_CONTROL, save->vga_hdp_control); | ||
501 | mdelay(1); | ||
502 | WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control); | ||
503 | |||
504 | } | ||
505 | |||
506 | static void dce_v6_0_set_vga_render_state(struct amdgpu_device *adev, | 395 | static void dce_v6_0_set_vga_render_state(struct amdgpu_device *adev, |
507 | bool render) | 396 | bool render) |
508 | { | 397 | { |
@@ -2873,6 +2762,8 @@ static int dce_v6_0_hw_init(void *handle) | |||
2873 | int i; | 2762 | int i; |
2874 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2763 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2875 | 2764 | ||
2765 | /* disable vga render */ | ||
2766 | dce_v6_0_set_vga_render_state(adev, false); | ||
2876 | /* init dig PHYs, disp eng pll */ | 2767 | /* init dig PHYs, disp eng pll */ |
2877 | amdgpu_atombios_encoder_init_dig(adev); | 2768 | amdgpu_atombios_encoder_init_dig(adev); |
2878 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); | 2769 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); |
@@ -3525,7 +3416,6 @@ static void dce_v6_0_encoder_add(struct amdgpu_device *adev, | |||
3525 | } | 3416 | } |
3526 | 3417 | ||
3527 | static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { | 3418 | static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { |
3528 | .set_vga_render_state = &dce_v6_0_set_vga_render_state, | ||
3529 | .bandwidth_update = &dce_v6_0_bandwidth_update, | 3419 | .bandwidth_update = &dce_v6_0_bandwidth_update, |
3530 | .vblank_get_counter = &dce_v6_0_vblank_get_counter, | 3420 | .vblank_get_counter = &dce_v6_0_vblank_get_counter, |
3531 | .vblank_wait = &dce_v6_0_vblank_wait, | 3421 | .vblank_wait = &dce_v6_0_vblank_wait, |
@@ -3538,8 +3428,6 @@ static const struct amdgpu_display_funcs dce_v6_0_display_funcs = { | |||
3538 | .page_flip_get_scanoutpos = &dce_v6_0_crtc_get_scanoutpos, | 3428 | .page_flip_get_scanoutpos = &dce_v6_0_crtc_get_scanoutpos, |
3539 | .add_encoder = &dce_v6_0_encoder_add, | 3429 | .add_encoder = &dce_v6_0_encoder_add, |
3540 | .add_connector = &amdgpu_connector_add, | 3430 | .add_connector = &amdgpu_connector_add, |
3541 | .stop_mc_access = &dce_v6_0_stop_mc_access, | ||
3542 | .resume_mc_access = &dce_v6_0_resume_mc_access, | ||
3543 | }; | 3431 | }; |
3544 | 3432 | ||
3545 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev) | 3433 | static void dce_v6_0_set_display_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index c164bef82846..c0740adee46f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | |||
@@ -419,81 +419,6 @@ static bool dce_v8_0_is_display_hung(struct amdgpu_device *adev) | |||
419 | return true; | 419 | return true; |
420 | } | 420 | } |
421 | 421 | ||
422 | static void dce_v8_0_stop_mc_access(struct amdgpu_device *adev, | ||
423 | struct amdgpu_mode_mc_save *save) | ||
424 | { | ||
425 | u32 crtc_enabled, tmp; | ||
426 | int i; | ||
427 | |||
428 | save->vga_render_control = RREG32(mmVGA_RENDER_CONTROL); | ||
429 | save->vga_hdp_control = RREG32(mmVGA_HDP_CONTROL); | ||
430 | |||
431 | /* disable VGA render */ | ||
432 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
433 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
434 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
435 | |||
436 | /* blank the display controllers */ | ||
437 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
438 | crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]), | ||
439 | CRTC_CONTROL, CRTC_MASTER_EN); | ||
440 | if (crtc_enabled) { | ||
441 | #if 1 | ||
442 | save->crtc_enabled[i] = true; | ||
443 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
444 | if (REG_GET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN) == 0) { | ||
445 | /*it is correct only for RGB ; black is 0*/ | ||
446 | WREG32(mmCRTC_BLANK_DATA_COLOR + crtc_offsets[i], 0); | ||
447 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 1); | ||
448 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
449 | } | ||
450 | mdelay(20); | ||
451 | #else | ||
452 | /* XXX this is a hack to avoid strange behavior with EFI on certain systems */ | ||
453 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1); | ||
454 | tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]); | ||
455 | tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0); | ||
456 | WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp); | ||
457 | WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0); | ||
458 | save->crtc_enabled[i] = false; | ||
459 | /* ***** */ | ||
460 | #endif | ||
461 | } else { | ||
462 | save->crtc_enabled[i] = false; | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | |||
467 | static void dce_v8_0_resume_mc_access(struct amdgpu_device *adev, | ||
468 | struct amdgpu_mode_mc_save *save) | ||
469 | { | ||
470 | u32 tmp; | ||
471 | int i; | ||
472 | |||
473 | /* update crtc base addresses */ | ||
474 | for (i = 0; i < adev->mode_info.num_crtc; i++) { | ||
475 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + crtc_offsets[i], | ||
476 | upper_32_bits(adev->mc.vram_start)); | ||
477 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + crtc_offsets[i], | ||
478 | (u32)adev->mc.vram_start); | ||
479 | |||
480 | if (save->crtc_enabled[i]) { | ||
481 | tmp = RREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i]); | ||
482 | tmp = REG_SET_FIELD(tmp, CRTC_BLANK_CONTROL, CRTC_BLANK_DATA_EN, 0); | ||
483 | WREG32(mmCRTC_BLANK_CONTROL + crtc_offsets[i], tmp); | ||
484 | } | ||
485 | mdelay(20); | ||
486 | } | ||
487 | |||
488 | WREG32(mmVGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(adev->mc.vram_start)); | ||
489 | WREG32(mmVGA_MEMORY_BASE_ADDRESS, lower_32_bits(adev->mc.vram_start)); | ||
490 | |||
491 | /* Unlock vga access */ | ||
492 | WREG32(mmVGA_HDP_CONTROL, save->vga_hdp_control); | ||
493 | mdelay(1); | ||
494 | WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control); | ||
495 | } | ||
496 | |||
497 | static void dce_v8_0_set_vga_render_state(struct amdgpu_device *adev, | 422 | static void dce_v8_0_set_vga_render_state(struct amdgpu_device *adev, |
498 | bool render) | 423 | bool render) |
499 | { | 424 | { |
@@ -2870,6 +2795,8 @@ static int dce_v8_0_hw_init(void *handle) | |||
2870 | int i; | 2795 | int i; |
2871 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 2796 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
2872 | 2797 | ||
2798 | /* disable vga render */ | ||
2799 | dce_v8_0_set_vga_render_state(adev, false); | ||
2873 | /* init dig PHYs, disp eng pll */ | 2800 | /* init dig PHYs, disp eng pll */ |
2874 | amdgpu_atombios_encoder_init_dig(adev); | 2801 | amdgpu_atombios_encoder_init_dig(adev); |
2875 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); | 2802 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); |
@@ -3574,7 +3501,6 @@ static void dce_v8_0_encoder_add(struct amdgpu_device *adev, | |||
3574 | } | 3501 | } |
3575 | 3502 | ||
3576 | static const struct amdgpu_display_funcs dce_v8_0_display_funcs = { | 3503 | static const struct amdgpu_display_funcs dce_v8_0_display_funcs = { |
3577 | .set_vga_render_state = &dce_v8_0_set_vga_render_state, | ||
3578 | .bandwidth_update = &dce_v8_0_bandwidth_update, | 3504 | .bandwidth_update = &dce_v8_0_bandwidth_update, |
3579 | .vblank_get_counter = &dce_v8_0_vblank_get_counter, | 3505 | .vblank_get_counter = &dce_v8_0_vblank_get_counter, |
3580 | .vblank_wait = &dce_v8_0_vblank_wait, | 3506 | .vblank_wait = &dce_v8_0_vblank_wait, |
@@ -3587,8 +3513,6 @@ static const struct amdgpu_display_funcs dce_v8_0_display_funcs = { | |||
3587 | .page_flip_get_scanoutpos = &dce_v8_0_crtc_get_scanoutpos, | 3513 | .page_flip_get_scanoutpos = &dce_v8_0_crtc_get_scanoutpos, |
3588 | .add_encoder = &dce_v8_0_encoder_add, | 3514 | .add_encoder = &dce_v8_0_encoder_add, |
3589 | .add_connector = &amdgpu_connector_add, | 3515 | .add_connector = &amdgpu_connector_add, |
3590 | .stop_mc_access = &dce_v8_0_stop_mc_access, | ||
3591 | .resume_mc_access = &dce_v8_0_resume_mc_access, | ||
3592 | }; | 3516 | }; |
3593 | 3517 | ||
3594 | static void dce_v8_0_set_display_funcs(struct amdgpu_device *adev) | 3518 | static void dce_v8_0_set_display_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c index 90bb08309a53..0d2f060206dc 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c | |||
@@ -95,62 +95,6 @@ static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev) | |||
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | static void dce_virtual_stop_mc_access(struct amdgpu_device *adev, | ||
99 | struct amdgpu_mode_mc_save *save) | ||
100 | { | ||
101 | switch (adev->asic_type) { | ||
102 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
103 | case CHIP_TAHITI: | ||
104 | case CHIP_PITCAIRN: | ||
105 | case CHIP_VERDE: | ||
106 | case CHIP_OLAND: | ||
107 | dce_v6_0_disable_dce(adev); | ||
108 | break; | ||
109 | #endif | ||
110 | #ifdef CONFIG_DRM_AMDGPU_CIK | ||
111 | case CHIP_BONAIRE: | ||
112 | case CHIP_HAWAII: | ||
113 | case CHIP_KAVERI: | ||
114 | case CHIP_KABINI: | ||
115 | case CHIP_MULLINS: | ||
116 | dce_v8_0_disable_dce(adev); | ||
117 | break; | ||
118 | #endif | ||
119 | case CHIP_FIJI: | ||
120 | case CHIP_TONGA: | ||
121 | dce_v10_0_disable_dce(adev); | ||
122 | break; | ||
123 | case CHIP_CARRIZO: | ||
124 | case CHIP_STONEY: | ||
125 | case CHIP_POLARIS10: | ||
126 | case CHIP_POLARIS11: | ||
127 | case CHIP_POLARIS12: | ||
128 | dce_v11_0_disable_dce(adev); | ||
129 | break; | ||
130 | case CHIP_TOPAZ: | ||
131 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
132 | case CHIP_HAINAN: | ||
133 | #endif | ||
134 | /* no DCE */ | ||
135 | return; | ||
136 | default: | ||
137 | DRM_ERROR("Virtual display unsupported ASIC type: 0x%X\n", adev->asic_type); | ||
138 | } | ||
139 | |||
140 | return; | ||
141 | } | ||
142 | static void dce_virtual_resume_mc_access(struct amdgpu_device *adev, | ||
143 | struct amdgpu_mode_mc_save *save) | ||
144 | { | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | static void dce_virtual_set_vga_render_state(struct amdgpu_device *adev, | ||
149 | bool render) | ||
150 | { | ||
151 | return; | ||
152 | } | ||
153 | |||
154 | /** | 98 | /** |
155 | * dce_virtual_bandwidth_update - program display watermarks | 99 | * dce_virtual_bandwidth_update - program display watermarks |
156 | * | 100 | * |
@@ -522,6 +466,45 @@ static int dce_virtual_sw_fini(void *handle) | |||
522 | 466 | ||
523 | static int dce_virtual_hw_init(void *handle) | 467 | static int dce_virtual_hw_init(void *handle) |
524 | { | 468 | { |
469 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
470 | |||
471 | switch (adev->asic_type) { | ||
472 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
473 | case CHIP_TAHITI: | ||
474 | case CHIP_PITCAIRN: | ||
475 | case CHIP_VERDE: | ||
476 | case CHIP_OLAND: | ||
477 | dce_v6_0_disable_dce(adev); | ||
478 | break; | ||
479 | #endif | ||
480 | #ifdef CONFIG_DRM_AMDGPU_CIK | ||
481 | case CHIP_BONAIRE: | ||
482 | case CHIP_HAWAII: | ||
483 | case CHIP_KAVERI: | ||
484 | case CHIP_KABINI: | ||
485 | case CHIP_MULLINS: | ||
486 | dce_v8_0_disable_dce(adev); | ||
487 | break; | ||
488 | #endif | ||
489 | case CHIP_FIJI: | ||
490 | case CHIP_TONGA: | ||
491 | dce_v10_0_disable_dce(adev); | ||
492 | break; | ||
493 | case CHIP_CARRIZO: | ||
494 | case CHIP_STONEY: | ||
495 | case CHIP_POLARIS11: | ||
496 | case CHIP_POLARIS10: | ||
497 | dce_v11_0_disable_dce(adev); | ||
498 | break; | ||
499 | case CHIP_TOPAZ: | ||
500 | #ifdef CONFIG_DRM_AMDGPU_SI | ||
501 | case CHIP_HAINAN: | ||
502 | #endif | ||
503 | /* no DCE */ | ||
504 | break; | ||
505 | default: | ||
506 | DRM_ERROR("Virtual display unsupported ASIC type: 0x%X\n", adev->asic_type); | ||
507 | } | ||
525 | return 0; | 508 | return 0; |
526 | } | 509 | } |
527 | 510 | ||
@@ -677,7 +660,6 @@ static int dce_virtual_connector_encoder_init(struct amdgpu_device *adev, | |||
677 | } | 660 | } |
678 | 661 | ||
679 | static const struct amdgpu_display_funcs dce_virtual_display_funcs = { | 662 | static const struct amdgpu_display_funcs dce_virtual_display_funcs = { |
680 | .set_vga_render_state = &dce_virtual_set_vga_render_state, | ||
681 | .bandwidth_update = &dce_virtual_bandwidth_update, | 663 | .bandwidth_update = &dce_virtual_bandwidth_update, |
682 | .vblank_get_counter = &dce_virtual_vblank_get_counter, | 664 | .vblank_get_counter = &dce_virtual_vblank_get_counter, |
683 | .vblank_wait = &dce_virtual_vblank_wait, | 665 | .vblank_wait = &dce_virtual_vblank_wait, |
@@ -690,8 +672,6 @@ static const struct amdgpu_display_funcs dce_virtual_display_funcs = { | |||
690 | .page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos, | 672 | .page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos, |
691 | .add_encoder = NULL, | 673 | .add_encoder = NULL, |
692 | .add_connector = NULL, | 674 | .add_connector = NULL, |
693 | .stop_mc_access = &dce_virtual_stop_mc_access, | ||
694 | .resume_mc_access = &dce_virtual_resume_mc_access, | ||
695 | }; | 675 | }; |
696 | 676 | ||
697 | static void dce_virtual_set_display_funcs(struct amdgpu_device *adev) | 677 | static void dce_virtual_set_display_funcs(struct amdgpu_device *adev) |
@@ -809,7 +789,7 @@ static const struct amdgpu_irq_src_funcs dce_virtual_crtc_irq_funcs = { | |||
809 | 789 | ||
810 | static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev) | 790 | static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev) |
811 | { | 791 | { |
812 | adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_LAST; | 792 | adev->crtc_irq.num_types = AMDGPU_CRTC_IRQ_VBLANK6 + 1; |
813 | adev->crtc_irq.funcs = &dce_virtual_crtc_irq_funcs; | 793 | adev->crtc_irq.funcs = &dce_virtual_crtc_irq_funcs; |
814 | } | 794 | } |
815 | 795 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c index 5173ca1fd159..4ac85f47f287 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | |||
@@ -1573,7 +1573,7 @@ static void gfx_v6_0_gpu_init(struct amdgpu_device *adev) | |||
1573 | 1573 | ||
1574 | static void gfx_v6_0_scratch_init(struct amdgpu_device *adev) | 1574 | static void gfx_v6_0_scratch_init(struct amdgpu_device *adev) |
1575 | { | 1575 | { |
1576 | adev->gfx.scratch.num_reg = 7; | 1576 | adev->gfx.scratch.num_reg = 8; |
1577 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; | 1577 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
1578 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | 1578 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; |
1579 | } | 1579 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index 37b45e4403d1..17b7c6934b0a 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -2021,7 +2021,7 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev) | |||
2021 | */ | 2021 | */ |
2022 | static void gfx_v7_0_scratch_init(struct amdgpu_device *adev) | 2022 | static void gfx_v7_0_scratch_init(struct amdgpu_device *adev) |
2023 | { | 2023 | { |
2024 | adev->gfx.scratch.num_reg = 7; | 2024 | adev->gfx.scratch.num_reg = 8; |
2025 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; | 2025 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
2026 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | 2026 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; |
2027 | } | 2027 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index aa5a50f5eac8..05436b8730b4 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -193,8 +193,8 @@ static const u32 tonga_golden_common_all[] = | |||
193 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, | 193 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, |
194 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 194 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
195 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 195 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
196 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 196 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
197 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF | 197 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF |
198 | }; | 198 | }; |
199 | 199 | ||
200 | static const u32 tonga_mgcg_cgcg_init[] = | 200 | static const u32 tonga_mgcg_cgcg_init[] = |
@@ -303,8 +303,8 @@ static const u32 polaris11_golden_common_all[] = | |||
303 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, | 303 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, |
304 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 304 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
305 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 305 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
306 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 306 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
307 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, | 307 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF, |
308 | }; | 308 | }; |
309 | 309 | ||
310 | static const u32 golden_settings_polaris10_a11[] = | 310 | static const u32 golden_settings_polaris10_a11[] = |
@@ -336,8 +336,8 @@ static const u32 polaris10_golden_common_all[] = | |||
336 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, | 336 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, |
337 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 337 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
338 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 338 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
339 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 339 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
340 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, | 340 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF, |
341 | }; | 341 | }; |
342 | 342 | ||
343 | static const u32 fiji_golden_common_all[] = | 343 | static const u32 fiji_golden_common_all[] = |
@@ -348,8 +348,8 @@ static const u32 fiji_golden_common_all[] = | |||
348 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, | 348 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, |
349 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 349 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
350 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 350 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
351 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 351 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
352 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, | 352 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF, |
353 | mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | 353 | mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, |
354 | mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, | 354 | mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, |
355 | }; | 355 | }; |
@@ -436,8 +436,8 @@ static const u32 iceland_golden_common_all[] = | |||
436 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001, | 436 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001, |
437 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 437 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
438 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 438 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
439 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 439 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
440 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF | 440 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF |
441 | }; | 441 | }; |
442 | 442 | ||
443 | static const u32 iceland_mgcg_cgcg_init[] = | 443 | static const u32 iceland_mgcg_cgcg_init[] = |
@@ -532,8 +532,8 @@ static const u32 cz_golden_common_all[] = | |||
532 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001, | 532 | mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001, |
533 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 533 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
534 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 534 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
535 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 535 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
536 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF | 536 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF |
537 | }; | 537 | }; |
538 | 538 | ||
539 | static const u32 cz_mgcg_cgcg_init[] = | 539 | static const u32 cz_mgcg_cgcg_init[] = |
@@ -637,8 +637,8 @@ static const u32 stoney_golden_common_all[] = | |||
637 | mmGB_ADDR_CONFIG, 0xffffffff, 0x12010001, | 637 | mmGB_ADDR_CONFIG, 0xffffffff, 0x12010001, |
638 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | 638 | mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, |
639 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | 639 | mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, |
640 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | 640 | mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00FF7FBF, |
641 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, | 641 | mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00FF7FAF, |
642 | }; | 642 | }; |
643 | 643 | ||
644 | static const u32 stoney_mgcg_cgcg_init[] = | 644 | static const u32 stoney_mgcg_cgcg_init[] = |
@@ -750,7 +750,7 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev) | |||
750 | 750 | ||
751 | static void gfx_v8_0_scratch_init(struct amdgpu_device *adev) | 751 | static void gfx_v8_0_scratch_init(struct amdgpu_device *adev) |
752 | { | 752 | { |
753 | adev->gfx.scratch.num_reg = 7; | 753 | adev->gfx.scratch.num_reg = 8; |
754 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; | 754 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
755 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | 755 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; |
756 | } | 756 | } |
@@ -4564,7 +4564,7 @@ static int gfx_v8_0_kiq_kcq_enable(struct amdgpu_device *adev) | |||
4564 | /* This situation may be hit in the future if a new HW | 4564 | /* This situation may be hit in the future if a new HW |
4565 | * generation exposes more than 64 queues. If so, the | 4565 | * generation exposes more than 64 queues. If so, the |
4566 | * definition of queue_mask needs updating */ | 4566 | * definition of queue_mask needs updating */ |
4567 | if (WARN_ON(i > (sizeof(queue_mask)*8))) { | 4567 | if (WARN_ON(i >= (sizeof(queue_mask)*8))) { |
4568 | DRM_ERROR("Invalid KCQ enabled: %d\n", i); | 4568 | DRM_ERROR("Invalid KCQ enabled: %d\n", i); |
4569 | break; | 4569 | break; |
4570 | } | 4570 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 3a0b69b09ed6..435db6f5efcf 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -211,7 +211,7 @@ static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev) | |||
211 | 211 | ||
212 | static void gfx_v9_0_scratch_init(struct amdgpu_device *adev) | 212 | static void gfx_v9_0_scratch_init(struct amdgpu_device *adev) |
213 | { | 213 | { |
214 | adev->gfx.scratch.num_reg = 7; | 214 | adev->gfx.scratch.num_reg = 8; |
215 | adev->gfx.scratch.reg_base = SOC15_REG_OFFSET(GC, 0, mmSCRATCH_REG0); | 215 | adev->gfx.scratch.reg_base = SOC15_REG_OFFSET(GC, 0, mmSCRATCH_REG0); |
216 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | 216 | adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; |
217 | } | 217 | } |
@@ -1475,21 +1475,23 @@ static void gfx_v9_0_tiling_mode_table_init(struct amdgpu_device *adev) | |||
1475 | 1475 | ||
1476 | static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num, u32 instance) | 1476 | static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num, u32 instance) |
1477 | { | 1477 | { |
1478 | u32 data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1); | 1478 | u32 data; |
1479 | 1479 | ||
1480 | if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) { | 1480 | if (instance == 0xffffffff) |
1481 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1); | 1481 | data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1); |
1482 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1); | 1482 | else |
1483 | } else if (se_num == 0xffffffff) { | 1483 | data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_INDEX, instance); |
1484 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num); | 1484 | |
1485 | if (se_num == 0xffffffff) | ||
1485 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1); | 1486 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1); |
1486 | } else if (sh_num == 0xffffffff) { | 1487 | else |
1487 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1); | ||
1488 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num); | 1488 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num); |
1489 | } else { | 1489 | |
1490 | if (sh_num == 0xffffffff) | ||
1491 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1); | ||
1492 | else | ||
1490 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num); | 1493 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num); |
1491 | data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num); | 1494 | |
1492 | } | ||
1493 | WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data); | 1495 | WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data); |
1494 | } | 1496 | } |
1495 | 1497 | ||
@@ -2425,7 +2427,7 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev) | |||
2425 | /* This situation may be hit in the future if a new HW | 2427 | /* This situation may be hit in the future if a new HW |
2426 | * generation exposes more than 64 queues. If so, the | 2428 | * generation exposes more than 64 queues. If so, the |
2427 | * definition of queue_mask needs updating */ | 2429 | * definition of queue_mask needs updating */ |
2428 | if (WARN_ON(i > (sizeof(queue_mask)*8))) { | 2430 | if (WARN_ON(i >= (sizeof(queue_mask)*8))) { |
2429 | DRM_ERROR("Invalid KCQ enabled: %d\n", i); | 2431 | DRM_ERROR("Invalid KCQ enabled: %d\n", i); |
2430 | break; | 2432 | break; |
2431 | } | 2433 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c index a42f483767e7..408723ef157c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | |||
@@ -58,14 +58,14 @@ static void gfxhub_v1_0_init_gart_aperture_regs(struct amdgpu_device *adev) | |||
58 | gfxhub_v1_0_init_gart_pt_regs(adev); | 58 | gfxhub_v1_0_init_gart_pt_regs(adev); |
59 | 59 | ||
60 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, | 60 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, |
61 | (u32)(adev->mc.gtt_start >> 12)); | 61 | (u32)(adev->mc.gart_start >> 12)); |
62 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32, | 62 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32, |
63 | (u32)(adev->mc.gtt_start >> 44)); | 63 | (u32)(adev->mc.gart_start >> 44)); |
64 | 64 | ||
65 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32, | 65 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32, |
66 | (u32)(adev->mc.gtt_end >> 12)); | 66 | (u32)(adev->mc.gart_end >> 12)); |
67 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32, | 67 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32, |
68 | (u32)(adev->mc.gtt_end >> 44)); | 68 | (u32)(adev->mc.gart_end >> 44)); |
69 | } | 69 | } |
70 | 70 | ||
71 | static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) | 71 | static void gfxhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) |
@@ -129,7 +129,7 @@ static void gfxhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
129 | /* Setup L2 cache */ | 129 | /* Setup L2 cache */ |
130 | tmp = RREG32_SOC15(GC, 0, mmVM_L2_CNTL); | 130 | tmp = RREG32_SOC15(GC, 0, mmVM_L2_CNTL); |
131 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1); | 131 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1); |
132 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 0); | 132 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 1); |
133 | /* XXX for emulation, Refer to closed source code.*/ | 133 | /* XXX for emulation, Refer to closed source code.*/ |
134 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE, | 134 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE, |
135 | 0); | 135 | 0); |
@@ -144,6 +144,8 @@ static void gfxhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
144 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL2, tmp); | 144 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL2, tmp); |
145 | 145 | ||
146 | tmp = mmVM_L2_CNTL3_DEFAULT; | 146 | tmp = mmVM_L2_CNTL3_DEFAULT; |
147 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12); | ||
148 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | ||
147 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, tmp); | 149 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, tmp); |
148 | 150 | ||
149 | tmp = mmVM_L2_CNTL4_DEFAULT; | 151 | tmp = mmVM_L2_CNTL4_DEFAULT; |
@@ -206,6 +208,9 @@ static void gfxhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) | |||
206 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 208 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
207 | PAGE_TABLE_BLOCK_SIZE, | 209 | PAGE_TABLE_BLOCK_SIZE, |
208 | adev->vm_manager.block_size - 9); | 210 | adev->vm_manager.block_size - 9); |
211 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ | ||
212 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | ||
213 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); | ||
209 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL, i, tmp); | 214 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL, i, tmp); |
210 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32, i*2, 0); | 215 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32, i*2, 0); |
211 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32, i*2, 0); | 216 | WREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32, i*2, 0); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index d0214d942bfc..93c45f26b7c8 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | |||
@@ -66,14 +66,10 @@ static const u32 crtc_offsets[6] = | |||
66 | SI_CRTC5_REGISTER_OFFSET | 66 | SI_CRTC5_REGISTER_OFFSET |
67 | }; | 67 | }; |
68 | 68 | ||
69 | static void gmc_v6_0_mc_stop(struct amdgpu_device *adev, | 69 | static void gmc_v6_0_mc_stop(struct amdgpu_device *adev) |
70 | struct amdgpu_mode_mc_save *save) | ||
71 | { | 70 | { |
72 | u32 blackout; | 71 | u32 blackout; |
73 | 72 | ||
74 | if (adev->mode_info.num_crtc) | ||
75 | amdgpu_display_stop_mc_access(adev, save); | ||
76 | |||
77 | gmc_v6_0_wait_for_idle((void *)adev); | 73 | gmc_v6_0_wait_for_idle((void *)adev); |
78 | 74 | ||
79 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); | 75 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); |
@@ -90,8 +86,7 @@ static void gmc_v6_0_mc_stop(struct amdgpu_device *adev, | |||
90 | 86 | ||
91 | } | 87 | } |
92 | 88 | ||
93 | static void gmc_v6_0_mc_resume(struct amdgpu_device *adev, | 89 | static void gmc_v6_0_mc_resume(struct amdgpu_device *adev) |
94 | struct amdgpu_mode_mc_save *save) | ||
95 | { | 90 | { |
96 | u32 tmp; | 91 | u32 tmp; |
97 | 92 | ||
@@ -103,10 +98,6 @@ static void gmc_v6_0_mc_resume(struct amdgpu_device *adev, | |||
103 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); | 98 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); |
104 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); | 99 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); |
105 | WREG32(mmBIF_FB_EN, tmp); | 100 | WREG32(mmBIF_FB_EN, tmp); |
106 | |||
107 | if (adev->mode_info.num_crtc) | ||
108 | amdgpu_display_resume_mc_access(adev, save); | ||
109 | |||
110 | } | 101 | } |
111 | 102 | ||
112 | static int gmc_v6_0_init_microcode(struct amdgpu_device *adev) | 103 | static int gmc_v6_0_init_microcode(struct amdgpu_device *adev) |
@@ -228,20 +219,20 @@ static int gmc_v6_0_mc_load_microcode(struct amdgpu_device *adev) | |||
228 | static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, | 219 | static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, |
229 | struct amdgpu_mc *mc) | 220 | struct amdgpu_mc *mc) |
230 | { | 221 | { |
222 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | ||
223 | base <<= 24; | ||
224 | |||
231 | if (mc->mc_vram_size > 0xFFC0000000ULL) { | 225 | if (mc->mc_vram_size > 0xFFC0000000ULL) { |
232 | dev_warn(adev->dev, "limiting VRAM\n"); | 226 | dev_warn(adev->dev, "limiting VRAM\n"); |
233 | mc->real_vram_size = 0xFFC0000000ULL; | 227 | mc->real_vram_size = 0xFFC0000000ULL; |
234 | mc->mc_vram_size = 0xFFC0000000ULL; | 228 | mc->mc_vram_size = 0xFFC0000000ULL; |
235 | } | 229 | } |
236 | amdgpu_vram_location(adev, &adev->mc, 0); | 230 | amdgpu_vram_location(adev, &adev->mc, base); |
237 | adev->mc.gtt_base_align = 0; | 231 | amdgpu_gart_location(adev, mc); |
238 | amdgpu_gtt_location(adev, mc); | ||
239 | } | 232 | } |
240 | 233 | ||
241 | static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | 234 | static void gmc_v6_0_mc_program(struct amdgpu_device *adev) |
242 | { | 235 | { |
243 | struct amdgpu_mode_mc_save save; | ||
244 | u32 tmp; | ||
245 | int i, j; | 236 | int i, j; |
246 | 237 | ||
247 | /* Initialize HDP */ | 238 | /* Initialize HDP */ |
@@ -254,16 +245,23 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | |||
254 | } | 245 | } |
255 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); | 246 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); |
256 | 247 | ||
257 | if (adev->mode_info.num_crtc) | ||
258 | amdgpu_display_set_vga_render_state(adev, false); | ||
259 | |||
260 | gmc_v6_0_mc_stop(adev, &save); | ||
261 | |||
262 | if (gmc_v6_0_wait_for_idle((void *)adev)) { | 248 | if (gmc_v6_0_wait_for_idle((void *)adev)) { |
263 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 249 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
264 | } | 250 | } |
265 | 251 | ||
266 | WREG32(mmVGA_HDP_CONTROL, VGA_HDP_CONTROL__VGA_MEMORY_DISABLE_MASK); | 252 | if (adev->mode_info.num_crtc) { |
253 | u32 tmp; | ||
254 | |||
255 | /* Lockout access through VGA aperture*/ | ||
256 | tmp = RREG32(mmVGA_HDP_CONTROL); | ||
257 | tmp |= VGA_HDP_CONTROL__VGA_MEMORY_DISABLE_MASK; | ||
258 | WREG32(mmVGA_HDP_CONTROL, tmp); | ||
259 | |||
260 | /* disable VGA render */ | ||
261 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
262 | tmp &= ~VGA_VSTATUS_CNTL; | ||
263 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
264 | } | ||
267 | /* Update configuration */ | 265 | /* Update configuration */ |
268 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, | 266 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, |
269 | adev->mc.vram_start >> 12); | 267 | adev->mc.vram_start >> 12); |
@@ -271,13 +269,6 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | |||
271 | adev->mc.vram_end >> 12); | 269 | adev->mc.vram_end >> 12); |
272 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, | 270 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, |
273 | adev->vram_scratch.gpu_addr >> 12); | 271 | adev->vram_scratch.gpu_addr >> 12); |
274 | tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16; | ||
275 | tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF); | ||
276 | WREG32(mmMC_VM_FB_LOCATION, tmp); | ||
277 | /* XXX double check these! */ | ||
278 | WREG32(mmHDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8)); | ||
279 | WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); | ||
280 | WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF); | ||
281 | WREG32(mmMC_VM_AGP_BASE, 0); | 272 | WREG32(mmMC_VM_AGP_BASE, 0); |
282 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); | 273 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); |
283 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); | 274 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); |
@@ -285,7 +276,6 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | |||
285 | if (gmc_v6_0_wait_for_idle((void *)adev)) { | 276 | if (gmc_v6_0_wait_for_idle((void *)adev)) { |
286 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 277 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
287 | } | 278 | } |
288 | gmc_v6_0_mc_resume(adev, &save); | ||
289 | } | 279 | } |
290 | 280 | ||
291 | static int gmc_v6_0_mc_init(struct amdgpu_device *adev) | 281 | static int gmc_v6_0_mc_init(struct amdgpu_device *adev) |
@@ -342,15 +332,7 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev) | |||
342 | adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; | 332 | adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
343 | adev->mc.visible_vram_size = adev->mc.aper_size; | 333 | adev->mc.visible_vram_size = adev->mc.aper_size; |
344 | 334 | ||
345 | /* unless the user had overridden it, set the gart | 335 | amdgpu_gart_set_defaults(adev); |
346 | * size equal to the 1024 or vram, whichever is larger. | ||
347 | */ | ||
348 | if (amdgpu_gart_size == -1) | ||
349 | adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), | ||
350 | adev->mc.mc_vram_size); | ||
351 | else | ||
352 | adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; | ||
353 | |||
354 | gmc_v6_0_vram_gtt_location(adev, &adev->mc); | 336 | gmc_v6_0_vram_gtt_location(adev, &adev->mc); |
355 | 337 | ||
356 | return 0; | 338 | return 0; |
@@ -511,8 +493,8 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) | |||
511 | (4UL << VM_L2_CNTL3__BANK_SELECT__SHIFT) | | 493 | (4UL << VM_L2_CNTL3__BANK_SELECT__SHIFT) | |
512 | (4UL << VM_L2_CNTL3__L2_CACHE_BIGK_FRAGMENT_SIZE__SHIFT)); | 494 | (4UL << VM_L2_CNTL3__L2_CACHE_BIGK_FRAGMENT_SIZE__SHIFT)); |
513 | /* setup context0 */ | 495 | /* setup context0 */ |
514 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12); | 496 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gart_start >> 12); |
515 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12); | 497 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gart_end >> 12); |
516 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); | 498 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); |
517 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | 499 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
518 | (u32)(adev->dummy_page.addr >> 12)); | 500 | (u32)(adev->dummy_page.addr >> 12)); |
@@ -559,7 +541,7 @@ static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) | |||
559 | 541 | ||
560 | gmc_v6_0_gart_flush_gpu_tlb(adev, 0); | 542 | gmc_v6_0_gart_flush_gpu_tlb(adev, 0); |
561 | dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", | 543 | dev_info(adev->dev, "PCIE GART of %uM enabled (table at 0x%016llX).\n", |
562 | (unsigned)(adev->mc.gtt_size >> 20), | 544 | (unsigned)(adev->mc.gart_size >> 20), |
563 | (unsigned long long)adev->gart.table_addr); | 545 | (unsigned long long)adev->gart.table_addr); |
564 | adev->gart.ready = true; | 546 | adev->gart.ready = true; |
565 | return 0; | 547 | return 0; |
@@ -987,7 +969,6 @@ static int gmc_v6_0_wait_for_idle(void *handle) | |||
987 | static int gmc_v6_0_soft_reset(void *handle) | 969 | static int gmc_v6_0_soft_reset(void *handle) |
988 | { | 970 | { |
989 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 971 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
990 | struct amdgpu_mode_mc_save save; | ||
991 | u32 srbm_soft_reset = 0; | 972 | u32 srbm_soft_reset = 0; |
992 | u32 tmp = RREG32(mmSRBM_STATUS); | 973 | u32 tmp = RREG32(mmSRBM_STATUS); |
993 | 974 | ||
@@ -1003,7 +984,7 @@ static int gmc_v6_0_soft_reset(void *handle) | |||
1003 | } | 984 | } |
1004 | 985 | ||
1005 | if (srbm_soft_reset) { | 986 | if (srbm_soft_reset) { |
1006 | gmc_v6_0_mc_stop(adev, &save); | 987 | gmc_v6_0_mc_stop(adev); |
1007 | if (gmc_v6_0_wait_for_idle(adev)) { | 988 | if (gmc_v6_0_wait_for_idle(adev)) { |
1008 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); | 989 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); |
1009 | } | 990 | } |
@@ -1023,7 +1004,7 @@ static int gmc_v6_0_soft_reset(void *handle) | |||
1023 | 1004 | ||
1024 | udelay(50); | 1005 | udelay(50); |
1025 | 1006 | ||
1026 | gmc_v6_0_mc_resume(adev, &save); | 1007 | gmc_v6_0_mc_resume(adev); |
1027 | udelay(50); | 1008 | udelay(50); |
1028 | } | 1009 | } |
1029 | 1010 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index 7e9ea53edf8b..4a9e84062874 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | |||
@@ -37,6 +37,9 @@ | |||
37 | #include "oss/oss_2_0_d.h" | 37 | #include "oss/oss_2_0_d.h" |
38 | #include "oss/oss_2_0_sh_mask.h" | 38 | #include "oss/oss_2_0_sh_mask.h" |
39 | 39 | ||
40 | #include "dce/dce_8_0_d.h" | ||
41 | #include "dce/dce_8_0_sh_mask.h" | ||
42 | |||
40 | #include "amdgpu_atombios.h" | 43 | #include "amdgpu_atombios.h" |
41 | 44 | ||
42 | static void gmc_v7_0_set_gart_funcs(struct amdgpu_device *adev); | 45 | static void gmc_v7_0_set_gart_funcs(struct amdgpu_device *adev); |
@@ -76,14 +79,10 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev) | |||
76 | } | 79 | } |
77 | } | 80 | } |
78 | 81 | ||
79 | static void gmc_v7_0_mc_stop(struct amdgpu_device *adev, | 82 | static void gmc_v7_0_mc_stop(struct amdgpu_device *adev) |
80 | struct amdgpu_mode_mc_save *save) | ||
81 | { | 83 | { |
82 | u32 blackout; | 84 | u32 blackout; |
83 | 85 | ||
84 | if (adev->mode_info.num_crtc) | ||
85 | amdgpu_display_stop_mc_access(adev, save); | ||
86 | |||
87 | gmc_v7_0_wait_for_idle((void *)adev); | 86 | gmc_v7_0_wait_for_idle((void *)adev); |
88 | 87 | ||
89 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); | 88 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); |
@@ -99,8 +98,7 @@ static void gmc_v7_0_mc_stop(struct amdgpu_device *adev, | |||
99 | udelay(100); | 98 | udelay(100); |
100 | } | 99 | } |
101 | 100 | ||
102 | static void gmc_v7_0_mc_resume(struct amdgpu_device *adev, | 101 | static void gmc_v7_0_mc_resume(struct amdgpu_device *adev) |
103 | struct amdgpu_mode_mc_save *save) | ||
104 | { | 102 | { |
105 | u32 tmp; | 103 | u32 tmp; |
106 | 104 | ||
@@ -112,9 +110,6 @@ static void gmc_v7_0_mc_resume(struct amdgpu_device *adev, | |||
112 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); | 110 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); |
113 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); | 111 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); |
114 | WREG32(mmBIF_FB_EN, tmp); | 112 | WREG32(mmBIF_FB_EN, tmp); |
115 | |||
116 | if (adev->mode_info.num_crtc) | ||
117 | amdgpu_display_resume_mc_access(adev, save); | ||
118 | } | 113 | } |
119 | 114 | ||
120 | /** | 115 | /** |
@@ -242,15 +237,17 @@ static int gmc_v7_0_mc_load_microcode(struct amdgpu_device *adev) | |||
242 | static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, | 237 | static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, |
243 | struct amdgpu_mc *mc) | 238 | struct amdgpu_mc *mc) |
244 | { | 239 | { |
240 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | ||
241 | base <<= 24; | ||
242 | |||
245 | if (mc->mc_vram_size > 0xFFC0000000ULL) { | 243 | if (mc->mc_vram_size > 0xFFC0000000ULL) { |
246 | /* leave room for at least 1024M GTT */ | 244 | /* leave room for at least 1024M GTT */ |
247 | dev_warn(adev->dev, "limiting VRAM\n"); | 245 | dev_warn(adev->dev, "limiting VRAM\n"); |
248 | mc->real_vram_size = 0xFFC0000000ULL; | 246 | mc->real_vram_size = 0xFFC0000000ULL; |
249 | mc->mc_vram_size = 0xFFC0000000ULL; | 247 | mc->mc_vram_size = 0xFFC0000000ULL; |
250 | } | 248 | } |
251 | amdgpu_vram_location(adev, &adev->mc, 0); | 249 | amdgpu_vram_location(adev, &adev->mc, base); |
252 | adev->mc.gtt_base_align = 0; | 250 | amdgpu_gart_location(adev, mc); |
253 | amdgpu_gtt_location(adev, mc); | ||
254 | } | 251 | } |
255 | 252 | ||
256 | /** | 253 | /** |
@@ -263,7 +260,6 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, | |||
263 | */ | 260 | */ |
264 | static void gmc_v7_0_mc_program(struct amdgpu_device *adev) | 261 | static void gmc_v7_0_mc_program(struct amdgpu_device *adev) |
265 | { | 262 | { |
266 | struct amdgpu_mode_mc_save save; | ||
267 | u32 tmp; | 263 | u32 tmp; |
268 | int i, j; | 264 | int i, j; |
269 | 265 | ||
@@ -277,13 +273,20 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev) | |||
277 | } | 273 | } |
278 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); | 274 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); |
279 | 275 | ||
280 | if (adev->mode_info.num_crtc) | ||
281 | amdgpu_display_set_vga_render_state(adev, false); | ||
282 | |||
283 | gmc_v7_0_mc_stop(adev, &save); | ||
284 | if (gmc_v7_0_wait_for_idle((void *)adev)) { | 276 | if (gmc_v7_0_wait_for_idle((void *)adev)) { |
285 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 277 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
286 | } | 278 | } |
279 | if (adev->mode_info.num_crtc) { | ||
280 | /* Lockout access through VGA aperture*/ | ||
281 | tmp = RREG32(mmVGA_HDP_CONTROL); | ||
282 | tmp = REG_SET_FIELD(tmp, VGA_HDP_CONTROL, VGA_MEMORY_DISABLE, 1); | ||
283 | WREG32(mmVGA_HDP_CONTROL, tmp); | ||
284 | |||
285 | /* disable VGA render */ | ||
286 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
287 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
288 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
289 | } | ||
287 | /* Update configuration */ | 290 | /* Update configuration */ |
288 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, | 291 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, |
289 | adev->mc.vram_start >> 12); | 292 | adev->mc.vram_start >> 12); |
@@ -291,20 +294,12 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev) | |||
291 | adev->mc.vram_end >> 12); | 294 | adev->mc.vram_end >> 12); |
292 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, | 295 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, |
293 | adev->vram_scratch.gpu_addr >> 12); | 296 | adev->vram_scratch.gpu_addr >> 12); |
294 | tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16; | ||
295 | tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF); | ||
296 | WREG32(mmMC_VM_FB_LOCATION, tmp); | ||
297 | /* XXX double check these! */ | ||
298 | WREG32(mmHDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8)); | ||
299 | WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); | ||
300 | WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF); | ||
301 | WREG32(mmMC_VM_AGP_BASE, 0); | 297 | WREG32(mmMC_VM_AGP_BASE, 0); |
302 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); | 298 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); |
303 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); | 299 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); |
304 | if (gmc_v7_0_wait_for_idle((void *)adev)) { | 300 | if (gmc_v7_0_wait_for_idle((void *)adev)) { |
305 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 301 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
306 | } | 302 | } |
307 | gmc_v7_0_mc_resume(adev, &save); | ||
308 | 303 | ||
309 | WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK); | 304 | WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK); |
310 | 305 | ||
@@ -391,15 +386,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) | |||
391 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) | 386 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) |
392 | adev->mc.visible_vram_size = adev->mc.real_vram_size; | 387 | adev->mc.visible_vram_size = adev->mc.real_vram_size; |
393 | 388 | ||
394 | /* unless the user had overridden it, set the gart | 389 | amdgpu_gart_set_defaults(adev); |
395 | * size equal to the 1024 or vram, whichever is larger. | ||
396 | */ | ||
397 | if (amdgpu_gart_size == -1) | ||
398 | adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), | ||
399 | adev->mc.mc_vram_size); | ||
400 | else | ||
401 | adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; | ||
402 | |||
403 | gmc_v7_0_vram_gtt_location(adev, &adev->mc); | 390 | gmc_v7_0_vram_gtt_location(adev, &adev->mc); |
404 | 391 | ||
405 | return 0; | 392 | return 0; |
@@ -611,8 +598,8 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) | |||
611 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 4); | 598 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 4); |
612 | WREG32(mmVM_L2_CNTL3, tmp); | 599 | WREG32(mmVM_L2_CNTL3, tmp); |
613 | /* setup context0 */ | 600 | /* setup context0 */ |
614 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12); | 601 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gart_start >> 12); |
615 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12); | 602 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gart_end >> 12); |
616 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); | 603 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); |
617 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | 604 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
618 | (u32)(adev->dummy_page.addr >> 12)); | 605 | (u32)(adev->dummy_page.addr >> 12)); |
@@ -666,7 +653,7 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) | |||
666 | 653 | ||
667 | gmc_v7_0_gart_flush_gpu_tlb(adev, 0); | 654 | gmc_v7_0_gart_flush_gpu_tlb(adev, 0); |
668 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 655 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
669 | (unsigned)(adev->mc.gtt_size >> 20), | 656 | (unsigned)(adev->mc.gart_size >> 20), |
670 | (unsigned long long)adev->gart.table_addr); | 657 | (unsigned long long)adev->gart.table_addr); |
671 | adev->gart.ready = true; | 658 | adev->gart.ready = true; |
672 | return 0; | 659 | return 0; |
@@ -1138,7 +1125,6 @@ static int gmc_v7_0_wait_for_idle(void *handle) | |||
1138 | static int gmc_v7_0_soft_reset(void *handle) | 1125 | static int gmc_v7_0_soft_reset(void *handle) |
1139 | { | 1126 | { |
1140 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1127 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1141 | struct amdgpu_mode_mc_save save; | ||
1142 | u32 srbm_soft_reset = 0; | 1128 | u32 srbm_soft_reset = 0; |
1143 | u32 tmp = RREG32(mmSRBM_STATUS); | 1129 | u32 tmp = RREG32(mmSRBM_STATUS); |
1144 | 1130 | ||
@@ -1154,7 +1140,7 @@ static int gmc_v7_0_soft_reset(void *handle) | |||
1154 | } | 1140 | } |
1155 | 1141 | ||
1156 | if (srbm_soft_reset) { | 1142 | if (srbm_soft_reset) { |
1157 | gmc_v7_0_mc_stop(adev, &save); | 1143 | gmc_v7_0_mc_stop(adev); |
1158 | if (gmc_v7_0_wait_for_idle((void *)adev)) { | 1144 | if (gmc_v7_0_wait_for_idle((void *)adev)) { |
1159 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); | 1145 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); |
1160 | } | 1146 | } |
@@ -1175,7 +1161,7 @@ static int gmc_v7_0_soft_reset(void *handle) | |||
1175 | /* Wait a little for things to settle down */ | 1161 | /* Wait a little for things to settle down */ |
1176 | udelay(50); | 1162 | udelay(50); |
1177 | 1163 | ||
1178 | gmc_v7_0_mc_resume(adev, &save); | 1164 | gmc_v7_0_mc_resume(adev); |
1179 | udelay(50); | 1165 | udelay(50); |
1180 | } | 1166 | } |
1181 | 1167 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index cc9f88057cd5..85c937b5e40b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #include "oss/oss_3_0_d.h" | 35 | #include "oss/oss_3_0_d.h" |
36 | #include "oss/oss_3_0_sh_mask.h" | 36 | #include "oss/oss_3_0_sh_mask.h" |
37 | 37 | ||
38 | #include "dce/dce_10_0_d.h" | ||
39 | #include "dce/dce_10_0_sh_mask.h" | ||
40 | |||
38 | #include "vid.h" | 41 | #include "vid.h" |
39 | #include "vi.h" | 42 | #include "vi.h" |
40 | 43 | ||
@@ -161,14 +164,10 @@ static void gmc_v8_0_init_golden_registers(struct amdgpu_device *adev) | |||
161 | } | 164 | } |
162 | } | 165 | } |
163 | 166 | ||
164 | static void gmc_v8_0_mc_stop(struct amdgpu_device *adev, | 167 | static void gmc_v8_0_mc_stop(struct amdgpu_device *adev) |
165 | struct amdgpu_mode_mc_save *save) | ||
166 | { | 168 | { |
167 | u32 blackout; | 169 | u32 blackout; |
168 | 170 | ||
169 | if (adev->mode_info.num_crtc) | ||
170 | amdgpu_display_stop_mc_access(adev, save); | ||
171 | |||
172 | gmc_v8_0_wait_for_idle(adev); | 171 | gmc_v8_0_wait_for_idle(adev); |
173 | 172 | ||
174 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); | 173 | blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL); |
@@ -184,8 +183,7 @@ static void gmc_v8_0_mc_stop(struct amdgpu_device *adev, | |||
184 | udelay(100); | 183 | udelay(100); |
185 | } | 184 | } |
186 | 185 | ||
187 | static void gmc_v8_0_mc_resume(struct amdgpu_device *adev, | 186 | static void gmc_v8_0_mc_resume(struct amdgpu_device *adev) |
188 | struct amdgpu_mode_mc_save *save) | ||
189 | { | 187 | { |
190 | u32 tmp; | 188 | u32 tmp; |
191 | 189 | ||
@@ -197,9 +195,6 @@ static void gmc_v8_0_mc_resume(struct amdgpu_device *adev, | |||
197 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); | 195 | tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1); |
198 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); | 196 | tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1); |
199 | WREG32(mmBIF_FB_EN, tmp); | 197 | WREG32(mmBIF_FB_EN, tmp); |
200 | |||
201 | if (adev->mode_info.num_crtc) | ||
202 | amdgpu_display_resume_mc_access(adev, save); | ||
203 | } | 198 | } |
204 | 199 | ||
205 | /** | 200 | /** |
@@ -404,15 +399,20 @@ static int gmc_v8_0_polaris_mc_load_microcode(struct amdgpu_device *adev) | |||
404 | static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, | 399 | static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, |
405 | struct amdgpu_mc *mc) | 400 | struct amdgpu_mc *mc) |
406 | { | 401 | { |
402 | u64 base = 0; | ||
403 | |||
404 | if (!amdgpu_sriov_vf(adev)) | ||
405 | base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | ||
406 | base <<= 24; | ||
407 | |||
407 | if (mc->mc_vram_size > 0xFFC0000000ULL) { | 408 | if (mc->mc_vram_size > 0xFFC0000000ULL) { |
408 | /* leave room for at least 1024M GTT */ | 409 | /* leave room for at least 1024M GTT */ |
409 | dev_warn(adev->dev, "limiting VRAM\n"); | 410 | dev_warn(adev->dev, "limiting VRAM\n"); |
410 | mc->real_vram_size = 0xFFC0000000ULL; | 411 | mc->real_vram_size = 0xFFC0000000ULL; |
411 | mc->mc_vram_size = 0xFFC0000000ULL; | 412 | mc->mc_vram_size = 0xFFC0000000ULL; |
412 | } | 413 | } |
413 | amdgpu_vram_location(adev, &adev->mc, 0); | 414 | amdgpu_vram_location(adev, &adev->mc, base); |
414 | adev->mc.gtt_base_align = 0; | 415 | amdgpu_gart_location(adev, mc); |
415 | amdgpu_gtt_location(adev, mc); | ||
416 | } | 416 | } |
417 | 417 | ||
418 | /** | 418 | /** |
@@ -425,7 +425,6 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, | |||
425 | */ | 425 | */ |
426 | static void gmc_v8_0_mc_program(struct amdgpu_device *adev) | 426 | static void gmc_v8_0_mc_program(struct amdgpu_device *adev) |
427 | { | 427 | { |
428 | struct amdgpu_mode_mc_save save; | ||
429 | u32 tmp; | 428 | u32 tmp; |
430 | int i, j; | 429 | int i, j; |
431 | 430 | ||
@@ -439,13 +438,20 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev) | |||
439 | } | 438 | } |
440 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); | 439 | WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0); |
441 | 440 | ||
442 | if (adev->mode_info.num_crtc) | ||
443 | amdgpu_display_set_vga_render_state(adev, false); | ||
444 | |||
445 | gmc_v8_0_mc_stop(adev, &save); | ||
446 | if (gmc_v8_0_wait_for_idle((void *)adev)) { | 441 | if (gmc_v8_0_wait_for_idle((void *)adev)) { |
447 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 442 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
448 | } | 443 | } |
444 | if (adev->mode_info.num_crtc) { | ||
445 | /* Lockout access through VGA aperture*/ | ||
446 | tmp = RREG32(mmVGA_HDP_CONTROL); | ||
447 | tmp = REG_SET_FIELD(tmp, VGA_HDP_CONTROL, VGA_MEMORY_DISABLE, 1); | ||
448 | WREG32(mmVGA_HDP_CONTROL, tmp); | ||
449 | |||
450 | /* disable VGA render */ | ||
451 | tmp = RREG32(mmVGA_RENDER_CONTROL); | ||
452 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
453 | WREG32(mmVGA_RENDER_CONTROL, tmp); | ||
454 | } | ||
449 | /* Update configuration */ | 455 | /* Update configuration */ |
450 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, | 456 | WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR, |
451 | adev->mc.vram_start >> 12); | 457 | adev->mc.vram_start >> 12); |
@@ -453,20 +459,23 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev) | |||
453 | adev->mc.vram_end >> 12); | 459 | adev->mc.vram_end >> 12); |
454 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, | 460 | WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, |
455 | adev->vram_scratch.gpu_addr >> 12); | 461 | adev->vram_scratch.gpu_addr >> 12); |
456 | tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16; | 462 | |
457 | tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF); | 463 | if (amdgpu_sriov_vf(adev)) { |
458 | WREG32(mmMC_VM_FB_LOCATION, tmp); | 464 | tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16; |
459 | /* XXX double check these! */ | 465 | tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF); |
460 | WREG32(mmHDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8)); | 466 | WREG32(mmMC_VM_FB_LOCATION, tmp); |
461 | WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); | 467 | /* XXX double check these! */ |
462 | WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF); | 468 | WREG32(mmHDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8)); |
469 | WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); | ||
470 | WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF); | ||
471 | } | ||
472 | |||
463 | WREG32(mmMC_VM_AGP_BASE, 0); | 473 | WREG32(mmMC_VM_AGP_BASE, 0); |
464 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); | 474 | WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF); |
465 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); | 475 | WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF); |
466 | if (gmc_v8_0_wait_for_idle((void *)adev)) { | 476 | if (gmc_v8_0_wait_for_idle((void *)adev)) { |
467 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); | 477 | dev_warn(adev->dev, "Wait for MC idle timedout !\n"); |
468 | } | 478 | } |
469 | gmc_v8_0_mc_resume(adev, &save); | ||
470 | 479 | ||
471 | WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK); | 480 | WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK); |
472 | 481 | ||
@@ -553,15 +562,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) | |||
553 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) | 562 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) |
554 | adev->mc.visible_vram_size = adev->mc.real_vram_size; | 563 | adev->mc.visible_vram_size = adev->mc.real_vram_size; |
555 | 564 | ||
556 | /* unless the user had overridden it, set the gart | 565 | amdgpu_gart_set_defaults(adev); |
557 | * size equal to the 1024 or vram, whichever is larger. | ||
558 | */ | ||
559 | if (amdgpu_gart_size == -1) | ||
560 | adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), | ||
561 | adev->mc.mc_vram_size); | ||
562 | else | ||
563 | adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; | ||
564 | |||
565 | gmc_v8_0_vram_gtt_location(adev, &adev->mc); | 566 | gmc_v8_0_vram_gtt_location(adev, &adev->mc); |
566 | 567 | ||
567 | return 0; | 568 | return 0; |
@@ -813,8 +814,8 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) | |||
813 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PTE_REQUEST_SNOOP, 0); | 814 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PTE_REQUEST_SNOOP, 0); |
814 | WREG32(mmVM_L2_CNTL4, tmp); | 815 | WREG32(mmVM_L2_CNTL4, tmp); |
815 | /* setup context0 */ | 816 | /* setup context0 */ |
816 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12); | 817 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gart_start >> 12); |
817 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12); | 818 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gart_end >> 12); |
818 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); | 819 | WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12); |
819 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | 820 | WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
820 | (u32)(adev->dummy_page.addr >> 12)); | 821 | (u32)(adev->dummy_page.addr >> 12)); |
@@ -869,7 +870,7 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) | |||
869 | 870 | ||
870 | gmc_v8_0_gart_flush_gpu_tlb(adev, 0); | 871 | gmc_v8_0_gart_flush_gpu_tlb(adev, 0); |
871 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 872 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
872 | (unsigned)(adev->mc.gtt_size >> 20), | 873 | (unsigned)(adev->mc.gart_size >> 20), |
873 | (unsigned long long)adev->gart.table_addr); | 874 | (unsigned long long)adev->gart.table_addr); |
874 | adev->gart.ready = true; | 875 | adev->gart.ready = true; |
875 | return 0; | 876 | return 0; |
@@ -1260,7 +1261,7 @@ static int gmc_v8_0_pre_soft_reset(void *handle) | |||
1260 | if (!adev->mc.srbm_soft_reset) | 1261 | if (!adev->mc.srbm_soft_reset) |
1261 | return 0; | 1262 | return 0; |
1262 | 1263 | ||
1263 | gmc_v8_0_mc_stop(adev, &adev->mc.save); | 1264 | gmc_v8_0_mc_stop(adev); |
1264 | if (gmc_v8_0_wait_for_idle(adev)) { | 1265 | if (gmc_v8_0_wait_for_idle(adev)) { |
1265 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); | 1266 | dev_warn(adev->dev, "Wait for GMC idle timed out !\n"); |
1266 | } | 1267 | } |
@@ -1306,7 +1307,7 @@ static int gmc_v8_0_post_soft_reset(void *handle) | |||
1306 | if (!adev->mc.srbm_soft_reset) | 1307 | if (!adev->mc.srbm_soft_reset) |
1307 | return 0; | 1308 | return 0; |
1308 | 1309 | ||
1309 | gmc_v8_0_mc_resume(adev, &adev->mc.save); | 1310 | gmc_v8_0_mc_resume(adev); |
1310 | return 0; | 1311 | return 0; |
1311 | } | 1312 | } |
1312 | 1313 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index 175ba5f9691c..c22899a08106 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
@@ -23,11 +23,14 @@ | |||
23 | #include <linux/firmware.h> | 23 | #include <linux/firmware.h> |
24 | #include "amdgpu.h" | 24 | #include "amdgpu.h" |
25 | #include "gmc_v9_0.h" | 25 | #include "gmc_v9_0.h" |
26 | #include "amdgpu_atomfirmware.h" | ||
26 | 27 | ||
27 | #include "vega10/soc15ip.h" | 28 | #include "vega10/soc15ip.h" |
28 | #include "vega10/HDP/hdp_4_0_offset.h" | 29 | #include "vega10/HDP/hdp_4_0_offset.h" |
29 | #include "vega10/HDP/hdp_4_0_sh_mask.h" | 30 | #include "vega10/HDP/hdp_4_0_sh_mask.h" |
30 | #include "vega10/GC/gc_9_0_sh_mask.h" | 31 | #include "vega10/GC/gc_9_0_sh_mask.h" |
32 | #include "vega10/DC/dce_12_0_offset.h" | ||
33 | #include "vega10/DC/dce_12_0_sh_mask.h" | ||
31 | #include "vega10/vega10_enum.h" | 34 | #include "vega10/vega10_enum.h" |
32 | 35 | ||
33 | #include "soc15_common.h" | 36 | #include "soc15_common.h" |
@@ -419,8 +422,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev, | |||
419 | if (!amdgpu_sriov_vf(adev)) | 422 | if (!amdgpu_sriov_vf(adev)) |
420 | base = mmhub_v1_0_get_fb_location(adev); | 423 | base = mmhub_v1_0_get_fb_location(adev); |
421 | amdgpu_vram_location(adev, &adev->mc, base); | 424 | amdgpu_vram_location(adev, &adev->mc, base); |
422 | adev->mc.gtt_base_align = 0; | 425 | amdgpu_gart_location(adev, mc); |
423 | amdgpu_gtt_location(adev, mc); | ||
424 | /* base offset of vram pages */ | 426 | /* base offset of vram pages */ |
425 | if (adev->flags & AMD_IS_APU) | 427 | if (adev->flags & AMD_IS_APU) |
426 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); | 428 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); |
@@ -442,43 +444,46 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev) | |||
442 | u32 tmp; | 444 | u32 tmp; |
443 | int chansize, numchan; | 445 | int chansize, numchan; |
444 | 446 | ||
445 | /* hbm memory channel size */ | 447 | adev->mc.vram_width = amdgpu_atomfirmware_get_vram_width(adev); |
446 | chansize = 128; | 448 | if (!adev->mc.vram_width) { |
447 | 449 | /* hbm memory channel size */ | |
448 | tmp = RREG32_SOC15(DF, 0, mmDF_CS_AON0_DramBaseAddress0); | 450 | chansize = 128; |
449 | tmp &= DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK; | 451 | |
450 | tmp >>= DF_CS_AON0_DramBaseAddress0__IntLvNumChan__SHIFT; | 452 | tmp = RREG32_SOC15(DF, 0, mmDF_CS_AON0_DramBaseAddress0); |
451 | switch (tmp) { | 453 | tmp &= DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK; |
452 | case 0: | 454 | tmp >>= DF_CS_AON0_DramBaseAddress0__IntLvNumChan__SHIFT; |
453 | default: | 455 | switch (tmp) { |
454 | numchan = 1; | 456 | case 0: |
455 | break; | 457 | default: |
456 | case 1: | 458 | numchan = 1; |
457 | numchan = 2; | 459 | break; |
458 | break; | 460 | case 1: |
459 | case 2: | 461 | numchan = 2; |
460 | numchan = 0; | 462 | break; |
461 | break; | 463 | case 2: |
462 | case 3: | 464 | numchan = 0; |
463 | numchan = 4; | 465 | break; |
464 | break; | 466 | case 3: |
465 | case 4: | 467 | numchan = 4; |
466 | numchan = 0; | 468 | break; |
467 | break; | 469 | case 4: |
468 | case 5: | 470 | numchan = 0; |
469 | numchan = 8; | 471 | break; |
470 | break; | 472 | case 5: |
471 | case 6: | 473 | numchan = 8; |
472 | numchan = 0; | 474 | break; |
473 | break; | 475 | case 6: |
474 | case 7: | 476 | numchan = 0; |
475 | numchan = 16; | 477 | break; |
476 | break; | 478 | case 7: |
477 | case 8: | 479 | numchan = 16; |
478 | numchan = 2; | 480 | break; |
479 | break; | 481 | case 8: |
482 | numchan = 2; | ||
483 | break; | ||
484 | } | ||
485 | adev->mc.vram_width = numchan * chansize; | ||
480 | } | 486 | } |
481 | adev->mc.vram_width = numchan * chansize; | ||
482 | 487 | ||
483 | /* Could aper size report 0 ? */ | 488 | /* Could aper size report 0 ? */ |
484 | adev->mc.aper_base = pci_resource_start(adev->pdev, 0); | 489 | adev->mc.aper_base = pci_resource_start(adev->pdev, 0); |
@@ -494,15 +499,7 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev) | |||
494 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) | 499 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) |
495 | adev->mc.visible_vram_size = adev->mc.real_vram_size; | 500 | adev->mc.visible_vram_size = adev->mc.real_vram_size; |
496 | 501 | ||
497 | /* unless the user had overridden it, set the gart | 502 | amdgpu_gart_set_defaults(adev); |
498 | * size equal to the 1024 or vram, whichever is larger. | ||
499 | */ | ||
500 | if (amdgpu_gart_size == -1) | ||
501 | adev->mc.gtt_size = max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), | ||
502 | adev->mc.mc_vram_size); | ||
503 | else | ||
504 | adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; | ||
505 | |||
506 | gmc_v9_0_vram_gtt_location(adev, &adev->mc); | 503 | gmc_v9_0_vram_gtt_location(adev, &adev->mc); |
507 | 504 | ||
508 | return 0; | 505 | return 0; |
@@ -537,10 +534,20 @@ static int gmc_v9_0_sw_init(void *handle) | |||
537 | 534 | ||
538 | spin_lock_init(&adev->mc.invalidate_lock); | 535 | spin_lock_init(&adev->mc.invalidate_lock); |
539 | 536 | ||
540 | if (adev->flags & AMD_IS_APU) { | 537 | switch (adev->asic_type) { |
538 | case CHIP_RAVEN: | ||
541 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | 539 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; |
542 | amdgpu_vm_adjust_size(adev, 64); | 540 | if (adev->rev_id == 0x0 || adev->rev_id == 0x1) { |
543 | } else { | 541 | adev->vm_manager.vm_size = 1U << 18; |
542 | adev->vm_manager.block_size = 9; | ||
543 | adev->vm_manager.num_level = 3; | ||
544 | } else { | ||
545 | /* vm_size is 64GB for legacy 2-level page support*/ | ||
546 | amdgpu_vm_adjust_size(adev, 64); | ||
547 | adev->vm_manager.num_level = 1; | ||
548 | } | ||
549 | break; | ||
550 | case CHIP_VEGA10: | ||
544 | /* XXX Don't know how to get VRAM type yet. */ | 551 | /* XXX Don't know how to get VRAM type yet. */ |
545 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_HBM; | 552 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_HBM; |
546 | /* | 553 | /* |
@@ -550,11 +557,16 @@ static int gmc_v9_0_sw_init(void *handle) | |||
550 | */ | 557 | */ |
551 | adev->vm_manager.vm_size = 1U << 18; | 558 | adev->vm_manager.vm_size = 1U << 18; |
552 | adev->vm_manager.block_size = 9; | 559 | adev->vm_manager.block_size = 9; |
553 | DRM_INFO("vm size is %llu GB, block size is %u-bit\n", | 560 | adev->vm_manager.num_level = 3; |
554 | adev->vm_manager.vm_size, | 561 | break; |
555 | adev->vm_manager.block_size); | 562 | default: |
563 | break; | ||
556 | } | 564 | } |
557 | 565 | ||
566 | DRM_INFO("vm size is %llu GB, block size is %u-bit\n", | ||
567 | adev->vm_manager.vm_size, | ||
568 | adev->vm_manager.block_size); | ||
569 | |||
558 | /* This interrupt is VMC page fault.*/ | 570 | /* This interrupt is VMC page fault.*/ |
559 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_VMC, 0, | 571 | r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_VMC, 0, |
560 | &adev->mc.vm_fault); | 572 | &adev->mc.vm_fault); |
@@ -619,11 +631,6 @@ static int gmc_v9_0_sw_init(void *handle) | |||
619 | adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids = AMDGPU_NUM_OF_VMIDS; | 631 | adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids = AMDGPU_NUM_OF_VMIDS; |
620 | adev->vm_manager.id_mgr[AMDGPU_MMHUB].num_ids = AMDGPU_NUM_OF_VMIDS; | 632 | adev->vm_manager.id_mgr[AMDGPU_MMHUB].num_ids = AMDGPU_NUM_OF_VMIDS; |
621 | 633 | ||
622 | /* TODO: fix num_level for APU when updating vm size and block size */ | ||
623 | if (adev->flags & AMD_IS_APU) | ||
624 | adev->vm_manager.num_level = 1; | ||
625 | else | ||
626 | adev->vm_manager.num_level = 3; | ||
627 | amdgpu_vm_manager_init(adev); | 634 | amdgpu_vm_manager_init(adev); |
628 | 635 | ||
629 | return 0; | 636 | return 0; |
@@ -731,7 +738,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev) | |||
731 | gmc_v9_0_gart_flush_gpu_tlb(adev, 0); | 738 | gmc_v9_0_gart_flush_gpu_tlb(adev, 0); |
732 | 739 | ||
733 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", | 740 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
734 | (unsigned)(adev->mc.gtt_size >> 20), | 741 | (unsigned)(adev->mc.gart_size >> 20), |
735 | (unsigned long long)adev->gart.table_addr); | 742 | (unsigned long long)adev->gart.table_addr); |
736 | adev->gart.ready = true; | 743 | adev->gart.ready = true; |
737 | return 0; | 744 | return 0; |
@@ -745,6 +752,20 @@ static int gmc_v9_0_hw_init(void *handle) | |||
745 | /* The sequence of these two function calls matters.*/ | 752 | /* The sequence of these two function calls matters.*/ |
746 | gmc_v9_0_init_golden_registers(adev); | 753 | gmc_v9_0_init_golden_registers(adev); |
747 | 754 | ||
755 | if (adev->mode_info.num_crtc) { | ||
756 | u32 tmp; | ||
757 | |||
758 | /* Lockout access through VGA aperture*/ | ||
759 | tmp = RREG32_SOC15(DCE, 0, mmVGA_HDP_CONTROL); | ||
760 | tmp = REG_SET_FIELD(tmp, VGA_HDP_CONTROL, VGA_MEMORY_DISABLE, 1); | ||
761 | WREG32_SOC15(DCE, 0, mmVGA_HDP_CONTROL, tmp); | ||
762 | |||
763 | /* disable VGA render */ | ||
764 | tmp = RREG32_SOC15(DCE, 0, mmVGA_RENDER_CONTROL); | ||
765 | tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0); | ||
766 | WREG32_SOC15(DCE, 0, mmVGA_RENDER_CONTROL, tmp); | ||
767 | } | ||
768 | |||
748 | r = gmc_v9_0_gart_enable(adev); | 769 | r = gmc_v9_0_gart_enable(adev); |
749 | 770 | ||
750 | return r; | 771 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c index 9804318f3488..ad8def3cc343 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | |||
@@ -69,14 +69,14 @@ static void mmhub_v1_0_init_gart_aperture_regs(struct amdgpu_device *adev) | |||
69 | mmhub_v1_0_init_gart_pt_regs(adev); | 69 | mmhub_v1_0_init_gart_pt_regs(adev); |
70 | 70 | ||
71 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, | 71 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32, |
72 | (u32)(adev->mc.gtt_start >> 12)); | 72 | (u32)(adev->mc.gart_start >> 12)); |
73 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32, | 73 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32, |
74 | (u32)(adev->mc.gtt_start >> 44)); | 74 | (u32)(adev->mc.gart_start >> 44)); |
75 | 75 | ||
76 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32, | 76 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32, |
77 | (u32)(adev->mc.gtt_end >> 12)); | 77 | (u32)(adev->mc.gart_end >> 12)); |
78 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32, | 78 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32, |
79 | (u32)(adev->mc.gtt_end >> 44)); | 79 | (u32)(adev->mc.gart_end >> 44)); |
80 | } | 80 | } |
81 | 81 | ||
82 | static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) | 82 | static void mmhub_v1_0_init_system_aperture_regs(struct amdgpu_device *adev) |
@@ -143,7 +143,7 @@ static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
143 | /* Setup L2 cache */ | 143 | /* Setup L2 cache */ |
144 | tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL); | 144 | tmp = RREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL); |
145 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1); | 145 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1); |
146 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 0); | 146 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 1); |
147 | /* XXX for emulation, Refer to closed source code.*/ | 147 | /* XXX for emulation, Refer to closed source code.*/ |
148 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE, | 148 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE, |
149 | 0); | 149 | 0); |
@@ -158,6 +158,8 @@ static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
158 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp); | 158 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp); |
159 | 159 | ||
160 | tmp = mmVM_L2_CNTL3_DEFAULT; | 160 | tmp = mmVM_L2_CNTL3_DEFAULT; |
161 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12); | ||
162 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | ||
161 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL3, tmp); | 163 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL3, tmp); |
162 | 164 | ||
163 | tmp = mmVM_L2_CNTL4_DEFAULT; | 165 | tmp = mmVM_L2_CNTL4_DEFAULT; |
@@ -222,6 +224,9 @@ static void mmhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) | |||
222 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 224 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
223 | PAGE_TABLE_BLOCK_SIZE, | 225 | PAGE_TABLE_BLOCK_SIZE, |
224 | adev->vm_manager.block_size - 9); | 226 | adev->vm_manager.block_size - 9); |
227 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ | ||
228 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | ||
229 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); | ||
225 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i, tmp); | 230 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i, tmp); |
226 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32, i*2, 0); | 231 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32, i*2, 0); |
227 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32, i*2, 0); | 232 | WREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32, i*2, 0); |
@@ -245,28 +250,28 @@ static void mmhub_v1_0_program_invalidation(struct amdgpu_device *adev) | |||
245 | } | 250 | } |
246 | 251 | ||
247 | struct pctl_data { | 252 | struct pctl_data { |
248 | uint32_t index; | 253 | uint32_t index; |
249 | uint32_t data; | 254 | uint32_t data; |
250 | }; | 255 | }; |
251 | 256 | ||
252 | const struct pctl_data pctl0_data[] = { | 257 | static const struct pctl_data pctl0_data[] = { |
253 | {0x0, 0x7a640}, | 258 | {0x0, 0x7a640}, |
254 | {0x9, 0x2a64a}, | 259 | {0x9, 0x2a64a}, |
255 | {0xd, 0x2a680}, | 260 | {0xd, 0x2a680}, |
256 | {0x11, 0x6a684}, | 261 | {0x11, 0x6a684}, |
257 | {0x19, 0xea68e}, | 262 | {0x19, 0xea68e}, |
258 | {0x29, 0xa69e}, | 263 | {0x29, 0xa69e}, |
259 | {0x2b, 0x34a6c0}, | 264 | {0x2b, 0x34a6c0}, |
260 | {0x61, 0x83a707}, | 265 | {0x61, 0x83a707}, |
261 | {0xe6, 0x8a7a4}, | 266 | {0xe6, 0x8a7a4}, |
262 | {0xf0, 0x1a7b8}, | 267 | {0xf0, 0x1a7b8}, |
263 | {0xf3, 0xfa7cc}, | 268 | {0xf3, 0xfa7cc}, |
264 | {0x104, 0x17a7dd}, | 269 | {0x104, 0x17a7dd}, |
265 | {0x11d, 0xa7dc}, | 270 | {0x11d, 0xa7dc}, |
266 | {0x11f, 0x12a7f5}, | 271 | {0x11f, 0x12a7f5}, |
267 | {0x133, 0xa808}, | 272 | {0x133, 0xa808}, |
268 | {0x135, 0x12a810}, | 273 | {0x135, 0x12a810}, |
269 | {0x149, 0x7a82c} | 274 | {0x149, 0x7a82c} |
270 | }; | 275 | }; |
271 | #define PCTL0_DATA_LEN (sizeof(pctl0_data)/sizeof(pctl0_data[0])) | 276 | #define PCTL0_DATA_LEN (sizeof(pctl0_data)/sizeof(pctl0_data[0])) |
272 | 277 | ||
@@ -274,32 +279,39 @@ const struct pctl_data pctl0_data[] = { | |||
274 | #define PCTL0_STCTRL_REG_SAVE_RANGE0_BASE 0xa640 | 279 | #define PCTL0_STCTRL_REG_SAVE_RANGE0_BASE 0xa640 |
275 | #define PCTL0_STCTRL_REG_SAVE_RANGE0_LIMIT 0xa833 | 280 | #define PCTL0_STCTRL_REG_SAVE_RANGE0_LIMIT 0xa833 |
276 | 281 | ||
277 | const struct pctl_data pctl1_data[] = { | 282 | static const struct pctl_data pctl1_data[] = { |
278 | {0x0, 0x39a000}, | 283 | {0x0, 0x39a000}, |
279 | {0x3b, 0x44a040}, | 284 | {0x3b, 0x44a040}, |
280 | {0x81, 0x2a08d}, | 285 | {0x81, 0x2a08d}, |
281 | {0x85, 0x6ba094}, | 286 | {0x85, 0x6ba094}, |
282 | {0xf2, 0x18a100}, | 287 | {0xf2, 0x18a100}, |
283 | {0x10c, 0x4a132}, | 288 | {0x10c, 0x4a132}, |
284 | {0x112, 0xca141}, | 289 | {0x112, 0xca141}, |
285 | {0x120, 0x2fa158}, | 290 | {0x120, 0x2fa158}, |
286 | {0x151, 0x17a1d0}, | 291 | {0x151, 0x17a1d0}, |
287 | {0x16a, 0x1a1e9}, | 292 | {0x16a, 0x1a1e9}, |
288 | {0x16d, 0x13a1ec}, | 293 | {0x16d, 0x13a1ec}, |
289 | {0x182, 0x7a201}, | 294 | {0x182, 0x7a201}, |
290 | {0x18b, 0x3a20a}, | 295 | {0x18b, 0x3a20a}, |
291 | {0x190, 0x7a580}, | 296 | {0x190, 0x7a580}, |
292 | {0x199, 0xa590}, | 297 | {0x199, 0xa590}, |
293 | {0x19b, 0x4a594}, | 298 | {0x19b, 0x4a594}, |
294 | {0x1a1, 0x1a59c}, | 299 | {0x1a1, 0x1a59c}, |
295 | {0x1a4, 0x7a82c}, | 300 | {0x1a4, 0x7a82c}, |
296 | {0x1ad, 0xfa7cc}, | 301 | {0x1ad, 0xfa7cc}, |
297 | {0x1be, 0x17a7dd}, | 302 | {0x1be, 0x17a7dd}, |
298 | {0x1d7, 0x12a810} | 303 | {0x1d7, 0x12a810}, |
304 | {0x1eb, 0x4000a7e1}, | ||
305 | {0x1ec, 0x5000a7f5}, | ||
306 | {0x1ed, 0x4000a7e2}, | ||
307 | {0x1ee, 0x5000a7dc}, | ||
308 | {0x1ef, 0x4000a7e3}, | ||
309 | {0x1f0, 0x5000a7f6}, | ||
310 | {0x1f1, 0x5000a7e4} | ||
299 | }; | 311 | }; |
300 | #define PCTL1_DATA_LEN (sizeof(pctl1_data)/sizeof(pctl1_data[0])) | 312 | #define PCTL1_DATA_LEN (sizeof(pctl1_data)/sizeof(pctl1_data[0])) |
301 | 313 | ||
302 | #define PCTL1_RENG_EXEC_END_PTR 0x1ea | 314 | #define PCTL1_RENG_EXEC_END_PTR 0x1f1 |
303 | #define PCTL1_STCTRL_REG_SAVE_RANGE0_BASE 0xa000 | 315 | #define PCTL1_STCTRL_REG_SAVE_RANGE0_BASE 0xa000 |
304 | #define PCTL1_STCTRL_REG_SAVE_RANGE0_LIMIT 0xa20d | 316 | #define PCTL1_STCTRL_REG_SAVE_RANGE0_LIMIT 0xa20d |
305 | #define PCTL1_STCTRL_REG_SAVE_RANGE1_BASE 0xa580 | 317 | #define PCTL1_STCTRL_REG_SAVE_RANGE1_BASE 0xa580 |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index bde3ca3c21c1..2812d88a8bdd 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | |||
@@ -72,21 +72,6 @@ static void xgpu_ai_mailbox_set_valid(struct amdgpu_device *adev, bool val) | |||
72 | reg); | 72 | reg); |
73 | } | 73 | } |
74 | 74 | ||
75 | static void xgpu_ai_mailbox_trans_msg(struct amdgpu_device *adev, | ||
76 | enum idh_request req) | ||
77 | { | ||
78 | u32 reg; | ||
79 | |||
80 | reg = RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, | ||
81 | mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0)); | ||
82 | reg = REG_SET_FIELD(reg, BIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0, | ||
83 | MSGBUF_DATA, req); | ||
84 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0), | ||
85 | reg); | ||
86 | |||
87 | xgpu_ai_mailbox_set_valid(adev, true); | ||
88 | } | ||
89 | |||
90 | static int xgpu_ai_mailbox_rcv_msg(struct amdgpu_device *adev, | 75 | static int xgpu_ai_mailbox_rcv_msg(struct amdgpu_device *adev, |
91 | enum idh_event event) | 76 | enum idh_event event) |
92 | { | 77 | { |
@@ -154,13 +139,25 @@ static int xgpu_ai_poll_msg(struct amdgpu_device *adev, enum idh_event event) | |||
154 | return r; | 139 | return r; |
155 | } | 140 | } |
156 | 141 | ||
157 | 142 | static void xgpu_ai_mailbox_trans_msg (struct amdgpu_device *adev, | |
158 | static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | 143 | enum idh_request req, u32 data1, u32 data2, u32 data3) { |
159 | enum idh_request req) | 144 | u32 reg; |
160 | { | ||
161 | int r; | 145 | int r; |
162 | 146 | ||
163 | xgpu_ai_mailbox_trans_msg(adev, req); | 147 | reg = RREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, |
148 | mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0)); | ||
149 | reg = REG_SET_FIELD(reg, BIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0, | ||
150 | MSGBUF_DATA, req); | ||
151 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW0), | ||
152 | reg); | ||
153 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW1), | ||
154 | data1); | ||
155 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW2), | ||
156 | data2); | ||
157 | WREG32_NO_KIQ(SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_MAILBOX_MSGBUF_TRN_DW3), | ||
158 | data3); | ||
159 | |||
160 | xgpu_ai_mailbox_set_valid(adev, true); | ||
164 | 161 | ||
165 | /* start to poll ack */ | 162 | /* start to poll ack */ |
166 | r = xgpu_ai_poll_ack(adev); | 163 | r = xgpu_ai_poll_ack(adev); |
@@ -168,6 +165,14 @@ static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | |||
168 | pr_err("Doesn't get ack from pf, continue\n"); | 165 | pr_err("Doesn't get ack from pf, continue\n"); |
169 | 166 | ||
170 | xgpu_ai_mailbox_set_valid(adev, false); | 167 | xgpu_ai_mailbox_set_valid(adev, false); |
168 | } | ||
169 | |||
170 | static int xgpu_ai_send_access_requests(struct amdgpu_device *adev, | ||
171 | enum idh_request req) | ||
172 | { | ||
173 | int r; | ||
174 | |||
175 | xgpu_ai_mailbox_trans_msg(adev, req, 0, 0, 0); | ||
171 | 176 | ||
172 | /* start to check msg if request is idh_req_gpu_init_access */ | 177 | /* start to check msg if request is idh_req_gpu_init_access */ |
173 | if (req == IDH_REQ_GPU_INIT_ACCESS || | 178 | if (req == IDH_REQ_GPU_INIT_ACCESS || |
@@ -342,4 +347,5 @@ const struct amdgpu_virt_ops xgpu_ai_virt_ops = { | |||
342 | .req_full_gpu = xgpu_ai_request_full_gpu_access, | 347 | .req_full_gpu = xgpu_ai_request_full_gpu_access, |
343 | .rel_full_gpu = xgpu_ai_release_full_gpu_access, | 348 | .rel_full_gpu = xgpu_ai_release_full_gpu_access, |
344 | .reset_gpu = xgpu_ai_request_reset, | 349 | .reset_gpu = xgpu_ai_request_reset, |
350 | .trans_msg = xgpu_ai_mailbox_trans_msg, | ||
345 | }; | 351 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h index 9aefc44d2c34..1e91b9a1c591 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.h | |||
@@ -31,7 +31,9 @@ enum idh_request { | |||
31 | IDH_REL_GPU_INIT_ACCESS, | 31 | IDH_REL_GPU_INIT_ACCESS, |
32 | IDH_REQ_GPU_FINI_ACCESS, | 32 | IDH_REQ_GPU_FINI_ACCESS, |
33 | IDH_REL_GPU_FINI_ACCESS, | 33 | IDH_REL_GPU_FINI_ACCESS, |
34 | IDH_REQ_GPU_RESET_ACCESS | 34 | IDH_REQ_GPU_RESET_ACCESS, |
35 | |||
36 | IDH_LOG_VF_ERROR = 200, | ||
35 | }; | 37 | }; |
36 | 38 | ||
37 | enum idh_event { | 39 | enum idh_event { |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index 171a658135b5..c25a831f94ec 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | |||
@@ -613,4 +613,5 @@ const struct amdgpu_virt_ops xgpu_vi_virt_ops = { | |||
613 | .req_full_gpu = xgpu_vi_request_full_gpu_access, | 613 | .req_full_gpu = xgpu_vi_request_full_gpu_access, |
614 | .rel_full_gpu = xgpu_vi_release_full_gpu_access, | 614 | .rel_full_gpu = xgpu_vi_release_full_gpu_access, |
615 | .reset_gpu = xgpu_vi_request_reset, | 615 | .reset_gpu = xgpu_vi_request_reset, |
616 | .trans_msg = NULL, /* Does not need to trans VF errors to host. */ | ||
616 | }; | 617 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h index 2db741131bc6..c791d73d2d54 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.h | |||
@@ -32,7 +32,9 @@ enum idh_request { | |||
32 | IDH_REL_GPU_INIT_ACCESS, | 32 | IDH_REL_GPU_INIT_ACCESS, |
33 | IDH_REQ_GPU_FINI_ACCESS, | 33 | IDH_REQ_GPU_FINI_ACCESS, |
34 | IDH_REL_GPU_FINI_ACCESS, | 34 | IDH_REL_GPU_FINI_ACCESS, |
35 | IDH_REQ_GPU_RESET_ACCESS | 35 | IDH_REQ_GPU_RESET_ACCESS, |
36 | |||
37 | IDH_LOG_VF_ERROR = 200, | ||
36 | }; | 38 | }; |
37 | 39 | ||
38 | /* VI mailbox messages data */ | 40 | /* VI mailbox messages data */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c index 1e272f785def..045988b18bc3 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | |||
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | #define smnCPM_CONTROL 0x11180460 | 33 | #define smnCPM_CONTROL 0x11180460 |
34 | #define smnPCIE_CNTL2 0x11180070 | 34 | #define smnPCIE_CNTL2 0x11180070 |
35 | #define smnPCIE_CONFIG_CNTL 0x11180044 | ||
35 | 36 | ||
36 | u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev) | 37 | u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev) |
37 | { | 38 | { |
@@ -67,7 +68,7 @@ void nbio_v6_1_mc_access_enable(struct amdgpu_device *adev, bool enable) | |||
67 | 68 | ||
68 | void nbio_v6_1_hdp_flush(struct amdgpu_device *adev) | 69 | void nbio_v6_1_hdp_flush(struct amdgpu_device *adev) |
69 | { | 70 | { |
70 | WREG32_SOC15(NBIO, 0, mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL, 0); | 71 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
71 | } | 72 | } |
72 | 73 | ||
73 | u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev) | 74 | u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev) |
@@ -256,3 +257,15 @@ void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev) | |||
256 | adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; | 257 | adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; |
257 | } | 258 | } |
258 | } | 259 | } |
260 | |||
261 | void nbio_v6_1_init_registers(struct amdgpu_device *adev) | ||
262 | { | ||
263 | uint32_t def, data; | ||
264 | |||
265 | def = data = RREG32_PCIE(smnPCIE_CONFIG_CNTL); | ||
266 | data = REG_SET_FIELD(data, PCIE_CONFIG_CNTL, CI_SWUS_MAX_READ_REQUEST_SIZE_MODE, 1); | ||
267 | data = REG_SET_FIELD(data, PCIE_CONFIG_CNTL, CI_SWUS_MAX_READ_REQUEST_SIZE_PRIV, 1); | ||
268 | |||
269 | if (def != data) | ||
270 | WREG32_PCIE(smnPCIE_CONFIG_CNTL, data); | ||
271 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h index f6f8bc045518..686e4b4d296a 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h | |||
@@ -50,5 +50,6 @@ void nbio_v6_1_update_medium_grain_clock_gating(struct amdgpu_device *adev, bool | |||
50 | void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, bool enable); | 50 | void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, bool enable); |
51 | void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, u32 *flags); | 51 | void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, u32 *flags); |
52 | void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev); | 52 | void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev); |
53 | void nbio_v6_1_init_registers(struct amdgpu_device *adev); | ||
53 | 54 | ||
54 | #endif | 55 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c index aa04632523fa..11b70d601922 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c | |||
@@ -65,7 +65,7 @@ void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable) | |||
65 | 65 | ||
66 | void nbio_v7_0_hdp_flush(struct amdgpu_device *adev) | 66 | void nbio_v7_0_hdp_flush(struct amdgpu_device *adev) |
67 | { | 67 | { |
68 | WREG32_SOC15(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0); | 68 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
69 | } | 69 | } |
70 | 70 | ||
71 | u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev) | 71 | u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c index 2258323a3c26..f7cf994b1da2 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c | |||
@@ -86,6 +86,52 @@ psp_v10_0_get_fw_type(struct amdgpu_firmware_info *ucode, enum psp_gfx_fw_type * | |||
86 | return 0; | 86 | return 0; |
87 | } | 87 | } |
88 | 88 | ||
89 | int psp_v10_0_init_microcode(struct psp_context *psp) | ||
90 | { | ||
91 | struct amdgpu_device *adev = psp->adev; | ||
92 | const char *chip_name; | ||
93 | char fw_name[30]; | ||
94 | int err = 0; | ||
95 | const struct psp_firmware_header_v1_0 *hdr; | ||
96 | |||
97 | DRM_DEBUG("\n"); | ||
98 | |||
99 | switch (adev->asic_type) { | ||
100 | case CHIP_RAVEN: | ||
101 | chip_name = "raven"; | ||
102 | break; | ||
103 | default: BUG(); | ||
104 | } | ||
105 | |||
106 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", chip_name); | ||
107 | err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev); | ||
108 | if (err) | ||
109 | goto out; | ||
110 | |||
111 | err = amdgpu_ucode_validate(adev->psp.asd_fw); | ||
112 | if (err) | ||
113 | goto out; | ||
114 | |||
115 | hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data; | ||
116 | adev->psp.asd_fw_version = le32_to_cpu(hdr->header.ucode_version); | ||
117 | adev->psp.asd_feature_version = le32_to_cpu(hdr->ucode_feature_version); | ||
118 | adev->psp.asd_ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes); | ||
119 | adev->psp.asd_start_addr = (uint8_t *)hdr + | ||
120 | le32_to_cpu(hdr->header.ucode_array_offset_bytes); | ||
121 | |||
122 | return 0; | ||
123 | out: | ||
124 | if (err) { | ||
125 | dev_err(adev->dev, | ||
126 | "psp v10.0: Failed to load firmware \"%s\"\n", | ||
127 | fw_name); | ||
128 | release_firmware(adev->psp.asd_fw); | ||
129 | adev->psp.asd_fw = NULL; | ||
130 | } | ||
131 | |||
132 | return err; | ||
133 | } | ||
134 | |||
89 | int psp_v10_0_prep_cmd_buf(struct amdgpu_firmware_info *ucode, struct psp_gfx_cmd_resp *cmd) | 135 | int psp_v10_0_prep_cmd_buf(struct amdgpu_firmware_info *ucode, struct psp_gfx_cmd_resp *cmd) |
90 | { | 136 | { |
91 | int ret; | 137 | int ret; |
@@ -110,7 +156,6 @@ int psp_v10_0_prep_cmd_buf(struct amdgpu_firmware_info *ucode, struct psp_gfx_cm | |||
110 | int psp_v10_0_ring_init(struct psp_context *psp, enum psp_ring_type ring_type) | 156 | int psp_v10_0_ring_init(struct psp_context *psp, enum psp_ring_type ring_type) |
111 | { | 157 | { |
112 | int ret = 0; | 158 | int ret = 0; |
113 | unsigned int psp_ring_reg = 0; | ||
114 | struct psp_ring *ring; | 159 | struct psp_ring *ring; |
115 | struct amdgpu_device *adev = psp->adev; | 160 | struct amdgpu_device *adev = psp->adev; |
116 | 161 | ||
@@ -130,6 +175,16 @@ int psp_v10_0_ring_init(struct psp_context *psp, enum psp_ring_type ring_type) | |||
130 | return ret; | 175 | return ret; |
131 | } | 176 | } |
132 | 177 | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | int psp_v10_0_ring_create(struct psp_context *psp, enum psp_ring_type ring_type) | ||
182 | { | ||
183 | int ret = 0; | ||
184 | unsigned int psp_ring_reg = 0; | ||
185 | struct psp_ring *ring = &psp->km_ring; | ||
186 | struct amdgpu_device *adev = psp->adev; | ||
187 | |||
133 | /* Write low address of the ring to C2PMSG_69 */ | 188 | /* Write low address of the ring to C2PMSG_69 */ |
134 | psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr); | 189 | psp_ring_reg = lower_32_bits(ring->ring_mem_mc_addr); |
135 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_69, psp_ring_reg); | 190 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_69, psp_ring_reg); |
@@ -143,13 +198,42 @@ int psp_v10_0_ring_init(struct psp_context *psp, enum psp_ring_type ring_type) | |||
143 | psp_ring_reg = ring_type; | 198 | psp_ring_reg = ring_type; |
144 | psp_ring_reg = psp_ring_reg << 16; | 199 | psp_ring_reg = psp_ring_reg << 16; |
145 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, psp_ring_reg); | 200 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, psp_ring_reg); |
201 | |||
202 | /* There might be handshake issue with hardware which needs delay */ | ||
203 | mdelay(20); | ||
204 | |||
146 | /* Wait for response flag (bit 31) in C2PMSG_64 */ | 205 | /* Wait for response flag (bit 31) in C2PMSG_64 */ |
147 | psp_ring_reg = 0; | 206 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64), |
148 | while ((psp_ring_reg & 0x80000000) == 0) { | 207 | 0x80000000, 0x8000FFFF, false); |
149 | psp_ring_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64); | ||
150 | } | ||
151 | 208 | ||
152 | return 0; | 209 | return ret; |
210 | } | ||
211 | |||
212 | int psp_v10_0_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type) | ||
213 | { | ||
214 | int ret = 0; | ||
215 | struct psp_ring *ring; | ||
216 | unsigned int psp_ring_reg = 0; | ||
217 | struct amdgpu_device *adev = psp->adev; | ||
218 | |||
219 | ring = &psp->km_ring; | ||
220 | |||
221 | /* Write the ring destroy command to C2PMSG_64 */ | ||
222 | psp_ring_reg = 3 << 16; | ||
223 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, psp_ring_reg); | ||
224 | |||
225 | /* There might be handshake issue with hardware which needs delay */ | ||
226 | mdelay(20); | ||
227 | |||
228 | /* Wait for response flag (bit 31) in C2PMSG_64 */ | ||
229 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64), | ||
230 | 0x80000000, 0x80000000, false); | ||
231 | |||
232 | amdgpu_bo_free_kernel(&adev->firmware.rbuf, | ||
233 | &ring->ring_mem_mc_addr, | ||
234 | (void **)&ring->ring_mem); | ||
235 | |||
236 | return ret; | ||
153 | } | 237 | } |
154 | 238 | ||
155 | int psp_v10_0_cmd_submit(struct psp_context *psp, | 239 | int psp_v10_0_cmd_submit(struct psp_context *psp, |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h index 2022b7b7151e..e76cde2f01f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.h | |||
@@ -27,10 +27,15 @@ | |||
27 | 27 | ||
28 | #include "amdgpu_psp.h" | 28 | #include "amdgpu_psp.h" |
29 | 29 | ||
30 | extern int psp_v10_0_init_microcode(struct psp_context *psp); | ||
30 | extern int psp_v10_0_prep_cmd_buf(struct amdgpu_firmware_info *ucode, | 31 | extern int psp_v10_0_prep_cmd_buf(struct amdgpu_firmware_info *ucode, |
31 | struct psp_gfx_cmd_resp *cmd); | 32 | struct psp_gfx_cmd_resp *cmd); |
32 | extern int psp_v10_0_ring_init(struct psp_context *psp, | 33 | extern int psp_v10_0_ring_init(struct psp_context *psp, |
33 | enum psp_ring_type ring_type); | 34 | enum psp_ring_type ring_type); |
35 | extern int psp_v10_0_ring_create(struct psp_context *psp, | ||
36 | enum psp_ring_type ring_type); | ||
37 | extern int psp_v10_0_ring_destroy(struct psp_context *psp, | ||
38 | enum psp_ring_type ring_type); | ||
34 | extern int psp_v10_0_cmd_submit(struct psp_context *psp, | 39 | extern int psp_v10_0_cmd_submit(struct psp_context *psp, |
35 | struct amdgpu_firmware_info *ucode, | 40 | struct amdgpu_firmware_info *ucode, |
36 | uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr, | 41 | uint64_t cmd_buf_mc_addr, uint64_t fence_mc_addr, |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c index c98d77d0c8f8..2a535a4b8d5b 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c | |||
@@ -237,11 +237,9 @@ int psp_v3_1_bootloader_load_sos(struct psp_context *psp) | |||
237 | 237 | ||
238 | /* there might be handshake issue with hardware which needs delay */ | 238 | /* there might be handshake issue with hardware which needs delay */ |
239 | mdelay(20); | 239 | mdelay(20); |
240 | #if 0 | ||
241 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_81), | 240 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_81), |
242 | RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81), | 241 | RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81), |
243 | 0, true); | 242 | 0, true); |
244 | #endif | ||
245 | 243 | ||
246 | return ret; | 244 | return ret; |
247 | } | 245 | } |
@@ -341,10 +339,10 @@ int psp_v3_1_ring_destroy(struct psp_context *psp, enum psp_ring_type ring_type) | |||
341 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64), | 339 | ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, mmMP0_SMN_C2PMSG_64), |
342 | 0x80000000, 0x80000000, false); | 340 | 0x80000000, 0x80000000, false); |
343 | 341 | ||
344 | if (ring->ring_mem) | 342 | amdgpu_bo_free_kernel(&adev->firmware.rbuf, |
345 | amdgpu_bo_free_kernel(&adev->firmware.rbuf, | 343 | &ring->ring_mem_mc_addr, |
346 | &ring->ring_mem_mc_addr, | 344 | (void **)&ring->ring_mem); |
347 | (void **)&ring->ring_mem); | 345 | |
348 | return ret; | 346 | return ret; |
349 | } | 347 | } |
350 | 348 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index 1d766ae98dc8..b1de44f22824 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -551,17 +551,53 @@ static void sdma_v3_0_rlc_stop(struct amdgpu_device *adev) | |||
551 | */ | 551 | */ |
552 | static void sdma_v3_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) | 552 | static void sdma_v3_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) |
553 | { | 553 | { |
554 | u32 f32_cntl; | 554 | u32 f32_cntl, phase_quantum = 0; |
555 | int i; | 555 | int i; |
556 | 556 | ||
557 | if (amdgpu_sdma_phase_quantum) { | ||
558 | unsigned value = amdgpu_sdma_phase_quantum; | ||
559 | unsigned unit = 0; | ||
560 | |||
561 | while (value > (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
562 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT)) { | ||
563 | value = (value + 1) >> 1; | ||
564 | unit++; | ||
565 | } | ||
566 | if (unit > (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
567 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT)) { | ||
568 | value = (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
569 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT); | ||
570 | unit = (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
571 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT); | ||
572 | WARN_ONCE(1, | ||
573 | "clamping sdma_phase_quantum to %uK clock cycles\n", | ||
574 | value << unit); | ||
575 | } | ||
576 | phase_quantum = | ||
577 | value << SDMA0_PHASE0_QUANTUM__VALUE__SHIFT | | ||
578 | unit << SDMA0_PHASE0_QUANTUM__UNIT__SHIFT; | ||
579 | } | ||
580 | |||
557 | for (i = 0; i < adev->sdma.num_instances; i++) { | 581 | for (i = 0; i < adev->sdma.num_instances; i++) { |
558 | f32_cntl = RREG32(mmSDMA0_CNTL + sdma_offsets[i]); | 582 | f32_cntl = RREG32(mmSDMA0_CNTL + sdma_offsets[i]); |
559 | if (enable) | 583 | if (enable) { |
560 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | 584 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, |
561 | AUTO_CTXSW_ENABLE, 1); | 585 | AUTO_CTXSW_ENABLE, 1); |
562 | else | 586 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, |
587 | ATC_L1_ENABLE, 1); | ||
588 | if (amdgpu_sdma_phase_quantum) { | ||
589 | WREG32(mmSDMA0_PHASE0_QUANTUM + sdma_offsets[i], | ||
590 | phase_quantum); | ||
591 | WREG32(mmSDMA0_PHASE1_QUANTUM + sdma_offsets[i], | ||
592 | phase_quantum); | ||
593 | } | ||
594 | } else { | ||
563 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | 595 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, |
564 | AUTO_CTXSW_ENABLE, 0); | 596 | AUTO_CTXSW_ENABLE, 0); |
597 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | ||
598 | ATC_L1_ENABLE, 1); | ||
599 | } | ||
600 | |||
565 | WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl); | 601 | WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl); |
566 | } | 602 | } |
567 | } | 603 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 4a65697ccc94..591f3e7fb508 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
@@ -493,13 +493,45 @@ static void sdma_v4_0_rlc_stop(struct amdgpu_device *adev) | |||
493 | */ | 493 | */ |
494 | static void sdma_v4_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) | 494 | static void sdma_v4_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) |
495 | { | 495 | { |
496 | u32 f32_cntl; | 496 | u32 f32_cntl, phase_quantum = 0; |
497 | int i; | 497 | int i; |
498 | 498 | ||
499 | if (amdgpu_sdma_phase_quantum) { | ||
500 | unsigned value = amdgpu_sdma_phase_quantum; | ||
501 | unsigned unit = 0; | ||
502 | |||
503 | while (value > (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
504 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT)) { | ||
505 | value = (value + 1) >> 1; | ||
506 | unit++; | ||
507 | } | ||
508 | if (unit > (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
509 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT)) { | ||
510 | value = (SDMA0_PHASE0_QUANTUM__VALUE_MASK >> | ||
511 | SDMA0_PHASE0_QUANTUM__VALUE__SHIFT); | ||
512 | unit = (SDMA0_PHASE0_QUANTUM__UNIT_MASK >> | ||
513 | SDMA0_PHASE0_QUANTUM__UNIT__SHIFT); | ||
514 | WARN_ONCE(1, | ||
515 | "clamping sdma_phase_quantum to %uK clock cycles\n", | ||
516 | value << unit); | ||
517 | } | ||
518 | phase_quantum = | ||
519 | value << SDMA0_PHASE0_QUANTUM__VALUE__SHIFT | | ||
520 | unit << SDMA0_PHASE0_QUANTUM__UNIT__SHIFT; | ||
521 | } | ||
522 | |||
499 | for (i = 0; i < adev->sdma.num_instances; i++) { | 523 | for (i = 0; i < adev->sdma.num_instances; i++) { |
500 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL)); | 524 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL)); |
501 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | 525 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, |
502 | AUTO_CTXSW_ENABLE, enable ? 1 : 0); | 526 | AUTO_CTXSW_ENABLE, enable ? 1 : 0); |
527 | if (enable && amdgpu_sdma_phase_quantum) { | ||
528 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE0_QUANTUM), | ||
529 | phase_quantum); | ||
530 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE1_QUANTUM), | ||
531 | phase_quantum); | ||
532 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE2_QUANTUM), | ||
533 | phase_quantum); | ||
534 | } | ||
503 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL), f32_cntl); | 535 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL), f32_cntl); |
504 | } | 536 | } |
505 | 537 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index f45fb0f022b3..812a24dd1204 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -1150,6 +1150,33 @@ static bool si_read_disabled_bios(struct amdgpu_device *adev) | |||
1150 | return r; | 1150 | return r; |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | #define mmROM_INDEX 0x2A | ||
1154 | #define mmROM_DATA 0x2B | ||
1155 | |||
1156 | static bool si_read_bios_from_rom(struct amdgpu_device *adev, | ||
1157 | u8 *bios, u32 length_bytes) | ||
1158 | { | ||
1159 | u32 *dw_ptr; | ||
1160 | u32 i, length_dw; | ||
1161 | |||
1162 | if (bios == NULL) | ||
1163 | return false; | ||
1164 | if (length_bytes == 0) | ||
1165 | return false; | ||
1166 | /* APU vbios image is part of sbios image */ | ||
1167 | if (adev->flags & AMD_IS_APU) | ||
1168 | return false; | ||
1169 | |||
1170 | dw_ptr = (u32 *)bios; | ||
1171 | length_dw = ALIGN(length_bytes, 4) / 4; | ||
1172 | /* set rom index to 0 */ | ||
1173 | WREG32(mmROM_INDEX, 0); | ||
1174 | for (i = 0; i < length_dw; i++) | ||
1175 | dw_ptr[i] = RREG32(mmROM_DATA); | ||
1176 | |||
1177 | return true; | ||
1178 | } | ||
1179 | |||
1153 | //xxx: not implemented | 1180 | //xxx: not implemented |
1154 | static int si_asic_reset(struct amdgpu_device *adev) | 1181 | static int si_asic_reset(struct amdgpu_device *adev) |
1155 | { | 1182 | { |
@@ -1206,6 +1233,7 @@ static void si_detect_hw_virtualization(struct amdgpu_device *adev) | |||
1206 | static const struct amdgpu_asic_funcs si_asic_funcs = | 1233 | static const struct amdgpu_asic_funcs si_asic_funcs = |
1207 | { | 1234 | { |
1208 | .read_disabled_bios = &si_read_disabled_bios, | 1235 | .read_disabled_bios = &si_read_disabled_bios, |
1236 | .read_bios_from_rom = &si_read_bios_from_rom, | ||
1209 | .read_register = &si_read_register, | 1237 | .read_register = &si_read_register, |
1210 | .reset = &si_asic_reset, | 1238 | .reset = &si_asic_reset, |
1211 | .set_vga_state = &si_vga_set_state, | 1239 | .set_vga_state = &si_vga_set_state, |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index a7ad8390981c..d63873f3f574 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
@@ -2055,6 +2055,7 @@ static void si_initialize_powertune_defaults(struct amdgpu_device *adev) | |||
2055 | case 0x682C: | 2055 | case 0x682C: |
2056 | si_pi->cac_weights = cac_weights_cape_verde_pro; | 2056 | si_pi->cac_weights = cac_weights_cape_verde_pro; |
2057 | si_pi->dte_data = dte_data_sun_xt; | 2057 | si_pi->dte_data = dte_data_sun_xt; |
2058 | update_dte_from_pl2 = true; | ||
2058 | break; | 2059 | break; |
2059 | case 0x6825: | 2060 | case 0x6825: |
2060 | case 0x6827: | 2061 | case 0x6827: |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index a7341d88a320..f2c3a49f73a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <drm/drmP.h> | 26 | #include <drm/drmP.h> |
27 | #include "amdgpu.h" | 27 | #include "amdgpu.h" |
28 | #include "amdgpu_atomfirmware.h" | 28 | #include "amdgpu_atombios.h" |
29 | #include "amdgpu_ih.h" | 29 | #include "amdgpu_ih.h" |
30 | #include "amdgpu_uvd.h" | 30 | #include "amdgpu_uvd.h" |
31 | #include "amdgpu_vce.h" | 31 | #include "amdgpu_vce.h" |
@@ -62,8 +62,6 @@ | |||
62 | #include "dce_virtual.h" | 62 | #include "dce_virtual.h" |
63 | #include "mxgpu_ai.h" | 63 | #include "mxgpu_ai.h" |
64 | 64 | ||
65 | MODULE_FIRMWARE("amdgpu/vega10_smc.bin"); | ||
66 | |||
67 | #define mmFabricConfigAccessControl 0x0410 | 65 | #define mmFabricConfigAccessControl 0x0410 |
68 | #define mmFabricConfigAccessControl_BASE_IDX 0 | 66 | #define mmFabricConfigAccessControl_BASE_IDX 0 |
69 | #define mmFabricConfigAccessControl_DEFAULT 0x00000000 | 67 | #define mmFabricConfigAccessControl_DEFAULT 0x00000000 |
@@ -198,6 +196,50 @@ static void soc15_didt_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | |||
198 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); | 196 | spin_unlock_irqrestore(&adev->didt_idx_lock, flags); |
199 | } | 197 | } |
200 | 198 | ||
199 | static u32 soc15_gc_cac_rreg(struct amdgpu_device *adev, u32 reg) | ||
200 | { | ||
201 | unsigned long flags; | ||
202 | u32 r; | ||
203 | |||
204 | spin_lock_irqsave(&adev->gc_cac_idx_lock, flags); | ||
205 | WREG32_SOC15(GC, 0, mmGC_CAC_IND_INDEX, (reg)); | ||
206 | r = RREG32_SOC15(GC, 0, mmGC_CAC_IND_DATA); | ||
207 | spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags); | ||
208 | return r; | ||
209 | } | ||
210 | |||
211 | static void soc15_gc_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
212 | { | ||
213 | unsigned long flags; | ||
214 | |||
215 | spin_lock_irqsave(&adev->gc_cac_idx_lock, flags); | ||
216 | WREG32_SOC15(GC, 0, mmGC_CAC_IND_INDEX, (reg)); | ||
217 | WREG32_SOC15(GC, 0, mmGC_CAC_IND_DATA, (v)); | ||
218 | spin_unlock_irqrestore(&adev->gc_cac_idx_lock, flags); | ||
219 | } | ||
220 | |||
221 | static u32 soc15_se_cac_rreg(struct amdgpu_device *adev, u32 reg) | ||
222 | { | ||
223 | unsigned long flags; | ||
224 | u32 r; | ||
225 | |||
226 | spin_lock_irqsave(&adev->se_cac_idx_lock, flags); | ||
227 | WREG32_SOC15(GC, 0, mmSE_CAC_IND_INDEX, (reg)); | ||
228 | r = RREG32_SOC15(GC, 0, mmSE_CAC_IND_DATA); | ||
229 | spin_unlock_irqrestore(&adev->se_cac_idx_lock, flags); | ||
230 | return r; | ||
231 | } | ||
232 | |||
233 | static void soc15_se_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | ||
234 | { | ||
235 | unsigned long flags; | ||
236 | |||
237 | spin_lock_irqsave(&adev->se_cac_idx_lock, flags); | ||
238 | WREG32_SOC15(GC, 0, mmSE_CAC_IND_INDEX, (reg)); | ||
239 | WREG32_SOC15(GC, 0, mmSE_CAC_IND_DATA, (v)); | ||
240 | spin_unlock_irqrestore(&adev->se_cac_idx_lock, flags); | ||
241 | } | ||
242 | |||
201 | static u32 soc15_get_config_memsize(struct amdgpu_device *adev) | 243 | static u32 soc15_get_config_memsize(struct amdgpu_device *adev) |
202 | { | 244 | { |
203 | if (adev->flags & AMD_IS_APU) | 245 | if (adev->flags & AMD_IS_APU) |
@@ -392,11 +434,11 @@ static void soc15_gpu_pci_config_reset(struct amdgpu_device *adev) | |||
392 | 434 | ||
393 | static int soc15_asic_reset(struct amdgpu_device *adev) | 435 | static int soc15_asic_reset(struct amdgpu_device *adev) |
394 | { | 436 | { |
395 | amdgpu_atomfirmware_scratch_regs_engine_hung(adev, true); | 437 | amdgpu_atombios_scratch_regs_engine_hung(adev, true); |
396 | 438 | ||
397 | soc15_gpu_pci_config_reset(adev); | 439 | soc15_gpu_pci_config_reset(adev); |
398 | 440 | ||
399 | amdgpu_atomfirmware_scratch_regs_engine_hung(adev, false); | 441 | amdgpu_atombios_scratch_regs_engine_hung(adev, false); |
400 | 442 | ||
401 | return 0; | 443 | return 0; |
402 | } | 444 | } |
@@ -524,13 +566,6 @@ static uint32_t soc15_get_rev_id(struct amdgpu_device *adev) | |||
524 | return nbio_v6_1_get_rev_id(adev); | 566 | return nbio_v6_1_get_rev_id(adev); |
525 | } | 567 | } |
526 | 568 | ||
527 | |||
528 | int gmc_v9_0_mc_wait_for_idle(struct amdgpu_device *adev) | ||
529 | { | ||
530 | /* to be implemented in MC IP*/ | ||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static const struct amdgpu_asic_funcs soc15_asic_funcs = | 569 | static const struct amdgpu_asic_funcs soc15_asic_funcs = |
535 | { | 570 | { |
536 | .read_disabled_bios = &soc15_read_disabled_bios, | 571 | .read_disabled_bios = &soc15_read_disabled_bios, |
@@ -557,6 +592,10 @@ static int soc15_common_early_init(void *handle) | |||
557 | adev->uvd_ctx_wreg = &soc15_uvd_ctx_wreg; | 592 | adev->uvd_ctx_wreg = &soc15_uvd_ctx_wreg; |
558 | adev->didt_rreg = &soc15_didt_rreg; | 593 | adev->didt_rreg = &soc15_didt_rreg; |
559 | adev->didt_wreg = &soc15_didt_wreg; | 594 | adev->didt_wreg = &soc15_didt_wreg; |
595 | adev->gc_cac_rreg = &soc15_gc_cac_rreg; | ||
596 | adev->gc_cac_wreg = &soc15_gc_cac_wreg; | ||
597 | adev->se_cac_rreg = &soc15_se_cac_rreg; | ||
598 | adev->se_cac_wreg = &soc15_se_cac_wreg; | ||
560 | 599 | ||
561 | adev->asic_funcs = &soc15_asic_funcs; | 600 | adev->asic_funcs = &soc15_asic_funcs; |
562 | 601 | ||
@@ -681,6 +720,9 @@ static int soc15_common_hw_init(void *handle) | |||
681 | soc15_pcie_gen3_enable(adev); | 720 | soc15_pcie_gen3_enable(adev); |
682 | /* enable aspm */ | 721 | /* enable aspm */ |
683 | soc15_program_aspm(adev); | 722 | soc15_program_aspm(adev); |
723 | /* setup nbio registers */ | ||
724 | if (!(adev->flags & AMD_IS_APU)) | ||
725 | nbio_v6_1_init_registers(adev); | ||
684 | /* enable the doorbell aperture */ | 726 | /* enable the doorbell aperture */ |
685 | soc15_enable_doorbell_aperture(adev, true); | 727 | soc15_enable_doorbell_aperture(adev, true); |
686 | 728 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h index e2d330eed952..7a8e4e28abb2 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h | |||
@@ -77,6 +77,13 @@ struct nbio_pcie_index_data { | |||
77 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | 77 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ |
78 | (ip##_BASE__INST##inst##_SEG4 + reg))))), value) | 78 | (ip##_BASE__INST##inst##_SEG4 + reg))))), value) |
79 | 79 | ||
80 | #define WREG32_SOC15_NO_KIQ(ip, inst, reg, value) \ | ||
81 | WREG32_NO_KIQ( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | ||
82 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
83 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
84 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
85 | (ip##_BASE__INST##inst##_SEG4 + reg))))), value) | ||
86 | |||
80 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ | 87 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ |
81 | WREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 88 | WREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ |
82 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | 89 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 602769ced3bd..42de22bbe14c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | |||
@@ -664,7 +664,7 @@ static int set_sched_resources(struct device_queue_manager *dqm) | |||
664 | /* This situation may be hit in the future if a new HW | 664 | /* This situation may be hit in the future if a new HW |
665 | * generation exposes more than 64 queues. If so, the | 665 | * generation exposes more than 64 queues. If so, the |
666 | * definition of res.queue_mask needs updating */ | 666 | * definition of res.queue_mask needs updating */ |
667 | if (WARN_ON(i > (sizeof(res.queue_mask)*8))) { | 667 | if (WARN_ON(i >= (sizeof(res.queue_mask)*8))) { |
668 | pr_err("Invalid queue enabled by amdgpu: %d\n", i); | 668 | pr_err("Invalid queue enabled by amdgpu: %d\n", i); |
669 | break; | 669 | break; |
670 | } | 670 | } |
diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h b/drivers/gpu/drm/amd/include/atomfirmware.h index 0021a1c63356..837296db9628 100644 --- a/drivers/gpu/drm/amd/include/atomfirmware.h +++ b/drivers/gpu/drm/amd/include/atomfirmware.h | |||
@@ -1233,6 +1233,69 @@ struct atom_asic_profiling_info_v4_1 | |||
1233 | uint32_t phyclk2gfxclk_c; | 1233 | uint32_t phyclk2gfxclk_c; |
1234 | }; | 1234 | }; |
1235 | 1235 | ||
1236 | struct atom_asic_profiling_info_v4_2 { | ||
1237 | struct atom_common_table_header table_header; | ||
1238 | uint32_t maxvddc; | ||
1239 | uint32_t minvddc; | ||
1240 | uint32_t avfs_meannsigma_acontant0; | ||
1241 | uint32_t avfs_meannsigma_acontant1; | ||
1242 | uint32_t avfs_meannsigma_acontant2; | ||
1243 | uint16_t avfs_meannsigma_dc_tol_sigma; | ||
1244 | uint16_t avfs_meannsigma_platform_mean; | ||
1245 | uint16_t avfs_meannsigma_platform_sigma; | ||
1246 | uint32_t gb_vdroop_table_cksoff_a0; | ||
1247 | uint32_t gb_vdroop_table_cksoff_a1; | ||
1248 | uint32_t gb_vdroop_table_cksoff_a2; | ||
1249 | uint32_t gb_vdroop_table_ckson_a0; | ||
1250 | uint32_t gb_vdroop_table_ckson_a1; | ||
1251 | uint32_t gb_vdroop_table_ckson_a2; | ||
1252 | uint32_t avfsgb_fuse_table_cksoff_m1; | ||
1253 | uint32_t avfsgb_fuse_table_cksoff_m2; | ||
1254 | uint32_t avfsgb_fuse_table_cksoff_b; | ||
1255 | uint32_t avfsgb_fuse_table_ckson_m1; | ||
1256 | uint32_t avfsgb_fuse_table_ckson_m2; | ||
1257 | uint32_t avfsgb_fuse_table_ckson_b; | ||
1258 | uint16_t max_voltage_0_25mv; | ||
1259 | uint8_t enable_gb_vdroop_table_cksoff; | ||
1260 | uint8_t enable_gb_vdroop_table_ckson; | ||
1261 | uint8_t enable_gb_fuse_table_cksoff; | ||
1262 | uint8_t enable_gb_fuse_table_ckson; | ||
1263 | uint16_t psm_age_comfactor; | ||
1264 | uint8_t enable_apply_avfs_cksoff_voltage; | ||
1265 | uint8_t reserved; | ||
1266 | uint32_t dispclk2gfxclk_a; | ||
1267 | uint32_t dispclk2gfxclk_b; | ||
1268 | uint32_t dispclk2gfxclk_c; | ||
1269 | uint32_t pixclk2gfxclk_a; | ||
1270 | uint32_t pixclk2gfxclk_b; | ||
1271 | uint32_t pixclk2gfxclk_c; | ||
1272 | uint32_t dcefclk2gfxclk_a; | ||
1273 | uint32_t dcefclk2gfxclk_b; | ||
1274 | uint32_t dcefclk2gfxclk_c; | ||
1275 | uint32_t phyclk2gfxclk_a; | ||
1276 | uint32_t phyclk2gfxclk_b; | ||
1277 | uint32_t phyclk2gfxclk_c; | ||
1278 | uint32_t acg_gb_vdroop_table_a0; | ||
1279 | uint32_t acg_gb_vdroop_table_a1; | ||
1280 | uint32_t acg_gb_vdroop_table_a2; | ||
1281 | uint32_t acg_avfsgb_fuse_table_m1; | ||
1282 | uint32_t acg_avfsgb_fuse_table_m2; | ||
1283 | uint32_t acg_avfsgb_fuse_table_b; | ||
1284 | uint8_t enable_acg_gb_vdroop_table; | ||
1285 | uint8_t enable_acg_gb_fuse_table; | ||
1286 | uint32_t acg_dispclk2gfxclk_a; | ||
1287 | uint32_t acg_dispclk2gfxclk_b; | ||
1288 | uint32_t acg_dispclk2gfxclk_c; | ||
1289 | uint32_t acg_pixclk2gfxclk_a; | ||
1290 | uint32_t acg_pixclk2gfxclk_b; | ||
1291 | uint32_t acg_pixclk2gfxclk_c; | ||
1292 | uint32_t acg_dcefclk2gfxclk_a; | ||
1293 | uint32_t acg_dcefclk2gfxclk_b; | ||
1294 | uint32_t acg_dcefclk2gfxclk_c; | ||
1295 | uint32_t acg_phyclk2gfxclk_a; | ||
1296 | uint32_t acg_phyclk2gfxclk_b; | ||
1297 | uint32_t acg_phyclk2gfxclk_c; | ||
1298 | }; | ||
1236 | 1299 | ||
1237 | /* | 1300 | /* |
1238 | *************************************************************************** | 1301 | *************************************************************************** |
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h index 0a94f749e3c0..0214f63f52fc 100644 --- a/drivers/gpu/drm/amd/include/cgs_common.h +++ b/drivers/gpu/drm/amd/include/cgs_common.h | |||
@@ -50,6 +50,7 @@ enum cgs_ind_reg { | |||
50 | CGS_IND_REG__UVD_CTX, | 50 | CGS_IND_REG__UVD_CTX, |
51 | CGS_IND_REG__DIDT, | 51 | CGS_IND_REG__DIDT, |
52 | CGS_IND_REG_GC_CAC, | 52 | CGS_IND_REG_GC_CAC, |
53 | CGS_IND_REG_SE_CAC, | ||
53 | CGS_IND_REG__AUDIO_ENDPT | 54 | CGS_IND_REG__AUDIO_ENDPT |
54 | }; | 55 | }; |
55 | 56 | ||
@@ -406,6 +407,8 @@ typedef int (*cgs_is_virtualization_enabled_t)(void *cgs_device); | |||
406 | 407 | ||
407 | typedef int (*cgs_enter_safe_mode)(struct cgs_device *cgs_device, bool en); | 408 | typedef int (*cgs_enter_safe_mode)(struct cgs_device *cgs_device, bool en); |
408 | 409 | ||
410 | typedef void (*cgs_lock_grbm_idx)(struct cgs_device *cgs_device, bool lock); | ||
411 | |||
409 | struct cgs_ops { | 412 | struct cgs_ops { |
410 | /* memory management calls (similar to KFD interface) */ | 413 | /* memory management calls (similar to KFD interface) */ |
411 | cgs_alloc_gpu_mem_t alloc_gpu_mem; | 414 | cgs_alloc_gpu_mem_t alloc_gpu_mem; |
@@ -441,6 +444,7 @@ struct cgs_ops { | |||
441 | cgs_query_system_info query_system_info; | 444 | cgs_query_system_info query_system_info; |
442 | cgs_is_virtualization_enabled_t is_virtualization_enabled; | 445 | cgs_is_virtualization_enabled_t is_virtualization_enabled; |
443 | cgs_enter_safe_mode enter_safe_mode; | 446 | cgs_enter_safe_mode enter_safe_mode; |
447 | cgs_lock_grbm_idx lock_grbm_idx; | ||
444 | }; | 448 | }; |
445 | 449 | ||
446 | struct cgs_os_ops; /* To be define in OS-specific CGS header */ | 450 | struct cgs_os_ops; /* To be define in OS-specific CGS header */ |
@@ -517,4 +521,6 @@ struct cgs_device | |||
517 | #define cgs_enter_safe_mode(cgs_device, en) \ | 521 | #define cgs_enter_safe_mode(cgs_device, en) \ |
518 | CGS_CALL(enter_safe_mode, cgs_device, en) | 522 | CGS_CALL(enter_safe_mode, cgs_device, en) |
519 | 523 | ||
524 | #define cgs_lock_grbm_idx(cgs_device, lock) \ | ||
525 | CGS_CALL(lock_grbm_idx, cgs_device, lock) | ||
520 | #endif /* _CGS_COMMON_H */ | 526 | #endif /* _CGS_COMMON_H */ |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c index 720d5006ff62..cd33eb179db2 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c | |||
@@ -276,7 +276,10 @@ int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr, | |||
276 | struct pp_atomfwctrl_avfs_parameters *param) | 276 | struct pp_atomfwctrl_avfs_parameters *param) |
277 | { | 277 | { |
278 | uint16_t idx; | 278 | uint16_t idx; |
279 | uint8_t format_revision, content_revision; | ||
280 | |||
279 | struct atom_asic_profiling_info_v4_1 *profile; | 281 | struct atom_asic_profiling_info_v4_1 *profile; |
282 | struct atom_asic_profiling_info_v4_2 *profile_v4_2; | ||
280 | 283 | ||
281 | idx = GetIndexIntoMasterDataTable(asic_profiling_info); | 284 | idx = GetIndexIntoMasterDataTable(asic_profiling_info); |
282 | profile = (struct atom_asic_profiling_info_v4_1 *) | 285 | profile = (struct atom_asic_profiling_info_v4_1 *) |
@@ -286,76 +289,172 @@ int pp_atomfwctrl_get_avfs_information(struct pp_hwmgr *hwmgr, | |||
286 | if (!profile) | 289 | if (!profile) |
287 | return -1; | 290 | return -1; |
288 | 291 | ||
289 | param->ulMaxVddc = le32_to_cpu(profile->maxvddc); | 292 | format_revision = ((struct atom_common_table_header *)profile)->format_revision; |
290 | param->ulMinVddc = le32_to_cpu(profile->minvddc); | 293 | content_revision = ((struct atom_common_table_header *)profile)->content_revision; |
291 | param->ulMeanNsigmaAcontant0 = | 294 | |
292 | le32_to_cpu(profile->avfs_meannsigma_acontant0); | 295 | if (format_revision == 4 && content_revision == 1) { |
293 | param->ulMeanNsigmaAcontant1 = | 296 | param->ulMaxVddc = le32_to_cpu(profile->maxvddc); |
294 | le32_to_cpu(profile->avfs_meannsigma_acontant1); | 297 | param->ulMinVddc = le32_to_cpu(profile->minvddc); |
295 | param->ulMeanNsigmaAcontant2 = | 298 | param->ulMeanNsigmaAcontant0 = |
296 | le32_to_cpu(profile->avfs_meannsigma_acontant2); | 299 | le32_to_cpu(profile->avfs_meannsigma_acontant0); |
297 | param->usMeanNsigmaDcTolSigma = | 300 | param->ulMeanNsigmaAcontant1 = |
298 | le16_to_cpu(profile->avfs_meannsigma_dc_tol_sigma); | 301 | le32_to_cpu(profile->avfs_meannsigma_acontant1); |
299 | param->usMeanNsigmaPlatformMean = | 302 | param->ulMeanNsigmaAcontant2 = |
300 | le16_to_cpu(profile->avfs_meannsigma_platform_mean); | 303 | le32_to_cpu(profile->avfs_meannsigma_acontant2); |
301 | param->usMeanNsigmaPlatformSigma = | 304 | param->usMeanNsigmaDcTolSigma = |
302 | le16_to_cpu(profile->avfs_meannsigma_platform_sigma); | 305 | le16_to_cpu(profile->avfs_meannsigma_dc_tol_sigma); |
303 | param->ulGbVdroopTableCksoffA0 = | 306 | param->usMeanNsigmaPlatformMean = |
304 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a0); | 307 | le16_to_cpu(profile->avfs_meannsigma_platform_mean); |
305 | param->ulGbVdroopTableCksoffA1 = | 308 | param->usMeanNsigmaPlatformSigma = |
306 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a1); | 309 | le16_to_cpu(profile->avfs_meannsigma_platform_sigma); |
307 | param->ulGbVdroopTableCksoffA2 = | 310 | param->ulGbVdroopTableCksoffA0 = |
308 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a2); | 311 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a0); |
309 | param->ulGbVdroopTableCksonA0 = | 312 | param->ulGbVdroopTableCksoffA1 = |
310 | le32_to_cpu(profile->gb_vdroop_table_ckson_a0); | 313 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a1); |
311 | param->ulGbVdroopTableCksonA1 = | 314 | param->ulGbVdroopTableCksoffA2 = |
312 | le32_to_cpu(profile->gb_vdroop_table_ckson_a1); | 315 | le32_to_cpu(profile->gb_vdroop_table_cksoff_a2); |
313 | param->ulGbVdroopTableCksonA2 = | 316 | param->ulGbVdroopTableCksonA0 = |
314 | le32_to_cpu(profile->gb_vdroop_table_ckson_a2); | 317 | le32_to_cpu(profile->gb_vdroop_table_ckson_a0); |
315 | param->ulGbFuseTableCksoffM1 = | 318 | param->ulGbVdroopTableCksonA1 = |
316 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m1); | 319 | le32_to_cpu(profile->gb_vdroop_table_ckson_a1); |
317 | param->ulGbFuseTableCksoffM2 = | 320 | param->ulGbVdroopTableCksonA2 = |
318 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m2); | 321 | le32_to_cpu(profile->gb_vdroop_table_ckson_a2); |
319 | param->ulGbFuseTableCksoffB = | 322 | param->ulGbFuseTableCksoffM1 = |
320 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_b); | 323 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m1); |
321 | param->ulGbFuseTableCksonM1 = | 324 | param->ulGbFuseTableCksoffM2 = |
322 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_m1); | 325 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_m2); |
323 | param->ulGbFuseTableCksonM2 = | 326 | param->ulGbFuseTableCksoffB = |
324 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_m2); | 327 | le32_to_cpu(profile->avfsgb_fuse_table_cksoff_b); |
325 | param->ulGbFuseTableCksonB = | 328 | param->ulGbFuseTableCksonM1 = |
326 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_b); | 329 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_m1); |
327 | 330 | param->ulGbFuseTableCksonM2 = | |
328 | param->ucEnableGbVdroopTableCkson = | 331 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_m2); |
329 | profile->enable_gb_vdroop_table_ckson; | 332 | param->ulGbFuseTableCksonB = |
330 | param->ucEnableGbFuseTableCkson = | 333 | le32_to_cpu(profile->avfsgb_fuse_table_ckson_b); |
331 | profile->enable_gb_fuse_table_ckson; | 334 | |
332 | param->usPsmAgeComfactor = | 335 | param->ucEnableGbVdroopTableCkson = |
333 | le16_to_cpu(profile->psm_age_comfactor); | 336 | profile->enable_gb_vdroop_table_ckson; |
334 | 337 | param->ucEnableGbFuseTableCkson = | |
335 | param->ulDispclk2GfxclkM1 = | 338 | profile->enable_gb_fuse_table_ckson; |
336 | le32_to_cpu(profile->dispclk2gfxclk_a); | 339 | param->usPsmAgeComfactor = |
337 | param->ulDispclk2GfxclkM2 = | 340 | le16_to_cpu(profile->psm_age_comfactor); |
338 | le32_to_cpu(profile->dispclk2gfxclk_b); | 341 | |
339 | param->ulDispclk2GfxclkB = | 342 | param->ulDispclk2GfxclkM1 = |
340 | le32_to_cpu(profile->dispclk2gfxclk_c); | 343 | le32_to_cpu(profile->dispclk2gfxclk_a); |
341 | param->ulDcefclk2GfxclkM1 = | 344 | param->ulDispclk2GfxclkM2 = |
342 | le32_to_cpu(profile->dcefclk2gfxclk_a); | 345 | le32_to_cpu(profile->dispclk2gfxclk_b); |
343 | param->ulDcefclk2GfxclkM2 = | 346 | param->ulDispclk2GfxclkB = |
344 | le32_to_cpu(profile->dcefclk2gfxclk_b); | 347 | le32_to_cpu(profile->dispclk2gfxclk_c); |
345 | param->ulDcefclk2GfxclkB = | 348 | param->ulDcefclk2GfxclkM1 = |
346 | le32_to_cpu(profile->dcefclk2gfxclk_c); | 349 | le32_to_cpu(profile->dcefclk2gfxclk_a); |
347 | param->ulPixelclk2GfxclkM1 = | 350 | param->ulDcefclk2GfxclkM2 = |
348 | le32_to_cpu(profile->pixclk2gfxclk_a); | 351 | le32_to_cpu(profile->dcefclk2gfxclk_b); |
349 | param->ulPixelclk2GfxclkM2 = | 352 | param->ulDcefclk2GfxclkB = |
350 | le32_to_cpu(profile->pixclk2gfxclk_b); | 353 | le32_to_cpu(profile->dcefclk2gfxclk_c); |
351 | param->ulPixelclk2GfxclkB = | 354 | param->ulPixelclk2GfxclkM1 = |
352 | le32_to_cpu(profile->pixclk2gfxclk_c); | 355 | le32_to_cpu(profile->pixclk2gfxclk_a); |
353 | param->ulPhyclk2GfxclkM1 = | 356 | param->ulPixelclk2GfxclkM2 = |
354 | le32_to_cpu(profile->phyclk2gfxclk_a); | 357 | le32_to_cpu(profile->pixclk2gfxclk_b); |
355 | param->ulPhyclk2GfxclkM2 = | 358 | param->ulPixelclk2GfxclkB = |
356 | le32_to_cpu(profile->phyclk2gfxclk_b); | 359 | le32_to_cpu(profile->pixclk2gfxclk_c); |
357 | param->ulPhyclk2GfxclkB = | 360 | param->ulPhyclk2GfxclkM1 = |
358 | le32_to_cpu(profile->phyclk2gfxclk_c); | 361 | le32_to_cpu(profile->phyclk2gfxclk_a); |
362 | param->ulPhyclk2GfxclkM2 = | ||
363 | le32_to_cpu(profile->phyclk2gfxclk_b); | ||
364 | param->ulPhyclk2GfxclkB = | ||
365 | le32_to_cpu(profile->phyclk2gfxclk_c); | ||
366 | param->ulAcgGbVdroopTableA0 = 0; | ||
367 | param->ulAcgGbVdroopTableA1 = 0; | ||
368 | param->ulAcgGbVdroopTableA2 = 0; | ||
369 | param->ulAcgGbFuseTableM1 = 0; | ||
370 | param->ulAcgGbFuseTableM2 = 0; | ||
371 | param->ulAcgGbFuseTableB = 0; | ||
372 | param->ucAcgEnableGbVdroopTable = 0; | ||
373 | param->ucAcgEnableGbFuseTable = 0; | ||
374 | } else if (format_revision == 4 && content_revision == 2) { | ||
375 | profile_v4_2 = (struct atom_asic_profiling_info_v4_2 *)profile; | ||
376 | param->ulMaxVddc = le32_to_cpu(profile_v4_2->maxvddc); | ||
377 | param->ulMinVddc = le32_to_cpu(profile_v4_2->minvddc); | ||
378 | param->ulMeanNsigmaAcontant0 = | ||
379 | le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant0); | ||
380 | param->ulMeanNsigmaAcontant1 = | ||
381 | le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant1); | ||
382 | param->ulMeanNsigmaAcontant2 = | ||
383 | le32_to_cpu(profile_v4_2->avfs_meannsigma_acontant2); | ||
384 | param->usMeanNsigmaDcTolSigma = | ||
385 | le16_to_cpu(profile_v4_2->avfs_meannsigma_dc_tol_sigma); | ||
386 | param->usMeanNsigmaPlatformMean = | ||
387 | le16_to_cpu(profile_v4_2->avfs_meannsigma_platform_mean); | ||
388 | param->usMeanNsigmaPlatformSigma = | ||
389 | le16_to_cpu(profile_v4_2->avfs_meannsigma_platform_sigma); | ||
390 | param->ulGbVdroopTableCksoffA0 = | ||
391 | le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a0); | ||
392 | param->ulGbVdroopTableCksoffA1 = | ||
393 | le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a1); | ||
394 | param->ulGbVdroopTableCksoffA2 = | ||
395 | le32_to_cpu(profile_v4_2->gb_vdroop_table_cksoff_a2); | ||
396 | param->ulGbVdroopTableCksonA0 = | ||
397 | le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a0); | ||
398 | param->ulGbVdroopTableCksonA1 = | ||
399 | le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a1); | ||
400 | param->ulGbVdroopTableCksonA2 = | ||
401 | le32_to_cpu(profile_v4_2->gb_vdroop_table_ckson_a2); | ||
402 | param->ulGbFuseTableCksoffM1 = | ||
403 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_m1); | ||
404 | param->ulGbFuseTableCksoffM2 = | ||
405 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_m2); | ||
406 | param->ulGbFuseTableCksoffB = | ||
407 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_cksoff_b); | ||
408 | param->ulGbFuseTableCksonM1 = | ||
409 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_m1); | ||
410 | param->ulGbFuseTableCksonM2 = | ||
411 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_m2); | ||
412 | param->ulGbFuseTableCksonB = | ||
413 | le32_to_cpu(profile_v4_2->avfsgb_fuse_table_ckson_b); | ||
414 | |||
415 | param->ucEnableGbVdroopTableCkson = | ||
416 | profile_v4_2->enable_gb_vdroop_table_ckson; | ||
417 | param->ucEnableGbFuseTableCkson = | ||
418 | profile_v4_2->enable_gb_fuse_table_ckson; | ||
419 | param->usPsmAgeComfactor = | ||
420 | le16_to_cpu(profile_v4_2->psm_age_comfactor); | ||
421 | |||
422 | param->ulDispclk2GfxclkM1 = | ||
423 | le32_to_cpu(profile_v4_2->dispclk2gfxclk_a); | ||
424 | param->ulDispclk2GfxclkM2 = | ||
425 | le32_to_cpu(profile_v4_2->dispclk2gfxclk_b); | ||
426 | param->ulDispclk2GfxclkB = | ||
427 | le32_to_cpu(profile_v4_2->dispclk2gfxclk_c); | ||
428 | param->ulDcefclk2GfxclkM1 = | ||
429 | le32_to_cpu(profile_v4_2->dcefclk2gfxclk_a); | ||
430 | param->ulDcefclk2GfxclkM2 = | ||
431 | le32_to_cpu(profile_v4_2->dcefclk2gfxclk_b); | ||
432 | param->ulDcefclk2GfxclkB = | ||
433 | le32_to_cpu(profile_v4_2->dcefclk2gfxclk_c); | ||
434 | param->ulPixelclk2GfxclkM1 = | ||
435 | le32_to_cpu(profile_v4_2->pixclk2gfxclk_a); | ||
436 | param->ulPixelclk2GfxclkM2 = | ||
437 | le32_to_cpu(profile_v4_2->pixclk2gfxclk_b); | ||
438 | param->ulPixelclk2GfxclkB = | ||
439 | le32_to_cpu(profile_v4_2->pixclk2gfxclk_c); | ||
440 | param->ulPhyclk2GfxclkM1 = | ||
441 | le32_to_cpu(profile->phyclk2gfxclk_a); | ||
442 | param->ulPhyclk2GfxclkM2 = | ||
443 | le32_to_cpu(profile_v4_2->phyclk2gfxclk_b); | ||
444 | param->ulPhyclk2GfxclkB = | ||
445 | le32_to_cpu(profile_v4_2->phyclk2gfxclk_c); | ||
446 | param->ulAcgGbVdroopTableA0 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a0); | ||
447 | param->ulAcgGbVdroopTableA1 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a1); | ||
448 | param->ulAcgGbVdroopTableA2 = le32_to_cpu(profile_v4_2->acg_gb_vdroop_table_a2); | ||
449 | param->ulAcgGbFuseTableM1 = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_m1); | ||
450 | param->ulAcgGbFuseTableM2 = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_m2); | ||
451 | param->ulAcgGbFuseTableB = le32_to_cpu(profile_v4_2->acg_avfsgb_fuse_table_b); | ||
452 | param->ucAcgEnableGbVdroopTable = le32_to_cpu(profile_v4_2->enable_acg_gb_vdroop_table); | ||
453 | param->ucAcgEnableGbFuseTable = le32_to_cpu(profile_v4_2->enable_acg_gb_fuse_table); | ||
454 | } else { | ||
455 | pr_info("Invalid VBIOS AVFS ProfilingInfo Revision!\n"); | ||
456 | return -EINVAL; | ||
457 | } | ||
359 | 458 | ||
360 | return 0; | 459 | return 0; |
361 | } | 460 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h index 81908b5cfd5f..8e6b1f0ddebc 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.h | |||
@@ -109,6 +109,14 @@ struct pp_atomfwctrl_avfs_parameters { | |||
109 | uint32_t ulPhyclk2GfxclkM1; | 109 | uint32_t ulPhyclk2GfxclkM1; |
110 | uint32_t ulPhyclk2GfxclkM2; | 110 | uint32_t ulPhyclk2GfxclkM2; |
111 | uint32_t ulPhyclk2GfxclkB; | 111 | uint32_t ulPhyclk2GfxclkB; |
112 | uint32_t ulAcgGbVdroopTableA0; | ||
113 | uint32_t ulAcgGbVdroopTableA1; | ||
114 | uint32_t ulAcgGbVdroopTableA2; | ||
115 | uint32_t ulAcgGbFuseTableM1; | ||
116 | uint32_t ulAcgGbFuseTableM2; | ||
117 | uint32_t ulAcgGbFuseTableB; | ||
118 | uint32_t ucAcgEnableGbVdroopTable; | ||
119 | uint32_t ucAcgEnableGbFuseTable; | ||
112 | }; | 120 | }; |
113 | 121 | ||
114 | struct pp_atomfwctrl_gpio_parameters { | 122 | struct pp_atomfwctrl_gpio_parameters { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index 1f01020ce3a9..f01cda93f178 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | |||
@@ -4630,6 +4630,15 @@ static int smu7_set_power_profile_state(struct pp_hwmgr *hwmgr, | |||
4630 | 4630 | ||
4631 | static int smu7_avfs_control(struct pp_hwmgr *hwmgr, bool enable) | 4631 | static int smu7_avfs_control(struct pp_hwmgr *hwmgr, bool enable) |
4632 | { | 4632 | { |
4633 | struct pp_smumgr *smumgr = (struct pp_smumgr *)(hwmgr->smumgr); | ||
4634 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); | ||
4635 | |||
4636 | if (smu_data == NULL) | ||
4637 | return -EINVAL; | ||
4638 | |||
4639 | if (smu_data->avfs.avfs_btc_status == AVFS_BTC_NOTSUPPORTED) | ||
4640 | return 0; | ||
4641 | |||
4633 | if (enable) { | 4642 | if (enable) { |
4634 | if (!PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, | 4643 | if (!PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, |
4635 | CGS_IND_REG__SMC, FEATURE_STATUS, AVS_ON)) | 4644 | CGS_IND_REG__SMC, FEATURE_STATUS, AVS_ON)) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index d6f097f44b6c..01ff5054041b 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | |||
@@ -78,6 +78,8 @@ uint32_t channel_number[] = {1, 2, 0, 4, 0, 8, 0, 16, 2}; | |||
78 | #define DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK 0x000000F0L | 78 | #define DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK 0x000000F0L |
79 | #define DF_CS_AON0_DramBaseAddress0__IntLvAddrSel_MASK 0x00000700L | 79 | #define DF_CS_AON0_DramBaseAddress0__IntLvAddrSel_MASK 0x00000700L |
80 | #define DF_CS_AON0_DramBaseAddress0__DramBaseAddr_MASK 0xFFFFF000L | 80 | #define DF_CS_AON0_DramBaseAddress0__DramBaseAddr_MASK 0xFFFFF000L |
81 | static int vega10_force_clock_level(struct pp_hwmgr *hwmgr, | ||
82 | enum pp_clock_type type, uint32_t mask); | ||
81 | 83 | ||
82 | const ULONG PhwVega10_Magic = (ULONG)(PHM_VIslands_Magic); | 84 | const ULONG PhwVega10_Magic = (ULONG)(PHM_VIslands_Magic); |
83 | 85 | ||
@@ -146,6 +148,19 @@ static void vega10_set_default_registry_data(struct pp_hwmgr *hwmgr) | |||
146 | data->registry_data.vr1hot_enabled = 1; | 148 | data->registry_data.vr1hot_enabled = 1; |
147 | data->registry_data.regulator_hot_gpio_support = 1; | 149 | data->registry_data.regulator_hot_gpio_support = 1; |
148 | 150 | ||
151 | data->registry_data.didt_support = 1; | ||
152 | if (data->registry_data.didt_support) { | ||
153 | data->registry_data.didt_mode = 6; | ||
154 | data->registry_data.sq_ramping_support = 1; | ||
155 | data->registry_data.db_ramping_support = 0; | ||
156 | data->registry_data.td_ramping_support = 0; | ||
157 | data->registry_data.tcp_ramping_support = 0; | ||
158 | data->registry_data.dbr_ramping_support = 0; | ||
159 | data->registry_data.edc_didt_support = 1; | ||
160 | data->registry_data.gc_didt_support = 0; | ||
161 | data->registry_data.psm_didt_support = 0; | ||
162 | } | ||
163 | |||
149 | data->display_voltage_mode = PPVEGA10_VEGA10DISPLAYVOLTAGEMODE_DFLT; | 164 | data->display_voltage_mode = PPVEGA10_VEGA10DISPLAYVOLTAGEMODE_DFLT; |
150 | data->dcef_clk_quad_eqn_a = PPREGKEY_VEGA10QUADRATICEQUATION_DFLT; | 165 | data->dcef_clk_quad_eqn_a = PPREGKEY_VEGA10QUADRATICEQUATION_DFLT; |
151 | data->dcef_clk_quad_eqn_b = PPREGKEY_VEGA10QUADRATICEQUATION_DFLT; | 166 | data->dcef_clk_quad_eqn_b = PPREGKEY_VEGA10QUADRATICEQUATION_DFLT; |
@@ -223,6 +238,8 @@ static int vega10_set_features_platform_caps(struct pp_hwmgr *hwmgr) | |||
223 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 238 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
224 | PHM_PlatformCaps_PowerContainment); | 239 | PHM_PlatformCaps_PowerContainment); |
225 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 240 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
241 | PHM_PlatformCaps_DiDtSupport); | ||
242 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
226 | PHM_PlatformCaps_SQRamping); | 243 | PHM_PlatformCaps_SQRamping); |
227 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 244 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
228 | PHM_PlatformCaps_DBRamping); | 245 | PHM_PlatformCaps_DBRamping); |
@@ -230,6 +247,34 @@ static int vega10_set_features_platform_caps(struct pp_hwmgr *hwmgr) | |||
230 | PHM_PlatformCaps_TDRamping); | 247 | PHM_PlatformCaps_TDRamping); |
231 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | 248 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
232 | PHM_PlatformCaps_TCPRamping); | 249 | PHM_PlatformCaps_TCPRamping); |
250 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
251 | PHM_PlatformCaps_DBRRamping); | ||
252 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
253 | PHM_PlatformCaps_DiDtEDCEnable); | ||
254 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
255 | PHM_PlatformCaps_GCEDC); | ||
256 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, | ||
257 | PHM_PlatformCaps_PSM); | ||
258 | |||
259 | if (data->registry_data.didt_support) { | ||
260 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DiDtSupport); | ||
261 | if (data->registry_data.sq_ramping_support) | ||
262 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SQRamping); | ||
263 | if (data->registry_data.db_ramping_support) | ||
264 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping); | ||
265 | if (data->registry_data.td_ramping_support) | ||
266 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping); | ||
267 | if (data->registry_data.tcp_ramping_support) | ||
268 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping); | ||
269 | if (data->registry_data.dbr_ramping_support) | ||
270 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRRamping); | ||
271 | if (data->registry_data.edc_didt_support) | ||
272 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DiDtEDCEnable); | ||
273 | if (data->registry_data.gc_didt_support) | ||
274 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_GCEDC); | ||
275 | if (data->registry_data.psm_didt_support) | ||
276 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PSM); | ||
277 | } | ||
233 | 278 | ||
234 | if (data->registry_data.power_containment_support) | 279 | if (data->registry_data.power_containment_support) |
235 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, | 280 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
@@ -321,8 +366,8 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) | |||
321 | FEATURE_LED_DISPLAY_BIT; | 366 | FEATURE_LED_DISPLAY_BIT; |
322 | data->smu_features[GNLD_FAN_CONTROL].smu_feature_id = | 367 | data->smu_features[GNLD_FAN_CONTROL].smu_feature_id = |
323 | FEATURE_FAN_CONTROL_BIT; | 368 | FEATURE_FAN_CONTROL_BIT; |
324 | data->smu_features[GNLD_VOLTAGE_CONTROLLER].smu_feature_id = | 369 | data->smu_features[GNLD_ACG].smu_feature_id = FEATURE_ACG_BIT; |
325 | FEATURE_VOLTAGE_CONTROLLER_BIT; | 370 | data->smu_features[GNLD_DIDT].smu_feature_id = FEATURE_GFX_EDC_BIT; |
326 | 371 | ||
327 | if (!data->registry_data.prefetcher_dpm_key_disabled) | 372 | if (!data->registry_data.prefetcher_dpm_key_disabled) |
328 | data->smu_features[GNLD_DPM_PREFETCHER].supported = true; | 373 | data->smu_features[GNLD_DPM_PREFETCHER].supported = true; |
@@ -386,6 +431,15 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) | |||
386 | if (data->registry_data.vr0hot_enabled) | 431 | if (data->registry_data.vr0hot_enabled) |
387 | data->smu_features[GNLD_VR0HOT].supported = true; | 432 | data->smu_features[GNLD_VR0HOT].supported = true; |
388 | 433 | ||
434 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_GetSmuVersion); | ||
435 | vega10_read_arg_from_smc(hwmgr->smumgr, &(data->smu_version)); | ||
436 | /* ACG firmware has major version 5 */ | ||
437 | if ((data->smu_version & 0xff000000) == 0x5000000) | ||
438 | data->smu_features[GNLD_ACG].supported = true; | ||
439 | |||
440 | if (data->registry_data.didt_support) | ||
441 | data->smu_features[GNLD_DIDT].supported = true; | ||
442 | |||
389 | } | 443 | } |
390 | 444 | ||
391 | #ifdef PPLIB_VEGA10_EVV_SUPPORT | 445 | #ifdef PPLIB_VEGA10_EVV_SUPPORT |
@@ -2128,15 +2182,9 @@ static int vega10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) | |||
2128 | pp_table->AvfsGbCksOff.m2_shift = 12; | 2182 | pp_table->AvfsGbCksOff.m2_shift = 12; |
2129 | pp_table->AvfsGbCksOff.b_shift = 0; | 2183 | pp_table->AvfsGbCksOff.b_shift = 0; |
2130 | 2184 | ||
2131 | for (i = 0; i < dep_table->count; i++) { | 2185 | for (i = 0; i < dep_table->count; i++) |
2132 | if (dep_table->entries[i].sclk_offset == 0) | 2186 | pp_table->StaticVoltageOffsetVid[i] = |
2133 | pp_table->StaticVoltageOffsetVid[i] = 248; | 2187 | convert_to_vid((uint8_t)(dep_table->entries[i].sclk_offset)); |
2134 | else | ||
2135 | pp_table->StaticVoltageOffsetVid[i] = | ||
2136 | (uint8_t)(dep_table->entries[i].sclk_offset * | ||
2137 | VOLTAGE_VID_OFFSET_SCALE2 / | ||
2138 | VOLTAGE_VID_OFFSET_SCALE1); | ||
2139 | } | ||
2140 | 2188 | ||
2141 | if ((PPREGKEY_VEGA10QUADRATICEQUATION_DFLT != | 2189 | if ((PPREGKEY_VEGA10QUADRATICEQUATION_DFLT != |
2142 | data->disp_clk_quad_eqn_a) && | 2190 | data->disp_clk_quad_eqn_a) && |
@@ -2228,6 +2276,21 @@ static int vega10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) | |||
2228 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].m1_shift = 24; | 2276 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].m1_shift = 24; |
2229 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].m2_shift = 12; | 2277 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].m2_shift = 12; |
2230 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].b_shift = 12; | 2278 | pp_table->DisplayClock2Gfxclk[DSPCLK_PHYCLK].b_shift = 12; |
2279 | |||
2280 | pp_table->AcgBtcGbVdroopTable.a0 = avfs_params.ulAcgGbVdroopTableA0; | ||
2281 | pp_table->AcgBtcGbVdroopTable.a0_shift = 20; | ||
2282 | pp_table->AcgBtcGbVdroopTable.a1 = avfs_params.ulAcgGbVdroopTableA1; | ||
2283 | pp_table->AcgBtcGbVdroopTable.a1_shift = 20; | ||
2284 | pp_table->AcgBtcGbVdroopTable.a2 = avfs_params.ulAcgGbVdroopTableA2; | ||
2285 | pp_table->AcgBtcGbVdroopTable.a2_shift = 20; | ||
2286 | |||
2287 | pp_table->AcgAvfsGb.m1 = avfs_params.ulAcgGbFuseTableM1; | ||
2288 | pp_table->AcgAvfsGb.m2 = avfs_params.ulAcgGbFuseTableM2; | ||
2289 | pp_table->AcgAvfsGb.b = avfs_params.ulAcgGbFuseTableB; | ||
2290 | pp_table->AcgAvfsGb.m1_shift = 0; | ||
2291 | pp_table->AcgAvfsGb.m2_shift = 0; | ||
2292 | pp_table->AcgAvfsGb.b_shift = 0; | ||
2293 | |||
2231 | } else { | 2294 | } else { |
2232 | data->smu_features[GNLD_AVFS].supported = false; | 2295 | data->smu_features[GNLD_AVFS].supported = false; |
2233 | } | 2296 | } |
@@ -2236,6 +2299,55 @@ static int vega10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) | |||
2236 | return 0; | 2299 | return 0; |
2237 | } | 2300 | } |
2238 | 2301 | ||
2302 | static int vega10_acg_enable(struct pp_hwmgr *hwmgr) | ||
2303 | { | ||
2304 | struct vega10_hwmgr *data = | ||
2305 | (struct vega10_hwmgr *)(hwmgr->backend); | ||
2306 | uint32_t agc_btc_response; | ||
2307 | |||
2308 | if (data->smu_features[GNLD_ACG].supported) { | ||
2309 | if (0 == vega10_enable_smc_features(hwmgr->smumgr, true, | ||
2310 | data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_bitmap)) | ||
2311 | data->smu_features[GNLD_DPM_PREFETCHER].enabled = true; | ||
2312 | |||
2313 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_InitializeAcg); | ||
2314 | |||
2315 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_RunAcgBtc); | ||
2316 | vega10_read_arg_from_smc(hwmgr->smumgr, &agc_btc_response);; | ||
2317 | |||
2318 | if (1 == agc_btc_response) { | ||
2319 | if (1 == data->acg_loop_state) | ||
2320 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_RunAcgInClosedLoop); | ||
2321 | else if (2 == data->acg_loop_state) | ||
2322 | smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_MSG_RunAcgInOpenLoop); | ||
2323 | if (0 == vega10_enable_smc_features(hwmgr->smumgr, true, | ||
2324 | data->smu_features[GNLD_ACG].smu_feature_bitmap)) | ||
2325 | data->smu_features[GNLD_ACG].enabled = true; | ||
2326 | } else { | ||
2327 | pr_info("[ACG_Enable] ACG BTC Returned Failed Status!\n"); | ||
2328 | data->smu_features[GNLD_ACG].enabled = false; | ||
2329 | } | ||
2330 | } | ||
2331 | |||
2332 | return 0; | ||
2333 | } | ||
2334 | |||
2335 | static int vega10_acg_disable(struct pp_hwmgr *hwmgr) | ||
2336 | { | ||
2337 | struct vega10_hwmgr *data = | ||
2338 | (struct vega10_hwmgr *)(hwmgr->backend); | ||
2339 | |||
2340 | if (data->smu_features[GNLD_ACG].supported) { | ||
2341 | if (data->smu_features[GNLD_ACG].enabled) { | ||
2342 | if (0 == vega10_enable_smc_features(hwmgr->smumgr, false, | ||
2343 | data->smu_features[GNLD_ACG].smu_feature_bitmap)) | ||
2344 | data->smu_features[GNLD_ACG].enabled = false; | ||
2345 | } | ||
2346 | } | ||
2347 | |||
2348 | return 0; | ||
2349 | } | ||
2350 | |||
2239 | static int vega10_populate_gpio_parameters(struct pp_hwmgr *hwmgr) | 2351 | static int vega10_populate_gpio_parameters(struct pp_hwmgr *hwmgr) |
2240 | { | 2352 | { |
2241 | struct vega10_hwmgr *data = | 2353 | struct vega10_hwmgr *data = |
@@ -2506,7 +2618,7 @@ static int vega10_init_smc_table(struct pp_hwmgr *hwmgr) | |||
2506 | result = vega10_avfs_enable(hwmgr, true); | 2618 | result = vega10_avfs_enable(hwmgr, true); |
2507 | PP_ASSERT_WITH_CODE(!result, "Attempt to enable AVFS feature Failed!", | 2619 | PP_ASSERT_WITH_CODE(!result, "Attempt to enable AVFS feature Failed!", |
2508 | return result); | 2620 | return result); |
2509 | 2621 | vega10_acg_enable(hwmgr); | |
2510 | vega10_save_default_power_profile(hwmgr); | 2622 | vega10_save_default_power_profile(hwmgr); |
2511 | 2623 | ||
2512 | return 0; | 2624 | return 0; |
@@ -2838,6 +2950,11 @@ static int vega10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
2838 | PP_ASSERT_WITH_CODE(!tmp_result, | 2950 | PP_ASSERT_WITH_CODE(!tmp_result, |
2839 | "Failed to start DPM!", result = tmp_result); | 2951 | "Failed to start DPM!", result = tmp_result); |
2840 | 2952 | ||
2953 | /* enable didt, do not abort if failed didt */ | ||
2954 | tmp_result = vega10_enable_didt_config(hwmgr); | ||
2955 | PP_ASSERT(!tmp_result, | ||
2956 | "Failed to enable didt config!"); | ||
2957 | |||
2841 | tmp_result = vega10_enable_power_containment(hwmgr); | 2958 | tmp_result = vega10_enable_power_containment(hwmgr); |
2842 | PP_ASSERT_WITH_CODE(!tmp_result, | 2959 | PP_ASSERT_WITH_CODE(!tmp_result, |
2843 | "Failed to enable power containment!", | 2960 | "Failed to enable power containment!", |
@@ -4103,34 +4220,30 @@ static int vega10_unforce_dpm_levels(struct pp_hwmgr *hwmgr) | |||
4103 | return 0; | 4220 | return 0; |
4104 | } | 4221 | } |
4105 | 4222 | ||
4106 | static int vega10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | 4223 | static int vega10_get_profiling_clk_mask(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level, |
4107 | enum amd_dpm_forced_level level) | 4224 | uint32_t *sclk_mask, uint32_t *mclk_mask, uint32_t *soc_mask) |
4108 | { | 4225 | { |
4109 | int ret = 0; | 4226 | struct phm_ppt_v2_information *table_info = |
4227 | (struct phm_ppt_v2_information *)(hwmgr->pptable); | ||
4110 | 4228 | ||
4111 | switch (level) { | 4229 | if (table_info->vdd_dep_on_sclk->count > VEGA10_UMD_PSTATE_GFXCLK_LEVEL && |
4112 | case AMD_DPM_FORCED_LEVEL_HIGH: | 4230 | table_info->vdd_dep_on_socclk->count > VEGA10_UMD_PSTATE_SOCCLK_LEVEL && |
4113 | ret = vega10_force_dpm_highest(hwmgr); | 4231 | table_info->vdd_dep_on_mclk->count > VEGA10_UMD_PSTATE_MCLK_LEVEL) { |
4114 | if (ret) | 4232 | *sclk_mask = VEGA10_UMD_PSTATE_GFXCLK_LEVEL; |
4115 | return ret; | 4233 | *soc_mask = VEGA10_UMD_PSTATE_SOCCLK_LEVEL; |
4116 | break; | 4234 | *mclk_mask = VEGA10_UMD_PSTATE_MCLK_LEVEL; |
4117 | case AMD_DPM_FORCED_LEVEL_LOW: | ||
4118 | ret = vega10_force_dpm_lowest(hwmgr); | ||
4119 | if (ret) | ||
4120 | return ret; | ||
4121 | break; | ||
4122 | case AMD_DPM_FORCED_LEVEL_AUTO: | ||
4123 | ret = vega10_unforce_dpm_levels(hwmgr); | ||
4124 | if (ret) | ||
4125 | return ret; | ||
4126 | break; | ||
4127 | default: | ||
4128 | break; | ||
4129 | } | 4235 | } |
4130 | 4236 | ||
4131 | hwmgr->dpm_level = level; | 4237 | if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) { |
4132 | 4238 | *sclk_mask = 0; | |
4133 | return ret; | 4239 | } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) { |
4240 | *mclk_mask = 0; | ||
4241 | } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) { | ||
4242 | *sclk_mask = table_info->vdd_dep_on_sclk->count - 1; | ||
4243 | *soc_mask = table_info->vdd_dep_on_socclk->count - 1; | ||
4244 | *mclk_mask = table_info->vdd_dep_on_mclk->count - 1; | ||
4245 | } | ||
4246 | return 0; | ||
4134 | } | 4247 | } |
4135 | 4248 | ||
4136 | static int vega10_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode) | 4249 | static int vega10_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode) |
@@ -4157,6 +4270,86 @@ static int vega10_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode) | |||
4157 | return result; | 4270 | return result; |
4158 | } | 4271 | } |
4159 | 4272 | ||
4273 | static int vega10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | ||
4274 | enum amd_dpm_forced_level level) | ||
4275 | { | ||
4276 | int ret = 0; | ||
4277 | uint32_t sclk_mask = 0; | ||
4278 | uint32_t mclk_mask = 0; | ||
4279 | uint32_t soc_mask = 0; | ||
4280 | uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD | | ||
4281 | AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK | | ||
4282 | AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK | | ||
4283 | AMD_DPM_FORCED_LEVEL_PROFILE_PEAK; | ||
4284 | |||
4285 | if (level == hwmgr->dpm_level) | ||
4286 | return ret; | ||
4287 | |||
4288 | if (!(hwmgr->dpm_level & profile_mode_mask)) { | ||
4289 | /* enter profile mode, save current level, disable gfx cg*/ | ||
4290 | if (level & profile_mode_mask) { | ||
4291 | hwmgr->saved_dpm_level = hwmgr->dpm_level; | ||
4292 | cgs_set_clockgating_state(hwmgr->device, | ||
4293 | AMD_IP_BLOCK_TYPE_GFX, | ||
4294 | AMD_CG_STATE_UNGATE); | ||
4295 | } | ||
4296 | } else { | ||
4297 | /* exit profile mode, restore level, enable gfx cg*/ | ||
4298 | if (!(level & profile_mode_mask)) { | ||
4299 | if (level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT) | ||
4300 | level = hwmgr->saved_dpm_level; | ||
4301 | cgs_set_clockgating_state(hwmgr->device, | ||
4302 | AMD_IP_BLOCK_TYPE_GFX, | ||
4303 | AMD_CG_STATE_GATE); | ||
4304 | } | ||
4305 | } | ||
4306 | |||
4307 | switch (level) { | ||
4308 | case AMD_DPM_FORCED_LEVEL_HIGH: | ||
4309 | ret = vega10_force_dpm_highest(hwmgr); | ||
4310 | if (ret) | ||
4311 | return ret; | ||
4312 | hwmgr->dpm_level = level; | ||
4313 | break; | ||
4314 | case AMD_DPM_FORCED_LEVEL_LOW: | ||
4315 | ret = vega10_force_dpm_lowest(hwmgr); | ||
4316 | if (ret) | ||
4317 | return ret; | ||
4318 | hwmgr->dpm_level = level; | ||
4319 | break; | ||
4320 | case AMD_DPM_FORCED_LEVEL_AUTO: | ||
4321 | ret = vega10_unforce_dpm_levels(hwmgr); | ||
4322 | if (ret) | ||
4323 | return ret; | ||
4324 | hwmgr->dpm_level = level; | ||
4325 | break; | ||
4326 | case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: | ||
4327 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: | ||
4328 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK: | ||
4329 | case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: | ||
4330 | ret = vega10_get_profiling_clk_mask(hwmgr, level, &sclk_mask, &mclk_mask, &soc_mask); | ||
4331 | if (ret) | ||
4332 | return ret; | ||
4333 | hwmgr->dpm_level = level; | ||
4334 | vega10_force_clock_level(hwmgr, PP_SCLK, 1<<sclk_mask); | ||
4335 | vega10_force_clock_level(hwmgr, PP_MCLK, 1<<mclk_mask); | ||
4336 | break; | ||
4337 | case AMD_DPM_FORCED_LEVEL_MANUAL: | ||
4338 | hwmgr->dpm_level = level; | ||
4339 | break; | ||
4340 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: | ||
4341 | default: | ||
4342 | break; | ||
4343 | } | ||
4344 | |||
4345 | if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && hwmgr->saved_dpm_level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) | ||
4346 | vega10_set_fan_control_mode(hwmgr, AMD_FAN_CTRL_NONE); | ||
4347 | else if (level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && hwmgr->saved_dpm_level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) | ||
4348 | vega10_set_fan_control_mode(hwmgr, AMD_FAN_CTRL_AUTO); | ||
4349 | |||
4350 | return 0; | ||
4351 | } | ||
4352 | |||
4160 | static int vega10_get_fan_control_mode(struct pp_hwmgr *hwmgr) | 4353 | static int vega10_get_fan_control_mode(struct pp_hwmgr *hwmgr) |
4161 | { | 4354 | { |
4162 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); | 4355 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); |
@@ -4402,7 +4595,9 @@ static int vega10_force_clock_level(struct pp_hwmgr *hwmgr, | |||
4402 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); | 4595 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); |
4403 | int i; | 4596 | int i; |
4404 | 4597 | ||
4405 | if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) | 4598 | if (hwmgr->dpm_level & (AMD_DPM_FORCED_LEVEL_AUTO | |
4599 | AMD_DPM_FORCED_LEVEL_LOW | | ||
4600 | AMD_DPM_FORCED_LEVEL_HIGH)) | ||
4406 | return -EINVAL; | 4601 | return -EINVAL; |
4407 | 4602 | ||
4408 | switch (type) { | 4603 | switch (type) { |
@@ -4667,6 +4862,10 @@ static int vega10_disable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
4667 | PP_ASSERT_WITH_CODE((tmp_result == 0), | 4862 | PP_ASSERT_WITH_CODE((tmp_result == 0), |
4668 | "Failed to disable power containment!", result = tmp_result); | 4863 | "Failed to disable power containment!", result = tmp_result); |
4669 | 4864 | ||
4865 | tmp_result = vega10_disable_didt_config(hwmgr); | ||
4866 | PP_ASSERT_WITH_CODE((tmp_result == 0), | ||
4867 | "Failed to disable didt config!", result = tmp_result); | ||
4868 | |||
4670 | tmp_result = vega10_avfs_enable(hwmgr, false); | 4869 | tmp_result = vega10_avfs_enable(hwmgr, false); |
4671 | PP_ASSERT_WITH_CODE((tmp_result == 0), | 4870 | PP_ASSERT_WITH_CODE((tmp_result == 0), |
4672 | "Failed to disable AVFS!", result = tmp_result); | 4871 | "Failed to disable AVFS!", result = tmp_result); |
@@ -4683,6 +4882,9 @@ static int vega10_disable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
4683 | PP_ASSERT_WITH_CODE((tmp_result == 0), | 4882 | PP_ASSERT_WITH_CODE((tmp_result == 0), |
4684 | "Failed to disable ulv!", result = tmp_result); | 4883 | "Failed to disable ulv!", result = tmp_result); |
4685 | 4884 | ||
4885 | tmp_result = vega10_acg_disable(hwmgr); | ||
4886 | PP_ASSERT_WITH_CODE((tmp_result == 0), | ||
4887 | "Failed to disable acg!", result = tmp_result); | ||
4686 | return result; | 4888 | return result; |
4687 | } | 4889 | } |
4688 | 4890 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h index 6e5c5b99593b..676cd7735883 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h | |||
@@ -64,7 +64,9 @@ enum { | |||
64 | GNLD_FW_CTF, | 64 | GNLD_FW_CTF, |
65 | GNLD_LED_DISPLAY, | 65 | GNLD_LED_DISPLAY, |
66 | GNLD_FAN_CONTROL, | 66 | GNLD_FAN_CONTROL, |
67 | GNLD_VOLTAGE_CONTROLLER, | 67 | GNLD_FEATURE_FAST_PPT_BIT, |
68 | GNLD_DIDT, | ||
69 | GNLD_ACG, | ||
68 | GNLD_FEATURES_MAX | 70 | GNLD_FEATURES_MAX |
69 | }; | 71 | }; |
70 | 72 | ||
@@ -230,7 +232,9 @@ struct vega10_registry_data { | |||
230 | uint8_t cac_support; | 232 | uint8_t cac_support; |
231 | uint8_t clock_stretcher_support; | 233 | uint8_t clock_stretcher_support; |
232 | uint8_t db_ramping_support; | 234 | uint8_t db_ramping_support; |
235 | uint8_t didt_mode; | ||
233 | uint8_t didt_support; | 236 | uint8_t didt_support; |
237 | uint8_t edc_didt_support; | ||
234 | uint8_t dynamic_state_patching_support; | 238 | uint8_t dynamic_state_patching_support; |
235 | uint8_t enable_pkg_pwr_tracking_feature; | 239 | uint8_t enable_pkg_pwr_tracking_feature; |
236 | uint8_t enable_tdc_limit_feature; | 240 | uint8_t enable_tdc_limit_feature; |
@@ -263,6 +267,9 @@ struct vega10_registry_data { | |||
263 | uint8_t tcp_ramping_support; | 267 | uint8_t tcp_ramping_support; |
264 | uint8_t tdc_support; | 268 | uint8_t tdc_support; |
265 | uint8_t td_ramping_support; | 269 | uint8_t td_ramping_support; |
270 | uint8_t dbr_ramping_support; | ||
271 | uint8_t gc_didt_support; | ||
272 | uint8_t psm_didt_support; | ||
266 | uint8_t thermal_out_gpio_support; | 273 | uint8_t thermal_out_gpio_support; |
267 | uint8_t thermal_support; | 274 | uint8_t thermal_support; |
268 | uint8_t fw_ctf_enabled; | 275 | uint8_t fw_ctf_enabled; |
@@ -381,6 +388,8 @@ struct vega10_hwmgr { | |||
381 | struct vega10_smc_state_table smc_state_table; | 388 | struct vega10_smc_state_table smc_state_table; |
382 | 389 | ||
383 | uint32_t config_telemetry; | 390 | uint32_t config_telemetry; |
391 | uint32_t smu_version; | ||
392 | uint32_t acg_loop_state; | ||
384 | }; | 393 | }; |
385 | 394 | ||
386 | #define VEGA10_DPM2_NEAR_TDP_DEC 10 | 395 | #define VEGA10_DPM2_NEAR_TDP_DEC 10 |
@@ -425,6 +434,10 @@ struct vega10_hwmgr { | |||
425 | #define PPVEGA10_VEGA10UCLKCLKAVERAGEALPHA_DFLT 25 /* 10% * 255 = 25 */ | 434 | #define PPVEGA10_VEGA10UCLKCLKAVERAGEALPHA_DFLT 25 /* 10% * 255 = 25 */ |
426 | #define PPVEGA10_VEGA10GFXACTIVITYAVERAGEALPHA_DFLT 25 /* 10% * 255 = 25 */ | 435 | #define PPVEGA10_VEGA10GFXACTIVITYAVERAGEALPHA_DFLT 25 /* 10% * 255 = 25 */ |
427 | 436 | ||
437 | #define VEGA10_UMD_PSTATE_GFXCLK_LEVEL 0x3 | ||
438 | #define VEGA10_UMD_PSTATE_SOCCLK_LEVEL 0x3 | ||
439 | #define VEGA10_UMD_PSTATE_MCLK_LEVEL 0x2 | ||
440 | |||
428 | extern int tonga_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); | 441 | extern int tonga_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); |
429 | extern int tonga_hwmgr_backend_fini(struct pp_hwmgr *hwmgr); | 442 | extern int tonga_hwmgr_backend_fini(struct pp_hwmgr *hwmgr); |
430 | extern int tonga_get_mc_microcode_version (struct pp_hwmgr *hwmgr); | 443 | extern int tonga_get_mc_microcode_version (struct pp_hwmgr *hwmgr); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c index 3f72268e99bb..fbafc849ea71 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c | |||
@@ -26,7 +26,1298 @@ | |||
26 | #include "vega10_powertune.h" | 26 | #include "vega10_powertune.h" |
27 | #include "vega10_smumgr.h" | 27 | #include "vega10_smumgr.h" |
28 | #include "vega10_ppsmc.h" | 28 | #include "vega10_ppsmc.h" |
29 | #include "vega10_inc.h" | ||
29 | #include "pp_debug.h" | 30 | #include "pp_debug.h" |
31 | #include "pp_soc15.h" | ||
32 | |||
33 | static const struct vega10_didt_config_reg SEDiDtTuningCtrlConfig_Vega10[] = | ||
34 | { | ||
35 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
36 | * Offset Mask Shift Value | ||
37 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
38 | */ | ||
39 | /* DIDT_SQ */ | ||
40 | { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x3853 }, | ||
41 | { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3153 }, | ||
42 | |||
43 | /* DIDT_TD */ | ||
44 | { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x0dde }, | ||
45 | { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x0dde }, | ||
46 | |||
47 | /* DIDT_TCP */ | ||
48 | { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x3dde }, | ||
49 | { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3dde }, | ||
50 | |||
51 | /* DIDT_DB */ | ||
52 | { ixDIDT_DB_TUNING_CTRL, DIDT_DB_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_DB_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x3dde }, | ||
53 | { ixDIDT_DB_TUNING_CTRL, DIDT_DB_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_DB_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3dde }, | ||
54 | |||
55 | { 0xFFFFFFFF } /* End of list */ | ||
56 | }; | ||
57 | |||
58 | static const struct vega10_didt_config_reg SEDiDtCtrl3Config_vega10[] = | ||
59 | { | ||
60 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
61 | * Offset Mask Shift Value | ||
62 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
63 | */ | ||
64 | /*DIDT_SQ_CTRL3 */ | ||
65 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__GC_DIDT_ENABLE_MASK, DIDT_SQ_CTRL3__GC_DIDT_ENABLE__SHIFT, 0x0000 }, | ||
66 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__GC_DIDT_CLK_EN_OVERRIDE_MASK, DIDT_SQ_CTRL3__GC_DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
67 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__THROTTLE_POLICY_MASK, DIDT_SQ_CTRL3__THROTTLE_POLICY__SHIFT, 0x0003 }, | ||
68 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
69 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_POWER_LEVEL_LOWBIT_MASK, DIDT_SQ_CTRL3__DIDT_POWER_LEVEL_LOWBIT__SHIFT, 0x0000 }, | ||
70 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0003 }, | ||
71 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__GC_DIDT_LEVEL_COMB_EN_MASK, DIDT_SQ_CTRL3__GC_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
72 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__SE_DIDT_LEVEL_COMB_EN_MASK, DIDT_SQ_CTRL3__SE_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
73 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__QUALIFY_STALL_EN_MASK, DIDT_SQ_CTRL3__QUALIFY_STALL_EN__SHIFT, 0x0000 }, | ||
74 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_STALL_SEL_MASK, DIDT_SQ_CTRL3__DIDT_STALL_SEL__SHIFT, 0x0000 }, | ||
75 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_FORCE_STALL_MASK, DIDT_SQ_CTRL3__DIDT_FORCE_STALL__SHIFT, 0x0000 }, | ||
76 | { ixDIDT_SQ_CTRL3, DIDT_SQ_CTRL3__DIDT_STALL_DELAY_EN_MASK, DIDT_SQ_CTRL3__DIDT_STALL_DELAY_EN__SHIFT, 0x0000 }, | ||
77 | |||
78 | /*DIDT_TCP_CTRL3 */ | ||
79 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__GC_DIDT_ENABLE_MASK, DIDT_TCP_CTRL3__GC_DIDT_ENABLE__SHIFT, 0x0000 }, | ||
80 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__GC_DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TCP_CTRL3__GC_DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
81 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__THROTTLE_POLICY_MASK, DIDT_TCP_CTRL3__THROTTLE_POLICY__SHIFT, 0x0003 }, | ||
82 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_TCP_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
83 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_POWER_LEVEL_LOWBIT_MASK, DIDT_TCP_CTRL3__DIDT_POWER_LEVEL_LOWBIT__SHIFT, 0x0000 }, | ||
84 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS_MASK, DIDT_TCP_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0003 }, | ||
85 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__GC_DIDT_LEVEL_COMB_EN_MASK, DIDT_TCP_CTRL3__GC_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
86 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__SE_DIDT_LEVEL_COMB_EN_MASK, DIDT_TCP_CTRL3__SE_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
87 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__QUALIFY_STALL_EN_MASK, DIDT_TCP_CTRL3__QUALIFY_STALL_EN__SHIFT, 0x0000 }, | ||
88 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_STALL_SEL_MASK, DIDT_TCP_CTRL3__DIDT_STALL_SEL__SHIFT, 0x0000 }, | ||
89 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_FORCE_STALL_MASK, DIDT_TCP_CTRL3__DIDT_FORCE_STALL__SHIFT, 0x0000 }, | ||
90 | { ixDIDT_TCP_CTRL3, DIDT_TCP_CTRL3__DIDT_STALL_DELAY_EN_MASK, DIDT_TCP_CTRL3__DIDT_STALL_DELAY_EN__SHIFT, 0x0000 }, | ||
91 | |||
92 | /*DIDT_TD_CTRL3 */ | ||
93 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__GC_DIDT_ENABLE_MASK, DIDT_TD_CTRL3__GC_DIDT_ENABLE__SHIFT, 0x0000 }, | ||
94 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__GC_DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TD_CTRL3__GC_DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
95 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__THROTTLE_POLICY_MASK, DIDT_TD_CTRL3__THROTTLE_POLICY__SHIFT, 0x0003 }, | ||
96 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_TD_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
97 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_POWER_LEVEL_LOWBIT_MASK, DIDT_TD_CTRL3__DIDT_POWER_LEVEL_LOWBIT__SHIFT, 0x0000 }, | ||
98 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS_MASK, DIDT_TD_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0003 }, | ||
99 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__GC_DIDT_LEVEL_COMB_EN_MASK, DIDT_TD_CTRL3__GC_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
100 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__SE_DIDT_LEVEL_COMB_EN_MASK, DIDT_TD_CTRL3__SE_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
101 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__QUALIFY_STALL_EN_MASK, DIDT_TD_CTRL3__QUALIFY_STALL_EN__SHIFT, 0x0000 }, | ||
102 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_STALL_SEL_MASK, DIDT_TD_CTRL3__DIDT_STALL_SEL__SHIFT, 0x0000 }, | ||
103 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_FORCE_STALL_MASK, DIDT_TD_CTRL3__DIDT_FORCE_STALL__SHIFT, 0x0000 }, | ||
104 | { ixDIDT_TD_CTRL3, DIDT_TD_CTRL3__DIDT_STALL_DELAY_EN_MASK, DIDT_TD_CTRL3__DIDT_STALL_DELAY_EN__SHIFT, 0x0000 }, | ||
105 | |||
106 | /*DIDT_DB_CTRL3 */ | ||
107 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__GC_DIDT_ENABLE_MASK, DIDT_DB_CTRL3__GC_DIDT_ENABLE__SHIFT, 0x0000 }, | ||
108 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__GC_DIDT_CLK_EN_OVERRIDE_MASK, DIDT_DB_CTRL3__GC_DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
109 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__THROTTLE_POLICY_MASK, DIDT_DB_CTRL3__THROTTLE_POLICY__SHIFT, 0x0003 }, | ||
110 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_DB_CTRL3__DIDT_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
111 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_POWER_LEVEL_LOWBIT_MASK, DIDT_DB_CTRL3__DIDT_POWER_LEVEL_LOWBIT__SHIFT, 0x0000 }, | ||
112 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS_MASK, DIDT_DB_CTRL3__DIDT_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0003 }, | ||
113 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__GC_DIDT_LEVEL_COMB_EN_MASK, DIDT_DB_CTRL3__GC_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
114 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__SE_DIDT_LEVEL_COMB_EN_MASK, DIDT_DB_CTRL3__SE_DIDT_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
115 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__QUALIFY_STALL_EN_MASK, DIDT_DB_CTRL3__QUALIFY_STALL_EN__SHIFT, 0x0000 }, | ||
116 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_STALL_SEL_MASK, DIDT_DB_CTRL3__DIDT_STALL_SEL__SHIFT, 0x0000 }, | ||
117 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_FORCE_STALL_MASK, DIDT_DB_CTRL3__DIDT_FORCE_STALL__SHIFT, 0x0000 }, | ||
118 | { ixDIDT_DB_CTRL3, DIDT_DB_CTRL3__DIDT_STALL_DELAY_EN_MASK, DIDT_DB_CTRL3__DIDT_STALL_DELAY_EN__SHIFT, 0x0000 }, | ||
119 | |||
120 | { 0xFFFFFFFF } /* End of list */ | ||
121 | }; | ||
122 | |||
123 | static const struct vega10_didt_config_reg SEDiDtCtrl2Config_Vega10[] = | ||
124 | { | ||
125 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
126 | * Offset Mask Shift Value | ||
127 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
128 | */ | ||
129 | /* DIDT_SQ */ | ||
130 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__MAX_POWER_DELTA_MASK, DIDT_SQ_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3853 }, | ||
131 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x00c0 }, | ||
132 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0000 }, | ||
133 | |||
134 | /* DIDT_TD */ | ||
135 | { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__MAX_POWER_DELTA_MASK, DIDT_TD_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3fff }, | ||
136 | { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_TD_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x00c0 }, | ||
137 | { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_TD_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0001 }, | ||
138 | |||
139 | /* DIDT_TCP */ | ||
140 | { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__MAX_POWER_DELTA_MASK, DIDT_TCP_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3dde }, | ||
141 | { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_TCP_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x00c0 }, | ||
142 | { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_TCP_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0001 }, | ||
143 | |||
144 | /* DIDT_DB */ | ||
145 | { ixDIDT_DB_CTRL2, DIDT_DB_CTRL2__MAX_POWER_DELTA_MASK, DIDT_DB_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3dde }, | ||
146 | { ixDIDT_DB_CTRL2, DIDT_DB_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_DB_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x00c0 }, | ||
147 | { ixDIDT_DB_CTRL2, DIDT_DB_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_DB_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0001 }, | ||
148 | |||
149 | { 0xFFFFFFFF } /* End of list */ | ||
150 | }; | ||
151 | |||
152 | static const struct vega10_didt_config_reg SEDiDtCtrl1Config_Vega10[] = | ||
153 | { | ||
154 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
155 | * Offset Mask Shift Value | ||
156 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
157 | */ | ||
158 | /* DIDT_SQ */ | ||
159 | { ixDIDT_SQ_CTRL1, DIDT_SQ_CTRL1__MIN_POWER_MASK, DIDT_SQ_CTRL1__MIN_POWER__SHIFT, 0x0000 }, | ||
160 | { ixDIDT_SQ_CTRL1, DIDT_SQ_CTRL1__MAX_POWER_MASK, DIDT_SQ_CTRL1__MAX_POWER__SHIFT, 0xffff }, | ||
161 | /* DIDT_TD */ | ||
162 | { ixDIDT_TD_CTRL1, DIDT_TD_CTRL1__MIN_POWER_MASK, DIDT_TD_CTRL1__MIN_POWER__SHIFT, 0x0000 }, | ||
163 | { ixDIDT_TD_CTRL1, DIDT_TD_CTRL1__MAX_POWER_MASK, DIDT_TD_CTRL1__MAX_POWER__SHIFT, 0xffff }, | ||
164 | /* DIDT_TCP */ | ||
165 | { ixDIDT_TCP_CTRL1, DIDT_TCP_CTRL1__MIN_POWER_MASK, DIDT_TCP_CTRL1__MIN_POWER__SHIFT, 0x0000 }, | ||
166 | { ixDIDT_TCP_CTRL1, DIDT_TCP_CTRL1__MAX_POWER_MASK, DIDT_TCP_CTRL1__MAX_POWER__SHIFT, 0xffff }, | ||
167 | /* DIDT_DB */ | ||
168 | { ixDIDT_DB_CTRL1, DIDT_DB_CTRL1__MIN_POWER_MASK, DIDT_DB_CTRL1__MIN_POWER__SHIFT, 0x0000 }, | ||
169 | { ixDIDT_DB_CTRL1, DIDT_DB_CTRL1__MAX_POWER_MASK, DIDT_DB_CTRL1__MAX_POWER__SHIFT, 0xffff }, | ||
170 | |||
171 | { 0xFFFFFFFF } /* End of list */ | ||
172 | }; | ||
173 | |||
174 | |||
175 | static const struct vega10_didt_config_reg SEDiDtWeightConfig_Vega10[] = | ||
176 | { | ||
177 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
178 | * Offset Mask Shift Value | ||
179 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
180 | */ | ||
181 | /* DIDT_SQ */ | ||
182 | { ixDIDT_SQ_WEIGHT0_3, 0xFFFFFFFF, 0, 0x2B363B1A }, | ||
183 | { ixDIDT_SQ_WEIGHT4_7, 0xFFFFFFFF, 0, 0x270B2432 }, | ||
184 | { ixDIDT_SQ_WEIGHT8_11, 0xFFFFFFFF, 0, 0x00000018 }, | ||
185 | |||
186 | /* DIDT_TD */ | ||
187 | { ixDIDT_TD_WEIGHT0_3, 0xFFFFFFFF, 0, 0x2B1D220F }, | ||
188 | { ixDIDT_TD_WEIGHT4_7, 0xFFFFFFFF, 0, 0x00007558 }, | ||
189 | { ixDIDT_TD_WEIGHT8_11, 0xFFFFFFFF, 0, 0x00000000 }, | ||
190 | |||
191 | /* DIDT_TCP */ | ||
192 | { ixDIDT_TCP_WEIGHT0_3, 0xFFFFFFFF, 0, 0x5ACE160D }, | ||
193 | { ixDIDT_TCP_WEIGHT4_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
194 | { ixDIDT_TCP_WEIGHT8_11, 0xFFFFFFFF, 0, 0x00000000 }, | ||
195 | |||
196 | /* DIDT_DB */ | ||
197 | { ixDIDT_DB_WEIGHT0_3, 0xFFFFFFFF, 0, 0x0E152A0F }, | ||
198 | { ixDIDT_DB_WEIGHT4_7, 0xFFFFFFFF, 0, 0x09061813 }, | ||
199 | { ixDIDT_DB_WEIGHT8_11, 0xFFFFFFFF, 0, 0x00000013 }, | ||
200 | |||
201 | { 0xFFFFFFFF } /* End of list */ | ||
202 | }; | ||
203 | |||
204 | static const struct vega10_didt_config_reg SEDiDtCtrl0Config_Vega10[] = | ||
205 | { | ||
206 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
207 | * Offset Mask Shift Value | ||
208 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
209 | */ | ||
210 | /* DIDT_SQ */ | ||
211 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK, DIDT_SQ_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0000 }, | ||
212 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__PHASE_OFFSET_MASK, DIDT_SQ_CTRL0__PHASE_OFFSET__SHIFT, 0x0000 }, | ||
213 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CTRL_RST_MASK, DIDT_SQ_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000 }, | ||
214 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_SQ_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
215 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_STALL_CTRL_EN_MASK, DIDT_SQ_CTRL0__DIDT_STALL_CTRL_EN__SHIFT, 0x0001 }, | ||
216 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_TUNING_CTRL_EN_MASK, DIDT_SQ_CTRL0__DIDT_TUNING_CTRL_EN__SHIFT, 0x0001 }, | ||
217 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_STALL_AUTO_RELEASE_EN_MASK, DIDT_SQ_CTRL0__DIDT_STALL_AUTO_RELEASE_EN__SHIFT, 0x0001 }, | ||
218 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_SQ_CTRL0__DIDT_HI_POWER_THRESHOLD__SHIFT, 0xffff }, | ||
219 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_AUTO_MPD_EN_MASK, DIDT_SQ_CTRL0__DIDT_AUTO_MPD_EN__SHIFT, 0x0000 }, | ||
220 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_STALL_EVENT_EN_MASK, DIDT_SQ_CTRL0__DIDT_STALL_EVENT_EN__SHIFT, 0x0000 }, | ||
221 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR_MASK, DIDT_SQ_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR__SHIFT, 0x0000 }, | ||
222 | /* DIDT_TD */ | ||
223 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK, DIDT_TD_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0000 }, | ||
224 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__PHASE_OFFSET_MASK, DIDT_TD_CTRL0__PHASE_OFFSET__SHIFT, 0x0000 }, | ||
225 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CTRL_RST_MASK, DIDT_TD_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000 }, | ||
226 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TD_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
227 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_STALL_CTRL_EN_MASK, DIDT_TD_CTRL0__DIDT_STALL_CTRL_EN__SHIFT, 0x0001 }, | ||
228 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_TUNING_CTRL_EN_MASK, DIDT_TD_CTRL0__DIDT_TUNING_CTRL_EN__SHIFT, 0x0001 }, | ||
229 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_STALL_AUTO_RELEASE_EN_MASK, DIDT_TD_CTRL0__DIDT_STALL_AUTO_RELEASE_EN__SHIFT, 0x0001 }, | ||
230 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_TD_CTRL0__DIDT_HI_POWER_THRESHOLD__SHIFT, 0xffff }, | ||
231 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_AUTO_MPD_EN_MASK, DIDT_TD_CTRL0__DIDT_AUTO_MPD_EN__SHIFT, 0x0000 }, | ||
232 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_STALL_EVENT_EN_MASK, DIDT_TD_CTRL0__DIDT_STALL_EVENT_EN__SHIFT, 0x0000 }, | ||
233 | { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR_MASK, DIDT_TD_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR__SHIFT, 0x0000 }, | ||
234 | /* DIDT_TCP */ | ||
235 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK, DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0000 }, | ||
236 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__PHASE_OFFSET_MASK, DIDT_TCP_CTRL0__PHASE_OFFSET__SHIFT, 0x0000 }, | ||
237 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CTRL_RST_MASK, DIDT_TCP_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000 }, | ||
238 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TCP_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
239 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_STALL_CTRL_EN_MASK, DIDT_TCP_CTRL0__DIDT_STALL_CTRL_EN__SHIFT, 0x0001 }, | ||
240 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_TUNING_CTRL_EN_MASK, DIDT_TCP_CTRL0__DIDT_TUNING_CTRL_EN__SHIFT, 0x0001 }, | ||
241 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_STALL_AUTO_RELEASE_EN_MASK, DIDT_TCP_CTRL0__DIDT_STALL_AUTO_RELEASE_EN__SHIFT, 0x0001 }, | ||
242 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_TCP_CTRL0__DIDT_HI_POWER_THRESHOLD__SHIFT, 0xffff }, | ||
243 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_AUTO_MPD_EN_MASK, DIDT_TCP_CTRL0__DIDT_AUTO_MPD_EN__SHIFT, 0x0000 }, | ||
244 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_STALL_EVENT_EN_MASK, DIDT_TCP_CTRL0__DIDT_STALL_EVENT_EN__SHIFT, 0x0000 }, | ||
245 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR_MASK, DIDT_TCP_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR__SHIFT, 0x0000 }, | ||
246 | /* DIDT_DB */ | ||
247 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK, DIDT_DB_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0000 }, | ||
248 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__PHASE_OFFSET_MASK, DIDT_DB_CTRL0__PHASE_OFFSET__SHIFT, 0x0000 }, | ||
249 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_CTRL_RST_MASK, DIDT_DB_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000 }, | ||
250 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_DB_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
251 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_STALL_CTRL_EN_MASK, DIDT_DB_CTRL0__DIDT_STALL_CTRL_EN__SHIFT, 0x0001 }, | ||
252 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_TUNING_CTRL_EN_MASK, DIDT_DB_CTRL0__DIDT_TUNING_CTRL_EN__SHIFT, 0x0001 }, | ||
253 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_STALL_AUTO_RELEASE_EN_MASK, DIDT_DB_CTRL0__DIDT_STALL_AUTO_RELEASE_EN__SHIFT, 0x0001 }, | ||
254 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_DB_CTRL0__DIDT_HI_POWER_THRESHOLD__SHIFT, 0xffff }, | ||
255 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_AUTO_MPD_EN_MASK, DIDT_DB_CTRL0__DIDT_AUTO_MPD_EN__SHIFT, 0x0000 }, | ||
256 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_STALL_EVENT_EN_MASK, DIDT_DB_CTRL0__DIDT_STALL_EVENT_EN__SHIFT, 0x0000 }, | ||
257 | { ixDIDT_DB_CTRL0, DIDT_DB_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR_MASK, DIDT_DB_CTRL0__DIDT_STALL_EVENT_COUNTER_CLEAR__SHIFT, 0x0000 }, | ||
258 | |||
259 | { 0xFFFFFFFF } /* End of list */ | ||
260 | }; | ||
261 | |||
262 | |||
263 | static const struct vega10_didt_config_reg SEDiDtStallCtrlConfig_vega10[] = | ||
264 | { | ||
265 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
266 | * Offset Mask Shift Value | ||
267 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
268 | */ | ||
269 | /* DIDT_SQ */ | ||
270 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0004 }, | ||
271 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0004 }, | ||
272 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_SQ_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x000a }, | ||
273 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_SQ_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x000a }, | ||
274 | |||
275 | /* DIDT_TD */ | ||
276 | { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001 }, | ||
277 | { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001 }, | ||
278 | { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_TD_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x000a }, | ||
279 | { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_TD_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x000a }, | ||
280 | |||
281 | /* DIDT_TCP */ | ||
282 | { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001 }, | ||
283 | { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001 }, | ||
284 | { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_TCP_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x000a }, | ||
285 | { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_TCP_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x000a }, | ||
286 | |||
287 | /* DIDT_DB */ | ||
288 | { ixDIDT_DB_STALL_CTRL, DIDT_DB_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_DB_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0004 }, | ||
289 | { ixDIDT_DB_STALL_CTRL, DIDT_DB_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_DB_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0004 }, | ||
290 | { ixDIDT_DB_STALL_CTRL, DIDT_DB_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_DB_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x000a }, | ||
291 | { ixDIDT_DB_STALL_CTRL, DIDT_DB_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_DB_STALL_CTRL__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x000a }, | ||
292 | |||
293 | { 0xFFFFFFFF } /* End of list */ | ||
294 | }; | ||
295 | |||
296 | static const struct vega10_didt_config_reg SEDiDtStallPatternConfig_vega10[] = | ||
297 | { | ||
298 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
299 | * Offset Mask Shift Value | ||
300 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
301 | */ | ||
302 | /* DIDT_SQ_STALL_PATTERN_1_2 */ | ||
303 | { ixDIDT_SQ_STALL_PATTERN_1_2, DIDT_SQ_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1_MASK, DIDT_SQ_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1__SHIFT, 0x0001 }, | ||
304 | { ixDIDT_SQ_STALL_PATTERN_1_2, DIDT_SQ_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2_MASK, DIDT_SQ_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2__SHIFT, 0x0001 }, | ||
305 | |||
306 | /* DIDT_SQ_STALL_PATTERN_3_4 */ | ||
307 | { ixDIDT_SQ_STALL_PATTERN_3_4, DIDT_SQ_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3_MASK, DIDT_SQ_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3__SHIFT, 0x0001 }, | ||
308 | { ixDIDT_SQ_STALL_PATTERN_3_4, DIDT_SQ_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4_MASK, DIDT_SQ_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4__SHIFT, 0x0001 }, | ||
309 | |||
310 | /* DIDT_SQ_STALL_PATTERN_5_6 */ | ||
311 | { ixDIDT_SQ_STALL_PATTERN_5_6, DIDT_SQ_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5_MASK, DIDT_SQ_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5__SHIFT, 0x0000 }, | ||
312 | { ixDIDT_SQ_STALL_PATTERN_5_6, DIDT_SQ_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6_MASK, DIDT_SQ_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6__SHIFT, 0x0000 }, | ||
313 | |||
314 | /* DIDT_SQ_STALL_PATTERN_7 */ | ||
315 | { ixDIDT_SQ_STALL_PATTERN_7, DIDT_SQ_STALL_PATTERN_7__DIDT_STALL_PATTERN_7_MASK, DIDT_SQ_STALL_PATTERN_7__DIDT_STALL_PATTERN_7__SHIFT, 0x0000 }, | ||
316 | |||
317 | /* DIDT_TCP_STALL_PATTERN_1_2 */ | ||
318 | { ixDIDT_TCP_STALL_PATTERN_1_2, DIDT_TCP_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1_MASK, DIDT_TCP_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1__SHIFT, 0x0001 }, | ||
319 | { ixDIDT_TCP_STALL_PATTERN_1_2, DIDT_TCP_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2_MASK, DIDT_TCP_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2__SHIFT, 0x0001 }, | ||
320 | |||
321 | /* DIDT_TCP_STALL_PATTERN_3_4 */ | ||
322 | { ixDIDT_TCP_STALL_PATTERN_3_4, DIDT_TCP_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3_MASK, DIDT_TCP_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3__SHIFT, 0x0001 }, | ||
323 | { ixDIDT_TCP_STALL_PATTERN_3_4, DIDT_TCP_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4_MASK, DIDT_TCP_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4__SHIFT, 0x0001 }, | ||
324 | |||
325 | /* DIDT_TCP_STALL_PATTERN_5_6 */ | ||
326 | { ixDIDT_TCP_STALL_PATTERN_5_6, DIDT_TCP_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5_MASK, DIDT_TCP_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5__SHIFT, 0x0000 }, | ||
327 | { ixDIDT_TCP_STALL_PATTERN_5_6, DIDT_TCP_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6_MASK, DIDT_TCP_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6__SHIFT, 0x0000 }, | ||
328 | |||
329 | /* DIDT_TCP_STALL_PATTERN_7 */ | ||
330 | { ixDIDT_TCP_STALL_PATTERN_7, DIDT_TCP_STALL_PATTERN_7__DIDT_STALL_PATTERN_7_MASK, DIDT_TCP_STALL_PATTERN_7__DIDT_STALL_PATTERN_7__SHIFT, 0x0000 }, | ||
331 | |||
332 | /* DIDT_TD_STALL_PATTERN_1_2 */ | ||
333 | { ixDIDT_TD_STALL_PATTERN_1_2, DIDT_TD_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1_MASK, DIDT_TD_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1__SHIFT, 0x0001 }, | ||
334 | { ixDIDT_TD_STALL_PATTERN_1_2, DIDT_TD_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2_MASK, DIDT_TD_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2__SHIFT, 0x0001 }, | ||
335 | |||
336 | /* DIDT_TD_STALL_PATTERN_3_4 */ | ||
337 | { ixDIDT_TD_STALL_PATTERN_3_4, DIDT_TD_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3_MASK, DIDT_TD_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3__SHIFT, 0x0001 }, | ||
338 | { ixDIDT_TD_STALL_PATTERN_3_4, DIDT_TD_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4_MASK, DIDT_TD_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4__SHIFT, 0x0001 }, | ||
339 | |||
340 | /* DIDT_TD_STALL_PATTERN_5_6 */ | ||
341 | { ixDIDT_TD_STALL_PATTERN_5_6, DIDT_TD_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5_MASK, DIDT_TD_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5__SHIFT, 0x0000 }, | ||
342 | { ixDIDT_TD_STALL_PATTERN_5_6, DIDT_TD_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6_MASK, DIDT_TD_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6__SHIFT, 0x0000 }, | ||
343 | |||
344 | /* DIDT_TD_STALL_PATTERN_7 */ | ||
345 | { ixDIDT_TD_STALL_PATTERN_7, DIDT_TD_STALL_PATTERN_7__DIDT_STALL_PATTERN_7_MASK, DIDT_TD_STALL_PATTERN_7__DIDT_STALL_PATTERN_7__SHIFT, 0x0000 }, | ||
346 | |||
347 | /* DIDT_DB_STALL_PATTERN_1_2 */ | ||
348 | { ixDIDT_DB_STALL_PATTERN_1_2, DIDT_DB_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1_MASK, DIDT_DB_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_1__SHIFT, 0x0001 }, | ||
349 | { ixDIDT_DB_STALL_PATTERN_1_2, DIDT_DB_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2_MASK, DIDT_DB_STALL_PATTERN_1_2__DIDT_STALL_PATTERN_2__SHIFT, 0x0001 }, | ||
350 | |||
351 | /* DIDT_DB_STALL_PATTERN_3_4 */ | ||
352 | { ixDIDT_DB_STALL_PATTERN_3_4, DIDT_DB_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3_MASK, DIDT_DB_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_3__SHIFT, 0x0001 }, | ||
353 | { ixDIDT_DB_STALL_PATTERN_3_4, DIDT_DB_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4_MASK, DIDT_DB_STALL_PATTERN_3_4__DIDT_STALL_PATTERN_4__SHIFT, 0x0001 }, | ||
354 | |||
355 | /* DIDT_DB_STALL_PATTERN_5_6 */ | ||
356 | { ixDIDT_DB_STALL_PATTERN_5_6, DIDT_DB_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5_MASK, DIDT_DB_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_5__SHIFT, 0x0000 }, | ||
357 | { ixDIDT_DB_STALL_PATTERN_5_6, DIDT_DB_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6_MASK, DIDT_DB_STALL_PATTERN_5_6__DIDT_STALL_PATTERN_6__SHIFT, 0x0000 }, | ||
358 | |||
359 | /* DIDT_DB_STALL_PATTERN_7 */ | ||
360 | { ixDIDT_DB_STALL_PATTERN_7, DIDT_DB_STALL_PATTERN_7__DIDT_STALL_PATTERN_7_MASK, DIDT_DB_STALL_PATTERN_7__DIDT_STALL_PATTERN_7__SHIFT, 0x0000 }, | ||
361 | |||
362 | { 0xFFFFFFFF } /* End of list */ | ||
363 | }; | ||
364 | |||
365 | static const struct vega10_didt_config_reg SELCacConfig_Vega10[] = | ||
366 | { | ||
367 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
368 | * Offset Mask Shift Value | ||
369 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
370 | */ | ||
371 | /* SQ */ | ||
372 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x00060021 }, | ||
373 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x00860021 }, | ||
374 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x01060021 }, | ||
375 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x01860021 }, | ||
376 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x02060021 }, | ||
377 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x02860021 }, | ||
378 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x03060021 }, | ||
379 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x03860021 }, | ||
380 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x04060021 }, | ||
381 | /* TD */ | ||
382 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x000E0020 }, | ||
383 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x008E0020 }, | ||
384 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x010E0020 }, | ||
385 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x018E0020 }, | ||
386 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x020E0020 }, | ||
387 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x028E0020 }, | ||
388 | /* TCP */ | ||
389 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x001c0020 }, | ||
390 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x009c0020 }, | ||
391 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x011c0020 }, | ||
392 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x019c0020 }, | ||
393 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x021c0020 }, | ||
394 | /* DB */ | ||
395 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x00200008 }, | ||
396 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x00820008 }, | ||
397 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x01020008 }, | ||
398 | { ixSE_CAC_CNTL, 0xFFFFFFFF, 0, 0x01820008 }, | ||
399 | |||
400 | { 0xFFFFFFFF } /* End of list */ | ||
401 | }; | ||
402 | |||
403 | |||
404 | static const struct vega10_didt_config_reg SEEDCStallPatternConfig_Vega10[] = | ||
405 | { | ||
406 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
407 | * Offset Mask Shift Value | ||
408 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
409 | */ | ||
410 | /* SQ */ | ||
411 | { ixDIDT_SQ_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00030001 }, | ||
412 | { ixDIDT_SQ_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x000F0007 }, | ||
413 | { ixDIDT_SQ_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x003F001F }, | ||
414 | { ixDIDT_SQ_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x0000007F }, | ||
415 | /* TD */ | ||
416 | { ixDIDT_TD_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
417 | { ixDIDT_TD_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
418 | { ixDIDT_TD_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x00000000 }, | ||
419 | { ixDIDT_TD_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
420 | /* TCP */ | ||
421 | { ixDIDT_TCP_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
422 | { ixDIDT_TCP_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
423 | { ixDIDT_TCP_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x00000000 }, | ||
424 | { ixDIDT_TCP_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
425 | /* DB */ | ||
426 | { ixDIDT_DB_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
427 | { ixDIDT_DB_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
428 | { ixDIDT_DB_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x00000000 }, | ||
429 | { ixDIDT_DB_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
430 | |||
431 | { 0xFFFFFFFF } /* End of list */ | ||
432 | }; | ||
433 | |||
434 | static const struct vega10_didt_config_reg SEEDCForceStallPatternConfig_Vega10[] = | ||
435 | { | ||
436 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
437 | * Offset Mask Shift Value | ||
438 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
439 | */ | ||
440 | /* SQ */ | ||
441 | { ixDIDT_SQ_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00000015 }, | ||
442 | { ixDIDT_SQ_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
443 | { ixDIDT_SQ_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x00000000 }, | ||
444 | { ixDIDT_SQ_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
445 | /* TD */ | ||
446 | { ixDIDT_TD_EDC_STALL_PATTERN_1_2, 0xFFFFFFFF, 0, 0x00000015 }, | ||
447 | { ixDIDT_TD_EDC_STALL_PATTERN_3_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
448 | { ixDIDT_TD_EDC_STALL_PATTERN_5_6, 0xFFFFFFFF, 0, 0x00000000 }, | ||
449 | { ixDIDT_TD_EDC_STALL_PATTERN_7, 0xFFFFFFFF, 0, 0x00000000 }, | ||
450 | |||
451 | { 0xFFFFFFFF } /* End of list */ | ||
452 | }; | ||
453 | |||
454 | static const struct vega10_didt_config_reg SEEDCStallDelayConfig_Vega10[] = | ||
455 | { | ||
456 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
457 | * Offset Mask Shift Value | ||
458 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
459 | */ | ||
460 | /* SQ */ | ||
461 | { ixDIDT_SQ_EDC_STALL_DELAY_1, 0xFFFFFFFF, 0, 0x00000000 }, | ||
462 | { ixDIDT_SQ_EDC_STALL_DELAY_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
463 | { ixDIDT_SQ_EDC_STALL_DELAY_3, 0xFFFFFFFF, 0, 0x00000000 }, | ||
464 | { ixDIDT_SQ_EDC_STALL_DELAY_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
465 | /* TD */ | ||
466 | { ixDIDT_TD_EDC_STALL_DELAY_1, 0xFFFFFFFF, 0, 0x00000000 }, | ||
467 | { ixDIDT_TD_EDC_STALL_DELAY_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
468 | { ixDIDT_TD_EDC_STALL_DELAY_3, 0xFFFFFFFF, 0, 0x00000000 }, | ||
469 | { ixDIDT_TD_EDC_STALL_DELAY_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
470 | /* TCP */ | ||
471 | { ixDIDT_TCP_EDC_STALL_DELAY_1, 0xFFFFFFFF, 0, 0x00000000 }, | ||
472 | { ixDIDT_TCP_EDC_STALL_DELAY_2, 0xFFFFFFFF, 0, 0x00000000 }, | ||
473 | { ixDIDT_TCP_EDC_STALL_DELAY_3, 0xFFFFFFFF, 0, 0x00000000 }, | ||
474 | { ixDIDT_TCP_EDC_STALL_DELAY_4, 0xFFFFFFFF, 0, 0x00000000 }, | ||
475 | /* DB */ | ||
476 | { ixDIDT_DB_EDC_STALL_DELAY_1, 0xFFFFFFFF, 0, 0x00000000 }, | ||
477 | |||
478 | { 0xFFFFFFFF } /* End of list */ | ||
479 | }; | ||
480 | |||
481 | static const struct vega10_didt_config_reg SEEDCThresholdConfig_Vega10[] = | ||
482 | { | ||
483 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
484 | * Offset Mask Shift Value | ||
485 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
486 | */ | ||
487 | { ixDIDT_SQ_EDC_THRESHOLD, 0xFFFFFFFF, 0, 0x0000010E }, | ||
488 | { ixDIDT_TD_EDC_THRESHOLD, 0xFFFFFFFF, 0, 0xFFFFFFFF }, | ||
489 | { ixDIDT_TCP_EDC_THRESHOLD, 0xFFFFFFFF, 0, 0xFFFFFFFF }, | ||
490 | { ixDIDT_DB_EDC_THRESHOLD, 0xFFFFFFFF, 0, 0xFFFFFFFF }, | ||
491 | |||
492 | { 0xFFFFFFFF } /* End of list */ | ||
493 | }; | ||
494 | |||
495 | static const struct vega10_didt_config_reg SEEDCCtrlResetConfig_Vega10[] = | ||
496 | { | ||
497 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
498 | * Offset Mask Shift Value | ||
499 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
500 | */ | ||
501 | /* SQ */ | ||
502 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_EN_MASK, DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT, 0x0000 }, | ||
503 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK, DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0001 }, | ||
504 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
505 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
506 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
507 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0000 }, | ||
508 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
509 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0000 }, | ||
510 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0000 }, | ||
511 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
512 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
513 | |||
514 | { 0xFFFFFFFF } /* End of list */ | ||
515 | }; | ||
516 | |||
517 | static const struct vega10_didt_config_reg SEEDCCtrlConfig_Vega10[] = | ||
518 | { | ||
519 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
520 | * Offset Mask Shift Value | ||
521 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
522 | */ | ||
523 | /* SQ */ | ||
524 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_EN_MASK, DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT, 0x0001 }, | ||
525 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK, DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0000 }, | ||
526 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
527 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
528 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0004 }, | ||
529 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0006 }, | ||
530 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
531 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0000 }, | ||
532 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0000 }, | ||
533 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0001 }, | ||
534 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
535 | |||
536 | { 0xFFFFFFFF } /* End of list */ | ||
537 | }; | ||
538 | |||
539 | static const struct vega10_didt_config_reg SEEDCCtrlForceStallConfig_Vega10[] = | ||
540 | { | ||
541 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
542 | * Offset Mask Shift Value | ||
543 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
544 | */ | ||
545 | /* SQ */ | ||
546 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_EN_MASK, DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT, 0x0001 }, | ||
547 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK, DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0000 }, | ||
548 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
549 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0001 }, | ||
550 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0001 }, | ||
551 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x000C }, | ||
552 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
553 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0000 }, | ||
554 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0000 }, | ||
555 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
556 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0001 }, | ||
557 | |||
558 | /* TD */ | ||
559 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_EN_MASK, DIDT_TD_EDC_CTRL__EDC_EN__SHIFT, 0x0001 }, | ||
560 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_SW_RST_MASK, DIDT_TD_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0000 }, | ||
561 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_TD_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
562 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_TD_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0001 }, | ||
563 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_TD_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0001 }, | ||
564 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_TD_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x000E }, | ||
565 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_TD_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
566 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__GC_EDC_EN_MASK, DIDT_TD_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0000 }, | ||
567 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_TD_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0000 }, | ||
568 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_TD_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
569 | { ixDIDT_TD_EDC_CTRL, DIDT_TD_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_TD_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0001 }, | ||
570 | |||
571 | { 0xFFFFFFFF } /* End of list */ | ||
572 | }; | ||
573 | |||
574 | static const struct vega10_didt_config_reg GCDiDtDroopCtrlConfig_vega10[] = | ||
575 | { | ||
576 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
577 | * Offset Mask Shift Value | ||
578 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
579 | */ | ||
580 | { mmGC_DIDT_DROOP_CTRL, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_EN_MASK, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_EN__SHIFT, 0x0000 }, | ||
581 | { mmGC_DIDT_DROOP_CTRL, GC_DIDT_DROOP_CTRL__DIDT_DROOP_THRESHOLD_MASK, GC_DIDT_DROOP_CTRL__DIDT_DROOP_THRESHOLD__SHIFT, 0x0000 }, | ||
582 | { mmGC_DIDT_DROOP_CTRL, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_INDEX_MASK, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_INDEX__SHIFT, 0x0000 }, | ||
583 | { mmGC_DIDT_DROOP_CTRL, GC_DIDT_DROOP_CTRL__DIDT_LEVEL_SEL_MASK, GC_DIDT_DROOP_CTRL__DIDT_LEVEL_SEL__SHIFT, 0x0000 }, | ||
584 | { mmGC_DIDT_DROOP_CTRL, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_OVERFLOW_MASK, GC_DIDT_DROOP_CTRL__DIDT_DROOP_LEVEL_OVERFLOW__SHIFT, 0x0000 }, | ||
585 | |||
586 | { 0xFFFFFFFF } /* End of list */ | ||
587 | }; | ||
588 | |||
589 | static const struct vega10_didt_config_reg GCDiDtCtrl0Config_vega10[] = | ||
590 | { | ||
591 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
592 | * Offset Mask Shift Value | ||
593 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
594 | */ | ||
595 | { mmGC_DIDT_CTRL0, GC_DIDT_CTRL0__DIDT_CTRL_EN_MASK, GC_DIDT_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0000 }, | ||
596 | { mmGC_DIDT_CTRL0, GC_DIDT_CTRL0__PHASE_OFFSET_MASK, GC_DIDT_CTRL0__PHASE_OFFSET__SHIFT, 0x0000 }, | ||
597 | { mmGC_DIDT_CTRL0, GC_DIDT_CTRL0__DIDT_SW_RST_MASK, GC_DIDT_CTRL0__DIDT_SW_RST__SHIFT, 0x0000 }, | ||
598 | { mmGC_DIDT_CTRL0, GC_DIDT_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, GC_DIDT_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
599 | { mmGC_DIDT_CTRL0, GC_DIDT_CTRL0__DIDT_TRIGGER_THROTTLE_LOWBIT_MASK, GC_DIDT_CTRL0__DIDT_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
600 | { 0xFFFFFFFF } /* End of list */ | ||
601 | }; | ||
602 | |||
603 | |||
604 | static const struct vega10_didt_config_reg PSMSEEDCStallPatternConfig_Vega10[] = | ||
605 | { | ||
606 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
607 | * Offset Mask Shift Value | ||
608 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
609 | */ | ||
610 | /* SQ EDC STALL PATTERNs */ | ||
611 | { ixDIDT_SQ_EDC_STALL_PATTERN_1_2, DIDT_SQ_EDC_STALL_PATTERN_1_2__EDC_STALL_PATTERN_1_MASK, DIDT_SQ_EDC_STALL_PATTERN_1_2__EDC_STALL_PATTERN_1__SHIFT, 0x0101 }, | ||
612 | { ixDIDT_SQ_EDC_STALL_PATTERN_1_2, DIDT_SQ_EDC_STALL_PATTERN_1_2__EDC_STALL_PATTERN_2_MASK, DIDT_SQ_EDC_STALL_PATTERN_1_2__EDC_STALL_PATTERN_2__SHIFT, 0x0101 }, | ||
613 | { ixDIDT_SQ_EDC_STALL_PATTERN_3_4, DIDT_SQ_EDC_STALL_PATTERN_3_4__EDC_STALL_PATTERN_3_MASK, DIDT_SQ_EDC_STALL_PATTERN_3_4__EDC_STALL_PATTERN_3__SHIFT, 0x1111 }, | ||
614 | { ixDIDT_SQ_EDC_STALL_PATTERN_3_4, DIDT_SQ_EDC_STALL_PATTERN_3_4__EDC_STALL_PATTERN_4_MASK, DIDT_SQ_EDC_STALL_PATTERN_3_4__EDC_STALL_PATTERN_4__SHIFT, 0x1111 }, | ||
615 | |||
616 | { ixDIDT_SQ_EDC_STALL_PATTERN_5_6, DIDT_SQ_EDC_STALL_PATTERN_5_6__EDC_STALL_PATTERN_5_MASK, DIDT_SQ_EDC_STALL_PATTERN_5_6__EDC_STALL_PATTERN_5__SHIFT, 0x1515 }, | ||
617 | { ixDIDT_SQ_EDC_STALL_PATTERN_5_6, DIDT_SQ_EDC_STALL_PATTERN_5_6__EDC_STALL_PATTERN_6_MASK, DIDT_SQ_EDC_STALL_PATTERN_5_6__EDC_STALL_PATTERN_6__SHIFT, 0x1515 }, | ||
618 | |||
619 | { ixDIDT_SQ_EDC_STALL_PATTERN_7, DIDT_SQ_EDC_STALL_PATTERN_7__EDC_STALL_PATTERN_7_MASK, DIDT_SQ_EDC_STALL_PATTERN_7__EDC_STALL_PATTERN_7__SHIFT, 0x5555 }, | ||
620 | |||
621 | { 0xFFFFFFFF } /* End of list */ | ||
622 | }; | ||
623 | |||
624 | static const struct vega10_didt_config_reg PSMSEEDCStallDelayConfig_Vega10[] = | ||
625 | { | ||
626 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
627 | * Offset Mask Shift Value | ||
628 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
629 | */ | ||
630 | /* SQ EDC STALL DELAYs */ | ||
631 | { ixDIDT_SQ_EDC_STALL_DELAY_1, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ0_MASK, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ0__SHIFT, 0x0000 }, | ||
632 | { ixDIDT_SQ_EDC_STALL_DELAY_1, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ1_MASK, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ1__SHIFT, 0x0000 }, | ||
633 | { ixDIDT_SQ_EDC_STALL_DELAY_1, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ2_MASK, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ2__SHIFT, 0x0000 }, | ||
634 | { ixDIDT_SQ_EDC_STALL_DELAY_1, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ3_MASK, DIDT_SQ_EDC_STALL_DELAY_1__EDC_STALL_DELAY_SQ3__SHIFT, 0x0000 }, | ||
635 | |||
636 | { ixDIDT_SQ_EDC_STALL_DELAY_2, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ4_MASK, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ4__SHIFT, 0x0000 }, | ||
637 | { ixDIDT_SQ_EDC_STALL_DELAY_2, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ5_MASK, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ5__SHIFT, 0x0000 }, | ||
638 | { ixDIDT_SQ_EDC_STALL_DELAY_2, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ6_MASK, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ6__SHIFT, 0x0000 }, | ||
639 | { ixDIDT_SQ_EDC_STALL_DELAY_2, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ7_MASK, DIDT_SQ_EDC_STALL_DELAY_2__EDC_STALL_DELAY_SQ7__SHIFT, 0x0000 }, | ||
640 | |||
641 | { ixDIDT_SQ_EDC_STALL_DELAY_3, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ8_MASK, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ8__SHIFT, 0x0000 }, | ||
642 | { ixDIDT_SQ_EDC_STALL_DELAY_3, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ9_MASK, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ9__SHIFT, 0x0000 }, | ||
643 | { ixDIDT_SQ_EDC_STALL_DELAY_3, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ10_MASK, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ10__SHIFT, 0x0000 }, | ||
644 | { ixDIDT_SQ_EDC_STALL_DELAY_3, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ11_MASK, DIDT_SQ_EDC_STALL_DELAY_3__EDC_STALL_DELAY_SQ11__SHIFT, 0x0000 }, | ||
645 | |||
646 | { ixDIDT_SQ_EDC_STALL_DELAY_4, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ12_MASK, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ12__SHIFT, 0x0000 }, | ||
647 | { ixDIDT_SQ_EDC_STALL_DELAY_4, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ12_MASK, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ13__SHIFT, 0x0000 }, | ||
648 | { ixDIDT_SQ_EDC_STALL_DELAY_4, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ14_MASK, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ14__SHIFT, 0x0000 }, | ||
649 | { ixDIDT_SQ_EDC_STALL_DELAY_4, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ15_MASK, DIDT_SQ_EDC_STALL_DELAY_4__EDC_STALL_DELAY_SQ15__SHIFT, 0x0000 }, | ||
650 | |||
651 | { 0xFFFFFFFF } /* End of list */ | ||
652 | }; | ||
653 | |||
654 | static const struct vega10_didt_config_reg PSMSEEDCThresholdConfig_Vega10[] = | ||
655 | { | ||
656 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
657 | * Offset Mask Shift Value | ||
658 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
659 | */ | ||
660 | /* SQ EDC THRESHOLD */ | ||
661 | { ixDIDT_SQ_EDC_THRESHOLD, DIDT_SQ_EDC_THRESHOLD__EDC_THRESHOLD_MASK, DIDT_SQ_EDC_THRESHOLD__EDC_THRESHOLD__SHIFT, 0x0000 }, | ||
662 | |||
663 | { 0xFFFFFFFF } /* End of list */ | ||
664 | }; | ||
665 | |||
666 | static const struct vega10_didt_config_reg PSMSEEDCCtrlResetConfig_Vega10[] = | ||
667 | { | ||
668 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
669 | * Offset Mask Shift Value | ||
670 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
671 | */ | ||
672 | /* SQ EDC CTRL */ | ||
673 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_EN_MASK, DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT, 0x0000 }, | ||
674 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK, DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0001 }, | ||
675 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
676 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
677 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
678 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x0000 }, | ||
679 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
680 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0000 }, | ||
681 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0000 }, | ||
682 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
683 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
684 | |||
685 | { 0xFFFFFFFF } /* End of list */ | ||
686 | }; | ||
687 | |||
688 | static const struct vega10_didt_config_reg PSMSEEDCCtrlConfig_Vega10[] = | ||
689 | { | ||
690 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
691 | * Offset Mask Shift Value | ||
692 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
693 | */ | ||
694 | /* SQ EDC CTRL */ | ||
695 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_EN_MASK, DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT, 0x0001 }, | ||
696 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK, DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0000 }, | ||
697 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, DIDT_SQ_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
698 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL_MASK, DIDT_SQ_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
699 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, DIDT_SQ_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
700 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS_MASK, DIDT_SQ_EDC_CTRL__EDC_STALL_PATTERN_BIT_NUMS__SHIFT, 0x000E }, | ||
701 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, DIDT_SQ_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
702 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_EN__SHIFT, 0x0001 }, | ||
703 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_STALL_POLICY__SHIFT, 0x0003 }, | ||
704 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__GC_EDC_LEVEL_COMB_EN__SHIFT, 0x0001 }, | ||
705 | { ixDIDT_SQ_EDC_CTRL, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN_MASK, DIDT_SQ_EDC_CTRL__SE_EDC_LEVEL_COMB_EN__SHIFT, 0x0000 }, | ||
706 | |||
707 | { 0xFFFFFFFF } /* End of list */ | ||
708 | }; | ||
709 | |||
710 | static const struct vega10_didt_config_reg PSMGCEDCThresholdConfig_vega10[] = | ||
711 | { | ||
712 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
713 | * Offset Mask Shift Value | ||
714 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
715 | */ | ||
716 | { mmGC_EDC_THRESHOLD, GC_EDC_THRESHOLD__EDC_THRESHOLD_MASK, GC_EDC_THRESHOLD__EDC_THRESHOLD__SHIFT, 0x0000000 }, | ||
717 | |||
718 | { 0xFFFFFFFF } /* End of list */ | ||
719 | }; | ||
720 | |||
721 | static const struct vega10_didt_config_reg PSMGCEDCDroopCtrlConfig_vega10[] = | ||
722 | { | ||
723 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
724 | * Offset Mask Shift Value | ||
725 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
726 | */ | ||
727 | { mmGC_EDC_DROOP_CTRL, GC_EDC_DROOP_CTRL__EDC_DROOP_LEVEL_EN_MASK, GC_EDC_DROOP_CTRL__EDC_DROOP_LEVEL_EN__SHIFT, 0x0001 }, | ||
728 | { mmGC_EDC_DROOP_CTRL, GC_EDC_DROOP_CTRL__EDC_DROOP_THRESHOLD_MASK, GC_EDC_DROOP_CTRL__EDC_DROOP_THRESHOLD__SHIFT, 0x0384 }, | ||
729 | { mmGC_EDC_DROOP_CTRL, GC_EDC_DROOP_CTRL__EDC_DROOP_LEVEL_INDEX_MASK, GC_EDC_DROOP_CTRL__EDC_DROOP_LEVEL_INDEX__SHIFT, 0x0001 }, | ||
730 | { mmGC_EDC_DROOP_CTRL, GC_EDC_DROOP_CTRL__AVG_PSM_SEL_MASK, GC_EDC_DROOP_CTRL__AVG_PSM_SEL__SHIFT, 0x0001 }, | ||
731 | { mmGC_EDC_DROOP_CTRL, GC_EDC_DROOP_CTRL__EDC_LEVEL_SEL_MASK, GC_EDC_DROOP_CTRL__EDC_LEVEL_SEL__SHIFT, 0x0001 }, | ||
732 | |||
733 | { 0xFFFFFFFF } /* End of list */ | ||
734 | }; | ||
735 | |||
736 | static const struct vega10_didt_config_reg PSMGCEDCCtrlResetConfig_vega10[] = | ||
737 | { | ||
738 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
739 | * Offset Mask Shift Value | ||
740 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
741 | */ | ||
742 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_EN_MASK, GC_EDC_CTRL__EDC_EN__SHIFT, 0x0000 }, | ||
743 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_SW_RST_MASK, GC_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0001 }, | ||
744 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, GC_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
745 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_FORCE_STALL_MASK, GC_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
746 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, GC_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
747 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, GC_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
748 | |||
749 | { 0xFFFFFFFF } /* End of list */ | ||
750 | }; | ||
751 | |||
752 | static const struct vega10_didt_config_reg PSMGCEDCCtrlConfig_vega10[] = | ||
753 | { | ||
754 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
755 | * Offset Mask Shift Value | ||
756 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
757 | */ | ||
758 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_EN_MASK, GC_EDC_CTRL__EDC_EN__SHIFT, 0x0001 }, | ||
759 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_SW_RST_MASK, GC_EDC_CTRL__EDC_SW_RST__SHIFT, 0x0000 }, | ||
760 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_CLK_EN_OVERRIDE_MASK, GC_EDC_CTRL__EDC_CLK_EN_OVERRIDE__SHIFT, 0x0000 }, | ||
761 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_FORCE_STALL_MASK, GC_EDC_CTRL__EDC_FORCE_STALL__SHIFT, 0x0000 }, | ||
762 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT_MASK, GC_EDC_CTRL__EDC_TRIGGER_THROTTLE_LOWBIT__SHIFT, 0x0000 }, | ||
763 | { mmGC_EDC_CTRL, GC_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA_MASK, GC_EDC_CTRL__EDC_ALLOW_WRITE_PWRDELTA__SHIFT, 0x0000 }, | ||
764 | |||
765 | { 0xFFFFFFFF } /* End of list */ | ||
766 | }; | ||
767 | |||
768 | static const struct vega10_didt_config_reg AvfsPSMResetConfig_vega10[]= | ||
769 | { | ||
770 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
771 | * Offset Mask Shift Value | ||
772 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
773 | */ | ||
774 | { 0x16A02, 0xFFFFFFFF, 0x0, 0x0000005F }, | ||
775 | { 0x16A05, 0xFFFFFFFF, 0x0, 0x00000001 }, | ||
776 | { 0x16A06, 0x00000001, 0x0, 0x02000000 }, | ||
777 | { 0x16A01, 0xFFFFFFFF, 0x0, 0x00003027 }, | ||
778 | |||
779 | { 0xFFFFFFFF } /* End of list */ | ||
780 | }; | ||
781 | |||
782 | static const struct vega10_didt_config_reg AvfsPSMInitConfig_vega10[] = | ||
783 | { | ||
784 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
785 | * Offset Mask Shift Value | ||
786 | * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
787 | */ | ||
788 | { 0x16A05, 0xFFFFFFFF, 0x18, 0x00000001 }, | ||
789 | { 0x16A05, 0xFFFFFFFF, 0x8, 0x00000003 }, | ||
790 | { 0x16A05, 0xFFFFFFFF, 0xa, 0x00000006 }, | ||
791 | { 0x16A05, 0xFFFFFFFF, 0x7, 0x00000000 }, | ||
792 | { 0x16A06, 0xFFFFFFFF, 0x18, 0x00000001 }, | ||
793 | { 0x16A06, 0xFFFFFFFF, 0x19, 0x00000001 }, | ||
794 | { 0x16A01, 0xFFFFFFFF, 0x0, 0x00003027 }, | ||
795 | |||
796 | { 0xFFFFFFFF } /* End of list */ | ||
797 | }; | ||
798 | |||
799 | static int vega10_program_didt_config_registers(struct pp_hwmgr *hwmgr, const struct vega10_didt_config_reg *config_regs, enum vega10_didt_config_reg_type reg_type) | ||
800 | { | ||
801 | uint32_t data; | ||
802 | |||
803 | PP_ASSERT_WITH_CODE((config_regs != NULL), "[vega10_program_didt_config_registers] Invalid config register table!", return -EINVAL); | ||
804 | |||
805 | while (config_regs->offset != 0xFFFFFFFF) { | ||
806 | switch (reg_type) { | ||
807 | case VEGA10_CONFIGREG_DIDT: | ||
808 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, config_regs->offset); | ||
809 | data &= ~config_regs->mask; | ||
810 | data |= ((config_regs->value << config_regs->shift) & config_regs->mask); | ||
811 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, config_regs->offset, data); | ||
812 | break; | ||
813 | case VEGA10_CONFIGREG_GCCAC: | ||
814 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG_GC_CAC, config_regs->offset); | ||
815 | data &= ~config_regs->mask; | ||
816 | data |= ((config_regs->value << config_regs->shift) & config_regs->mask); | ||
817 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG_GC_CAC, config_regs->offset, data); | ||
818 | break; | ||
819 | case VEGA10_CONFIGREG_SECAC: | ||
820 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG_SE_CAC, config_regs->offset); | ||
821 | data &= ~config_regs->mask; | ||
822 | data |= ((config_regs->value << config_regs->shift) & config_regs->mask); | ||
823 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG_SE_CAC, config_regs->offset, data); | ||
824 | break; | ||
825 | default: | ||
826 | return -EINVAL; | ||
827 | } | ||
828 | |||
829 | config_regs++; | ||
830 | } | ||
831 | |||
832 | return 0; | ||
833 | } | ||
834 | |||
835 | static int vega10_program_gc_didt_config_registers(struct pp_hwmgr *hwmgr, const struct vega10_didt_config_reg *config_regs) | ||
836 | { | ||
837 | uint32_t data; | ||
838 | |||
839 | while (config_regs->offset != 0xFFFFFFFF) { | ||
840 | data = cgs_read_register(hwmgr->device, config_regs->offset); | ||
841 | data &= ~config_regs->mask; | ||
842 | data |= ((config_regs->value << config_regs->shift) & config_regs->mask); | ||
843 | cgs_write_register(hwmgr->device, config_regs->offset, data); | ||
844 | config_regs++; | ||
845 | } | ||
846 | |||
847 | return 0; | ||
848 | } | ||
849 | |||
850 | static void vega10_didt_set_mask(struct pp_hwmgr *hwmgr, const bool enable) | ||
851 | { | ||
852 | uint32_t data; | ||
853 | int result; | ||
854 | uint32_t en = (enable ? 1 : 0); | ||
855 | uint32_t didt_block_info = SQ_IR_MASK | TCP_IR_MASK | TD_PCC_MASK; | ||
856 | |||
857 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SQRamping)) { | ||
858 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0); | ||
859 | data &= ~DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK; | ||
860 | data |= ((en << DIDT_SQ_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK); | ||
861 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0, data); | ||
862 | didt_block_info &= ~SQ_Enable_MASK; | ||
863 | didt_block_info |= en << SQ_Enable_SHIFT; | ||
864 | } | ||
865 | |||
866 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping)) { | ||
867 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0); | ||
868 | data &= ~DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK; | ||
869 | data |= ((en << DIDT_DB_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK); | ||
870 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0, data); | ||
871 | didt_block_info &= ~DB_Enable_MASK; | ||
872 | didt_block_info |= en << DB_Enable_SHIFT; | ||
873 | } | ||
874 | |||
875 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping)) { | ||
876 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0); | ||
877 | data &= ~DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK; | ||
878 | data |= ((en << DIDT_TD_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK); | ||
879 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0, data); | ||
880 | didt_block_info &= ~TD_Enable_MASK; | ||
881 | didt_block_info |= en << TD_Enable_SHIFT; | ||
882 | } | ||
883 | |||
884 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping)) { | ||
885 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0); | ||
886 | data &= ~DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK; | ||
887 | data |= ((en << DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK); | ||
888 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0, data); | ||
889 | didt_block_info &= ~TCP_Enable_MASK; | ||
890 | didt_block_info |= en << TCP_Enable_SHIFT; | ||
891 | } | ||
892 | |||
893 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRRamping)) { | ||
894 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DBR_CTRL0); | ||
895 | data &= ~DIDT_DBR_CTRL0__DIDT_CTRL_EN_MASK; | ||
896 | data |= ((en << DIDT_DBR_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_DBR_CTRL0__DIDT_CTRL_EN_MASK); | ||
897 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DBR_CTRL0, data); | ||
898 | } | ||
899 | |||
900 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DiDtEDCEnable)) { | ||
901 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SQRamping)) { | ||
902 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_EDC_CTRL); | ||
903 | data &= ~DIDT_SQ_EDC_CTRL__EDC_EN_MASK; | ||
904 | data |= ((en << DIDT_SQ_EDC_CTRL__EDC_EN__SHIFT) & DIDT_SQ_EDC_CTRL__EDC_EN_MASK); | ||
905 | data &= ~DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK; | ||
906 | data |= ((~en << DIDT_SQ_EDC_CTRL__EDC_SW_RST__SHIFT) & DIDT_SQ_EDC_CTRL__EDC_SW_RST_MASK); | ||
907 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_EDC_CTRL, data); | ||
908 | } | ||
909 | |||
910 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping)) { | ||
911 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_EDC_CTRL); | ||
912 | data &= ~DIDT_DB_EDC_CTRL__EDC_EN_MASK; | ||
913 | data |= ((en << DIDT_DB_EDC_CTRL__EDC_EN__SHIFT) & DIDT_DB_EDC_CTRL__EDC_EN_MASK); | ||
914 | data &= ~DIDT_DB_EDC_CTRL__EDC_SW_RST_MASK; | ||
915 | data |= ((~en << DIDT_DB_EDC_CTRL__EDC_SW_RST__SHIFT) & DIDT_DB_EDC_CTRL__EDC_SW_RST_MASK); | ||
916 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_EDC_CTRL, data); | ||
917 | } | ||
918 | |||
919 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping)) { | ||
920 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_EDC_CTRL); | ||
921 | data &= ~DIDT_TD_EDC_CTRL__EDC_EN_MASK; | ||
922 | data |= ((en << DIDT_TD_EDC_CTRL__EDC_EN__SHIFT) & DIDT_TD_EDC_CTRL__EDC_EN_MASK); | ||
923 | data &= ~DIDT_TD_EDC_CTRL__EDC_SW_RST_MASK; | ||
924 | data |= ((~en << DIDT_TD_EDC_CTRL__EDC_SW_RST__SHIFT) & DIDT_TD_EDC_CTRL__EDC_SW_RST_MASK); | ||
925 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_EDC_CTRL, data); | ||
926 | } | ||
927 | |||
928 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping)) { | ||
929 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_EDC_CTRL); | ||
930 | data &= ~DIDT_TCP_EDC_CTRL__EDC_EN_MASK; | ||
931 | data |= ((en << DIDT_TCP_EDC_CTRL__EDC_EN__SHIFT) & DIDT_TCP_EDC_CTRL__EDC_EN_MASK); | ||
932 | data &= ~DIDT_TCP_EDC_CTRL__EDC_SW_RST_MASK; | ||
933 | data |= ((~en << DIDT_TCP_EDC_CTRL__EDC_SW_RST__SHIFT) & DIDT_TCP_EDC_CTRL__EDC_SW_RST_MASK); | ||
934 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_EDC_CTRL, data); | ||
935 | } | ||
936 | |||
937 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRRamping)) { | ||
938 | data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DBR_EDC_CTRL); | ||
939 | data &= ~DIDT_DBR_EDC_CTRL__EDC_EN_MASK; | ||
940 | data |= ((en << DIDT_DBR_EDC_CTRL__EDC_EN__SHIFT) & DIDT_DBR_EDC_CTRL__EDC_EN_MASK); | ||
941 | data &= ~DIDT_DBR_EDC_CTRL__EDC_SW_RST_MASK; | ||
942 | data |= ((~en << DIDT_DBR_EDC_CTRL__EDC_SW_RST__SHIFT) & DIDT_DBR_EDC_CTRL__EDC_SW_RST_MASK); | ||
943 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DBR_EDC_CTRL, data); | ||
944 | } | ||
945 | } | ||
946 | |||
947 | if (enable) { | ||
948 | /* For Vega10, SMC does not support any mask yet. */ | ||
949 | result = smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_ConfigureGfxDidt, didt_block_info); | ||
950 | PP_ASSERT((0 == result), "[EnableDiDtConfig] SMC Configure Gfx Didt Failed!"); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | static int vega10_enable_cac_driving_se_didt_config(struct pp_hwmgr *hwmgr) | ||
955 | { | ||
956 | int result; | ||
957 | uint32_t num_se = 0, count, data; | ||
958 | struct cgs_system_info sys_info = {0}; | ||
959 | uint32_t reg; | ||
960 | |||
961 | sys_info.size = sizeof(struct cgs_system_info); | ||
962 | sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO; | ||
963 | if (cgs_query_system_info(hwmgr->device, &sys_info) == 0) | ||
964 | num_se = sys_info.value; | ||
965 | |||
966 | cgs_enter_safe_mode(hwmgr->device, true); | ||
967 | |||
968 | cgs_lock_grbm_idx(hwmgr->device, true); | ||
969 | reg = soc15_get_register_offset(GC_HWID, 0, mmGRBM_GFX_INDEX_BASE_IDX, mmGRBM_GFX_INDEX); | ||
970 | for (count = 0; count < num_se; count++) { | ||
971 | data = GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK | GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | ( count << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | ||
972 | cgs_write_register(hwmgr->device, reg, data); | ||
973 | |||
974 | result = vega10_program_didt_config_registers(hwmgr, SEDiDtStallCtrlConfig_vega10, VEGA10_CONFIGREG_DIDT); | ||
975 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtStallPatternConfig_vega10, VEGA10_CONFIGREG_DIDT); | ||
976 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtWeightConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
977 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl1Config_Vega10, VEGA10_CONFIGREG_DIDT); | ||
978 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl2Config_Vega10, VEGA10_CONFIGREG_DIDT); | ||
979 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl3Config_vega10, VEGA10_CONFIGREG_DIDT); | ||
980 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtTuningCtrlConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
981 | result |= vega10_program_didt_config_registers(hwmgr, SELCacConfig_Vega10, VEGA10_CONFIGREG_SECAC); | ||
982 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl0Config_Vega10, VEGA10_CONFIGREG_DIDT); | ||
983 | |||
984 | if (0 != result) | ||
985 | break; | ||
986 | } | ||
987 | cgs_write_register(hwmgr->device, reg, 0xE0000000); | ||
988 | cgs_lock_grbm_idx(hwmgr->device, false); | ||
989 | |||
990 | vega10_didt_set_mask(hwmgr, true); | ||
991 | |||
992 | cgs_enter_safe_mode(hwmgr->device, false); | ||
993 | |||
994 | return 0; | ||
995 | } | ||
996 | |||
997 | static int vega10_disable_cac_driving_se_didt_config(struct pp_hwmgr *hwmgr) | ||
998 | { | ||
999 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1000 | |||
1001 | vega10_didt_set_mask(hwmgr, false); | ||
1002 | |||
1003 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1004 | |||
1005 | return 0; | ||
1006 | } | ||
1007 | |||
1008 | static int vega10_enable_psm_gc_didt_config(struct pp_hwmgr *hwmgr) | ||
1009 | { | ||
1010 | int result; | ||
1011 | uint32_t num_se = 0, count, data; | ||
1012 | struct cgs_system_info sys_info = {0}; | ||
1013 | uint32_t reg; | ||
1014 | |||
1015 | sys_info.size = sizeof(struct cgs_system_info); | ||
1016 | sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO; | ||
1017 | if (cgs_query_system_info(hwmgr->device, &sys_info) == 0) | ||
1018 | num_se = sys_info.value; | ||
1019 | |||
1020 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1021 | |||
1022 | cgs_lock_grbm_idx(hwmgr->device, true); | ||
1023 | reg = soc15_get_register_offset(GC_HWID, 0, mmGRBM_GFX_INDEX_BASE_IDX, mmGRBM_GFX_INDEX); | ||
1024 | for (count = 0; count < num_se; count++) { | ||
1025 | data = GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK | GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | ( count << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | ||
1026 | cgs_write_register(hwmgr->device, reg, data); | ||
1027 | |||
1028 | result = vega10_program_didt_config_registers(hwmgr, SEDiDtStallCtrlConfig_vega10, VEGA10_CONFIGREG_DIDT); | ||
1029 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtStallPatternConfig_vega10, VEGA10_CONFIGREG_DIDT); | ||
1030 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl3Config_vega10, VEGA10_CONFIGREG_DIDT); | ||
1031 | result |= vega10_program_didt_config_registers(hwmgr, SEDiDtCtrl0Config_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1032 | if (0 != result) | ||
1033 | break; | ||
1034 | } | ||
1035 | cgs_write_register(hwmgr->device, reg, 0xE0000000); | ||
1036 | cgs_lock_grbm_idx(hwmgr->device, false); | ||
1037 | |||
1038 | vega10_didt_set_mask(hwmgr, true); | ||
1039 | |||
1040 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1041 | |||
1042 | vega10_program_gc_didt_config_registers(hwmgr, GCDiDtDroopCtrlConfig_vega10); | ||
1043 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_GCEDC)) | ||
1044 | vega10_program_gc_didt_config_registers(hwmgr, GCDiDtCtrl0Config_vega10); | ||
1045 | |||
1046 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PSM)) | ||
1047 | vega10_program_gc_didt_config_registers(hwmgr, AvfsPSMInitConfig_vega10); | ||
1048 | |||
1049 | return 0; | ||
1050 | } | ||
1051 | |||
1052 | static int vega10_disable_psm_gc_didt_config(struct pp_hwmgr *hwmgr) | ||
1053 | { | ||
1054 | uint32_t data; | ||
1055 | |||
1056 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1057 | |||
1058 | vega10_didt_set_mask(hwmgr, false); | ||
1059 | |||
1060 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1061 | |||
1062 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_GCEDC)) { | ||
1063 | data = 0x00000000; | ||
1064 | cgs_write_register(hwmgr->device, mmGC_DIDT_CTRL0, data); | ||
1065 | } | ||
1066 | |||
1067 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PSM)) | ||
1068 | vega10_program_gc_didt_config_registers(hwmgr, AvfsPSMResetConfig_vega10); | ||
1069 | |||
1070 | return 0; | ||
1071 | } | ||
1072 | |||
1073 | static int vega10_enable_se_edc_config(struct pp_hwmgr *hwmgr) | ||
1074 | { | ||
1075 | int result; | ||
1076 | uint32_t num_se = 0, count, data; | ||
1077 | struct cgs_system_info sys_info = {0}; | ||
1078 | uint32_t reg; | ||
1079 | |||
1080 | sys_info.size = sizeof(struct cgs_system_info); | ||
1081 | sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO; | ||
1082 | if (cgs_query_system_info(hwmgr->device, &sys_info) == 0) | ||
1083 | num_se = sys_info.value; | ||
1084 | |||
1085 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1086 | |||
1087 | cgs_lock_grbm_idx(hwmgr->device, true); | ||
1088 | reg = soc15_get_register_offset(GC_HWID, 0, mmGRBM_GFX_INDEX_BASE_IDX, mmGRBM_GFX_INDEX); | ||
1089 | for (count = 0; count < num_se; count++) { | ||
1090 | data = GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK | GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | ( count << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | ||
1091 | cgs_write_register(hwmgr->device, reg, data); | ||
1092 | result = vega10_program_didt_config_registers(hwmgr, SEDiDtWeightConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1093 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCStallPatternConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1094 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCStallDelayConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1095 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCThresholdConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1096 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCCtrlResetConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1097 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCCtrlConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1098 | |||
1099 | if (0 != result) | ||
1100 | break; | ||
1101 | } | ||
1102 | cgs_write_register(hwmgr->device, reg, 0xE0000000); | ||
1103 | cgs_lock_grbm_idx(hwmgr->device, false); | ||
1104 | |||
1105 | vega10_didt_set_mask(hwmgr, true); | ||
1106 | |||
1107 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1108 | |||
1109 | return 0; | ||
1110 | } | ||
1111 | |||
1112 | static int vega10_disable_se_edc_config(struct pp_hwmgr *hwmgr) | ||
1113 | { | ||
1114 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1115 | |||
1116 | vega10_didt_set_mask(hwmgr, false); | ||
1117 | |||
1118 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1119 | |||
1120 | return 0; | ||
1121 | } | ||
1122 | |||
1123 | static int vega10_enable_psm_gc_edc_config(struct pp_hwmgr *hwmgr) | ||
1124 | { | ||
1125 | int result; | ||
1126 | uint32_t num_se = 0; | ||
1127 | uint32_t count, data; | ||
1128 | struct cgs_system_info sys_info = {0}; | ||
1129 | uint32_t reg; | ||
1130 | |||
1131 | sys_info.size = sizeof(struct cgs_system_info); | ||
1132 | sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO; | ||
1133 | if (cgs_query_system_info(hwmgr->device, &sys_info) == 0) | ||
1134 | num_se = sys_info.value; | ||
1135 | |||
1136 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1137 | |||
1138 | vega10_program_gc_didt_config_registers(hwmgr, AvfsPSMResetConfig_vega10); | ||
1139 | |||
1140 | cgs_lock_grbm_idx(hwmgr->device, true); | ||
1141 | reg = soc15_get_register_offset(GC_HWID, 0, mmGRBM_GFX_INDEX_BASE_IDX, mmGRBM_GFX_INDEX); | ||
1142 | for (count = 0; count < num_se; count++) { | ||
1143 | data = GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK | GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | ( count << GRBM_GFX_INDEX__SE_INDEX__SHIFT); | ||
1144 | cgs_write_register(hwmgr->device, reg, data); | ||
1145 | result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCStallPatternConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1146 | result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCStallDelayConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1147 | result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCCtrlResetConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1148 | result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCCtrlConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1149 | |||
1150 | if (0 != result) | ||
1151 | break; | ||
1152 | } | ||
1153 | cgs_write_register(hwmgr->device, reg, 0xE0000000); | ||
1154 | cgs_lock_grbm_idx(hwmgr->device, false); | ||
1155 | |||
1156 | vega10_didt_set_mask(hwmgr, true); | ||
1157 | |||
1158 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1159 | |||
1160 | vega10_program_gc_didt_config_registers(hwmgr, PSMGCEDCDroopCtrlConfig_vega10); | ||
1161 | |||
1162 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_GCEDC)) { | ||
1163 | vega10_program_gc_didt_config_registers(hwmgr, PSMGCEDCCtrlResetConfig_vega10); | ||
1164 | vega10_program_gc_didt_config_registers(hwmgr, PSMGCEDCCtrlConfig_vega10); | ||
1165 | } | ||
1166 | |||
1167 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PSM)) | ||
1168 | vega10_program_gc_didt_config_registers(hwmgr, AvfsPSMInitConfig_vega10); | ||
1169 | |||
1170 | return 0; | ||
1171 | } | ||
1172 | |||
1173 | static int vega10_disable_psm_gc_edc_config(struct pp_hwmgr *hwmgr) | ||
1174 | { | ||
1175 | uint32_t data; | ||
1176 | |||
1177 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1178 | |||
1179 | vega10_didt_set_mask(hwmgr, false); | ||
1180 | |||
1181 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1182 | |||
1183 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_GCEDC)) { | ||
1184 | data = 0x00000000; | ||
1185 | cgs_write_register(hwmgr->device, mmGC_EDC_CTRL, data); | ||
1186 | } | ||
1187 | |||
1188 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PSM)) | ||
1189 | vega10_program_gc_didt_config_registers(hwmgr, AvfsPSMResetConfig_vega10); | ||
1190 | |||
1191 | return 0; | ||
1192 | } | ||
1193 | |||
1194 | static int vega10_enable_se_edc_force_stall_config(struct pp_hwmgr *hwmgr) | ||
1195 | { | ||
1196 | uint32_t reg; | ||
1197 | int result; | ||
1198 | |||
1199 | cgs_enter_safe_mode(hwmgr->device, true); | ||
1200 | |||
1201 | cgs_lock_grbm_idx(hwmgr->device, true); | ||
1202 | reg = soc15_get_register_offset(GC_HWID, 0, mmGRBM_GFX_INDEX_BASE_IDX, mmGRBM_GFX_INDEX); | ||
1203 | cgs_write_register(hwmgr->device, reg, 0xE0000000); | ||
1204 | cgs_lock_grbm_idx(hwmgr->device, false); | ||
1205 | |||
1206 | result = vega10_program_didt_config_registers(hwmgr, SEEDCForceStallPatternConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1207 | result |= vega10_program_didt_config_registers(hwmgr, SEEDCCtrlForceStallConfig_Vega10, VEGA10_CONFIGREG_DIDT); | ||
1208 | if (0 != result) | ||
1209 | return result; | ||
1210 | |||
1211 | vega10_didt_set_mask(hwmgr, true); | ||
1212 | |||
1213 | cgs_enter_safe_mode(hwmgr->device, false); | ||
1214 | |||
1215 | return 0; | ||
1216 | } | ||
1217 | |||
1218 | static int vega10_disable_se_edc_force_stall_config(struct pp_hwmgr *hwmgr) | ||
1219 | { | ||
1220 | int result; | ||
1221 | |||
1222 | result = vega10_disable_se_edc_config(hwmgr); | ||
1223 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDtConfig] Pre DIDT disable clock gating failed!", return result); | ||
1224 | |||
1225 | return 0; | ||
1226 | } | ||
1227 | |||
1228 | int vega10_enable_didt_config(struct pp_hwmgr *hwmgr) | ||
1229 | { | ||
1230 | int result = 0; | ||
1231 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); | ||
1232 | |||
1233 | if (data->smu_features[GNLD_DIDT].supported) { | ||
1234 | if (data->smu_features[GNLD_DIDT].enabled) | ||
1235 | PP_DBG_LOG("[EnableDiDtConfig] Feature DiDt Already enabled!\n"); | ||
1236 | |||
1237 | switch (data->registry_data.didt_mode) { | ||
1238 | case 0: | ||
1239 | result = vega10_enable_cac_driving_se_didt_config(hwmgr); | ||
1240 | PP_ASSERT_WITH_CODE((0 == result), "[EnableDiDt] Attempt to enable DiDt Mode 0 Failed!", return result); | ||
1241 | break; | ||
1242 | case 2: | ||
1243 | result = vega10_enable_psm_gc_didt_config(hwmgr); | ||
1244 | PP_ASSERT_WITH_CODE((0 == result), "[EnableDiDt] Attempt to enable DiDt Mode 2 Failed!", return result); | ||
1245 | break; | ||
1246 | case 3: | ||
1247 | result = vega10_enable_se_edc_config(hwmgr); | ||
1248 | PP_ASSERT_WITH_CODE((0 == result), "[EnableDiDt] Attempt to enable DiDt Mode 3 Failed!", return result); | ||
1249 | break; | ||
1250 | case 1: | ||
1251 | case 4: | ||
1252 | case 5: | ||
1253 | result = vega10_enable_psm_gc_edc_config(hwmgr); | ||
1254 | PP_ASSERT_WITH_CODE((0 == result), "[EnableDiDt] Attempt to enable DiDt Mode 5 Failed!", return result); | ||
1255 | break; | ||
1256 | case 6: | ||
1257 | result = vega10_enable_se_edc_force_stall_config(hwmgr); | ||
1258 | PP_ASSERT_WITH_CODE((0 == result), "[EnableDiDt] Attempt to enable DiDt Mode 6 Failed!", return result); | ||
1259 | break; | ||
1260 | default: | ||
1261 | result = -EINVAL; | ||
1262 | break; | ||
1263 | } | ||
1264 | |||
1265 | if (0 == result) { | ||
1266 | PP_ASSERT_WITH_CODE((!vega10_enable_smc_features(hwmgr->smumgr, true, data->smu_features[GNLD_DIDT].smu_feature_bitmap)), | ||
1267 | "[EnableDiDtConfig] Attempt to Enable DiDt feature Failed!", return result); | ||
1268 | data->smu_features[GNLD_DIDT].enabled = true; | ||
1269 | } | ||
1270 | } | ||
1271 | |||
1272 | return result; | ||
1273 | } | ||
1274 | |||
1275 | int vega10_disable_didt_config(struct pp_hwmgr *hwmgr) | ||
1276 | { | ||
1277 | int result = 0; | ||
1278 | struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend); | ||
1279 | |||
1280 | if (data->smu_features[GNLD_DIDT].supported) { | ||
1281 | if (!data->smu_features[GNLD_DIDT].enabled) | ||
1282 | PP_DBG_LOG("[DisableDiDtConfig] Feature DiDt Already Disabled!\n"); | ||
1283 | |||
1284 | switch (data->registry_data.didt_mode) { | ||
1285 | case 0: | ||
1286 | result = vega10_disable_cac_driving_se_didt_config(hwmgr); | ||
1287 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDt] Attempt to disable DiDt Mode 0 Failed!", return result); | ||
1288 | break; | ||
1289 | case 2: | ||
1290 | result = vega10_disable_psm_gc_didt_config(hwmgr); | ||
1291 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDt] Attempt to disable DiDt Mode 2 Failed!", return result); | ||
1292 | break; | ||
1293 | case 3: | ||
1294 | result = vega10_disable_se_edc_config(hwmgr); | ||
1295 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDt] Attempt to disable DiDt Mode 3 Failed!", return result); | ||
1296 | break; | ||
1297 | case 1: | ||
1298 | case 4: | ||
1299 | case 5: | ||
1300 | result = vega10_disable_psm_gc_edc_config(hwmgr); | ||
1301 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDt] Attempt to disable DiDt Mode 5 Failed!", return result); | ||
1302 | break; | ||
1303 | case 6: | ||
1304 | result = vega10_disable_se_edc_force_stall_config(hwmgr); | ||
1305 | PP_ASSERT_WITH_CODE((0 == result), "[DisableDiDt] Attempt to disable DiDt Mode 6 Failed!", return result); | ||
1306 | break; | ||
1307 | default: | ||
1308 | result = -EINVAL; | ||
1309 | break; | ||
1310 | } | ||
1311 | |||
1312 | if (0 == result) { | ||
1313 | PP_ASSERT_WITH_CODE((0 != vega10_enable_smc_features(hwmgr->smumgr, false, data->smu_features[GNLD_DIDT].smu_feature_bitmap)), | ||
1314 | "[DisableDiDtConfig] Attempt to Disable DiDt feature Failed!", return result); | ||
1315 | data->smu_features[GNLD_DIDT].enabled = false; | ||
1316 | } | ||
1317 | } | ||
1318 | |||
1319 | return result; | ||
1320 | } | ||
30 | 1321 | ||
31 | void vega10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr) | 1322 | void vega10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr) |
32 | { | 1323 | { |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.h index 9ecaa27c0bb5..b95771ab89cd 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.h | |||
@@ -31,6 +31,12 @@ enum vega10_pt_config_reg_type { | |||
31 | VEGA10_CONFIGREG_MAX | 31 | VEGA10_CONFIGREG_MAX |
32 | }; | 32 | }; |
33 | 33 | ||
34 | enum vega10_didt_config_reg_type { | ||
35 | VEGA10_CONFIGREG_DIDT = 0, | ||
36 | VEGA10_CONFIGREG_GCCAC, | ||
37 | VEGA10_CONFIGREG_SECAC | ||
38 | }; | ||
39 | |||
34 | /* PowerContainment Features */ | 40 | /* PowerContainment Features */ |
35 | #define POWERCONTAINMENT_FEATURE_DTE 0x00000001 | 41 | #define POWERCONTAINMENT_FEATURE_DTE 0x00000001 |
36 | #define POWERCONTAINMENT_FEATURE_TDCLimit 0x00000002 | 42 | #define POWERCONTAINMENT_FEATURE_TDCLimit 0x00000002 |
@@ -44,6 +50,13 @@ struct vega10_pt_config_reg { | |||
44 | enum vega10_pt_config_reg_type type; | 50 | enum vega10_pt_config_reg_type type; |
45 | }; | 51 | }; |
46 | 52 | ||
53 | struct vega10_didt_config_reg { | ||
54 | uint32_t offset; | ||
55 | uint32_t mask; | ||
56 | uint32_t shift; | ||
57 | uint32_t value; | ||
58 | }; | ||
59 | |||
47 | struct vega10_pt_defaults { | 60 | struct vega10_pt_defaults { |
48 | uint8_t SviLoadLineEn; | 61 | uint8_t SviLoadLineEn; |
49 | uint8_t SviLoadLineVddC; | 62 | uint8_t SviLoadLineVddC; |
@@ -62,5 +75,8 @@ int vega10_set_power_limit(struct pp_hwmgr *hwmgr, uint32_t n); | |||
62 | int vega10_power_control_set_level(struct pp_hwmgr *hwmgr); | 75 | int vega10_power_control_set_level(struct pp_hwmgr *hwmgr); |
63 | int vega10_disable_power_containment(struct pp_hwmgr *hwmgr); | 76 | int vega10_disable_power_containment(struct pp_hwmgr *hwmgr); |
64 | 77 | ||
78 | int vega10_enable_didt_config(struct pp_hwmgr *hwmgr); | ||
79 | int vega10_disable_didt_config(struct pp_hwmgr *hwmgr); | ||
80 | |||
65 | #endif /* _VEGA10_POWERTUNE_H_ */ | 81 | #endif /* _VEGA10_POWERTUNE_H_ */ |
66 | 82 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c index 1623644ea49a..e343df190375 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include "cgs_common.h" | 31 | #include "cgs_common.h" |
32 | #include "vega10_pptable.h" | 32 | #include "vega10_pptable.h" |
33 | 33 | ||
34 | #define NUM_DSPCLK_LEVELS 8 | ||
35 | |||
34 | static void set_hw_cap(struct pp_hwmgr *hwmgr, bool enable, | 36 | static void set_hw_cap(struct pp_hwmgr *hwmgr, bool enable, |
35 | enum phm_platform_caps cap) | 37 | enum phm_platform_caps cap) |
36 | { | 38 | { |
@@ -644,11 +646,11 @@ static int get_gfxclk_voltage_dependency_table( | |||
644 | return 0; | 646 | return 0; |
645 | } | 647 | } |
646 | 648 | ||
647 | static int get_dcefclk_voltage_dependency_table( | 649 | static int get_pix_clk_voltage_dependency_table( |
648 | struct pp_hwmgr *hwmgr, | 650 | struct pp_hwmgr *hwmgr, |
649 | struct phm_ppt_v1_clock_voltage_dependency_table | 651 | struct phm_ppt_v1_clock_voltage_dependency_table |
650 | **pp_vega10_clk_dep_table, | 652 | **pp_vega10_clk_dep_table, |
651 | const ATOM_Vega10_DCEFCLK_Dependency_Table *clk_dep_table) | 653 | const ATOM_Vega10_PIXCLK_Dependency_Table *clk_dep_table) |
652 | { | 654 | { |
653 | uint32_t table_size, i; | 655 | uint32_t table_size, i; |
654 | struct phm_ppt_v1_clock_voltage_dependency_table | 656 | struct phm_ppt_v1_clock_voltage_dependency_table |
@@ -681,6 +683,76 @@ static int get_dcefclk_voltage_dependency_table( | |||
681 | return 0; | 683 | return 0; |
682 | } | 684 | } |
683 | 685 | ||
686 | static int get_dcefclk_voltage_dependency_table( | ||
687 | struct pp_hwmgr *hwmgr, | ||
688 | struct phm_ppt_v1_clock_voltage_dependency_table | ||
689 | **pp_vega10_clk_dep_table, | ||
690 | const ATOM_Vega10_DCEFCLK_Dependency_Table *clk_dep_table) | ||
691 | { | ||
692 | uint32_t table_size, i; | ||
693 | uint8_t num_entries; | ||
694 | struct phm_ppt_v1_clock_voltage_dependency_table | ||
695 | *clk_table; | ||
696 | struct cgs_system_info sys_info = {0}; | ||
697 | uint32_t dev_id; | ||
698 | uint32_t rev_id; | ||
699 | |||
700 | PP_ASSERT_WITH_CODE((clk_dep_table->ucNumEntries != 0), | ||
701 | "Invalid PowerPlay Table!", return -1); | ||
702 | |||
703 | /* | ||
704 | * workaround needed to add another DPM level for pioneer cards | ||
705 | * as VBIOS is locked down. | ||
706 | * This DPM level was added to support 3DPM monitors @ 4K120Hz | ||
707 | * | ||
708 | */ | ||
709 | sys_info.size = sizeof(struct cgs_system_info); | ||
710 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_DEV; | ||
711 | cgs_query_system_info(hwmgr->device, &sys_info); | ||
712 | dev_id = (uint32_t)sys_info.value; | ||
713 | |||
714 | sys_info.size = sizeof(struct cgs_system_info); | ||
715 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_REV; | ||
716 | cgs_query_system_info(hwmgr->device, &sys_info); | ||
717 | rev_id = (uint32_t)sys_info.value; | ||
718 | |||
719 | if (dev_id == 0x6863 && rev_id == 0 && | ||
720 | clk_dep_table->entries[clk_dep_table->ucNumEntries - 1].ulClk < 90000) | ||
721 | num_entries = clk_dep_table->ucNumEntries + 1 > NUM_DSPCLK_LEVELS ? | ||
722 | NUM_DSPCLK_LEVELS : clk_dep_table->ucNumEntries + 1; | ||
723 | else | ||
724 | num_entries = clk_dep_table->ucNumEntries; | ||
725 | |||
726 | |||
727 | table_size = sizeof(uint32_t) + | ||
728 | sizeof(phm_ppt_v1_clock_voltage_dependency_record) * | ||
729 | num_entries; | ||
730 | |||
731 | clk_table = (struct phm_ppt_v1_clock_voltage_dependency_table *) | ||
732 | kzalloc(table_size, GFP_KERNEL); | ||
733 | |||
734 | if (!clk_table) | ||
735 | return -ENOMEM; | ||
736 | |||
737 | clk_table->count = (uint32_t)num_entries; | ||
738 | |||
739 | for (i = 0; i < clk_dep_table->ucNumEntries; i++) { | ||
740 | clk_table->entries[i].vddInd = | ||
741 | clk_dep_table->entries[i].ucVddInd; | ||
742 | clk_table->entries[i].clk = | ||
743 | le32_to_cpu(clk_dep_table->entries[i].ulClk); | ||
744 | } | ||
745 | |||
746 | if (i < num_entries) { | ||
747 | clk_table->entries[i].vddInd = clk_dep_table->entries[i-1].ucVddInd; | ||
748 | clk_table->entries[i].clk = 90000; | ||
749 | } | ||
750 | |||
751 | *pp_vega10_clk_dep_table = clk_table; | ||
752 | |||
753 | return 0; | ||
754 | } | ||
755 | |||
684 | static int get_pcie_table(struct pp_hwmgr *hwmgr, | 756 | static int get_pcie_table(struct pp_hwmgr *hwmgr, |
685 | struct phm_ppt_v1_pcie_table **vega10_pcie_table, | 757 | struct phm_ppt_v1_pcie_table **vega10_pcie_table, |
686 | const Vega10_PPTable_Generic_SubTable_Header *table) | 758 | const Vega10_PPTable_Generic_SubTable_Header *table) |
@@ -862,21 +934,21 @@ static int init_powerplay_extended_tables( | |||
862 | gfxclk_dep_table); | 934 | gfxclk_dep_table); |
863 | 935 | ||
864 | if (!result && powerplay_table->usPixclkDependencyTableOffset) | 936 | if (!result && powerplay_table->usPixclkDependencyTableOffset) |
865 | result = get_dcefclk_voltage_dependency_table(hwmgr, | 937 | result = get_pix_clk_voltage_dependency_table(hwmgr, |
866 | &pp_table_info->vdd_dep_on_pixclk, | 938 | &pp_table_info->vdd_dep_on_pixclk, |
867 | (const ATOM_Vega10_DCEFCLK_Dependency_Table*) | 939 | (const ATOM_Vega10_PIXCLK_Dependency_Table*) |
868 | pixclk_dep_table); | 940 | pixclk_dep_table); |
869 | 941 | ||
870 | if (!result && powerplay_table->usPhyClkDependencyTableOffset) | 942 | if (!result && powerplay_table->usPhyClkDependencyTableOffset) |
871 | result = get_dcefclk_voltage_dependency_table(hwmgr, | 943 | result = get_pix_clk_voltage_dependency_table(hwmgr, |
872 | &pp_table_info->vdd_dep_on_phyclk, | 944 | &pp_table_info->vdd_dep_on_phyclk, |
873 | (const ATOM_Vega10_DCEFCLK_Dependency_Table *) | 945 | (const ATOM_Vega10_PIXCLK_Dependency_Table *) |
874 | phyclk_dep_table); | 946 | phyclk_dep_table); |
875 | 947 | ||
876 | if (!result && powerplay_table->usDispClkDependencyTableOffset) | 948 | if (!result && powerplay_table->usDispClkDependencyTableOffset) |
877 | result = get_dcefclk_voltage_dependency_table(hwmgr, | 949 | result = get_pix_clk_voltage_dependency_table(hwmgr, |
878 | &pp_table_info->vdd_dep_on_dispclk, | 950 | &pp_table_info->vdd_dep_on_dispclk, |
879 | (const ATOM_Vega10_DCEFCLK_Dependency_Table *) | 951 | (const ATOM_Vega10_PIXCLK_Dependency_Table *) |
880 | dispclk_dep_table); | 952 | dispclk_dep_table); |
881 | 953 | ||
882 | if (!result && powerplay_table->usDcefclkDependencyTableOffset) | 954 | if (!result && powerplay_table->usDcefclkDependencyTableOffset) |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h index a1ebe1014492..a4c8b09b6f14 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | |||
@@ -164,9 +164,14 @@ enum phm_platform_caps { | |||
164 | PHM_PlatformCaps_EnablePlatformPowerManagement, /* indicates that Platform Power Management feature is supported */ | 164 | PHM_PlatformCaps_EnablePlatformPowerManagement, /* indicates that Platform Power Management feature is supported */ |
165 | PHM_PlatformCaps_SurpriseRemoval, /* indicates that surprise removal feature is requested */ | 165 | PHM_PlatformCaps_SurpriseRemoval, /* indicates that surprise removal feature is requested */ |
166 | PHM_PlatformCaps_NewCACVoltage, /* indicates new CAC voltage table support */ | 166 | PHM_PlatformCaps_NewCACVoltage, /* indicates new CAC voltage table support */ |
167 | PHM_PlatformCaps_DiDtSupport, /* for dI/dT feature */ | ||
167 | PHM_PlatformCaps_DBRamping, /* for dI/dT feature */ | 168 | PHM_PlatformCaps_DBRamping, /* for dI/dT feature */ |
168 | PHM_PlatformCaps_TDRamping, /* for dI/dT feature */ | 169 | PHM_PlatformCaps_TDRamping, /* for dI/dT feature */ |
169 | PHM_PlatformCaps_TCPRamping, /* for dI/dT feature */ | 170 | PHM_PlatformCaps_TCPRamping, /* for dI/dT feature */ |
171 | PHM_PlatformCaps_DBRRamping, /* for dI/dT feature */ | ||
172 | PHM_PlatformCaps_DiDtEDCEnable, /* for dI/dT feature */ | ||
173 | PHM_PlatformCaps_GCEDC, /* for dI/dT feature */ | ||
174 | PHM_PlatformCaps_PSM, /* for dI/dT feature */ | ||
170 | PHM_PlatformCaps_EnableSMU7ThermalManagement, /* SMC will manage thermal events */ | 175 | PHM_PlatformCaps_EnableSMU7ThermalManagement, /* SMC will manage thermal events */ |
171 | PHM_PlatformCaps_FPS, /* FPS support */ | 176 | PHM_PlatformCaps_FPS, /* FPS support */ |
172 | PHM_PlatformCaps_ACP, /* ACP support */ | 177 | PHM_PlatformCaps_ACP, /* ACP support */ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h b/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h index f3f9ebb631a5..822cd8b5bf90 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h +++ b/drivers/gpu/drm/amd/powerplay/inc/pp_debug.h | |||
@@ -42,6 +42,12 @@ | |||
42 | } \ | 42 | } \ |
43 | } while (0) | 43 | } while (0) |
44 | 44 | ||
45 | #define PP_ASSERT(cond, msg) \ | ||
46 | do { \ | ||
47 | if (!(cond)) { \ | ||
48 | pr_warn("%s\n", msg); \ | ||
49 | } \ | ||
50 | } while (0) | ||
45 | 51 | ||
46 | #define PP_DBG_LOG(fmt, ...) \ | 52 | #define PP_DBG_LOG(fmt, ...) \ |
47 | do { \ | 53 | do { \ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_soc15.h b/drivers/gpu/drm/amd/powerplay/inc/pp_soc15.h index 227d999b6bd1..a511611ec7e0 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/pp_soc15.h +++ b/drivers/gpu/drm/amd/powerplay/inc/pp_soc15.h | |||
@@ -41,6 +41,8 @@ inline static uint32_t soc15_get_register_offset( | |||
41 | reg = MP1_BASE.instance[inst].segment[segment] + offset; | 41 | reg = MP1_BASE.instance[inst].segment[segment] + offset; |
42 | else if (hw_id == DF_HWID) | 42 | else if (hw_id == DF_HWID) |
43 | reg = DF_BASE.instance[inst].segment[segment] + offset; | 43 | reg = DF_BASE.instance[inst].segment[segment] + offset; |
44 | else if (hw_id == GC_HWID) | ||
45 | reg = GC_BASE.instance[inst].segment[segment] + offset; | ||
44 | 46 | ||
45 | return reg; | 47 | return reg; |
46 | } | 48 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu9.h b/drivers/gpu/drm/amd/powerplay/inc/smu9.h index 9ef2490c7c2e..550ed675027a 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smu9.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smu9.h | |||
@@ -55,9 +55,9 @@ | |||
55 | #define FEATURE_FW_CTF_BIT 23 | 55 | #define FEATURE_FW_CTF_BIT 23 |
56 | #define FEATURE_LED_DISPLAY_BIT 24 | 56 | #define FEATURE_LED_DISPLAY_BIT 24 |
57 | #define FEATURE_FAN_CONTROL_BIT 25 | 57 | #define FEATURE_FAN_CONTROL_BIT 25 |
58 | #define FEATURE_VOLTAGE_CONTROLLER_BIT 26 | 58 | #define FEATURE_FAST_PPT_BIT 26 |
59 | #define FEATURE_SPARE_27_BIT 27 | 59 | #define FEATURE_GFX_EDC_BIT 27 |
60 | #define FEATURE_SPARE_28_BIT 28 | 60 | #define FEATURE_ACG_BIT 28 |
61 | #define FEATURE_SPARE_29_BIT 29 | 61 | #define FEATURE_SPARE_29_BIT 29 |
62 | #define FEATURE_SPARE_30_BIT 30 | 62 | #define FEATURE_SPARE_30_BIT 30 |
63 | #define FEATURE_SPARE_31_BIT 31 | 63 | #define FEATURE_SPARE_31_BIT 31 |
@@ -90,9 +90,10 @@ | |||
90 | #define FFEATURE_FW_CTF_MASK (1 << FEATURE_FW_CTF_BIT ) | 90 | #define FFEATURE_FW_CTF_MASK (1 << FEATURE_FW_CTF_BIT ) |
91 | #define FFEATURE_LED_DISPLAY_MASK (1 << FEATURE_LED_DISPLAY_BIT ) | 91 | #define FFEATURE_LED_DISPLAY_MASK (1 << FEATURE_LED_DISPLAY_BIT ) |
92 | #define FFEATURE_FAN_CONTROL_MASK (1 << FEATURE_FAN_CONTROL_BIT ) | 92 | #define FFEATURE_FAN_CONTROL_MASK (1 << FEATURE_FAN_CONTROL_BIT ) |
93 | #define FFEATURE_VOLTAGE_CONTROLLER_MASK (1 << FEATURE_VOLTAGE_CONTROLLER_BIT ) | 93 | |
94 | #define FFEATURE_SPARE_27_MASK (1 << FEATURE_SPARE_27_BIT ) | 94 | #define FEATURE_FAST_PPT_MASK (1 << FAST_PPT_BIT ) |
95 | #define FFEATURE_SPARE_28_MASK (1 << FEATURE_SPARE_28_BIT ) | 95 | #define FEATURE_GFX_EDC_MASK (1 << FEATURE_GFX_EDC_BIT ) |
96 | #define FEATURE_ACG_MASK (1 << FEATURE_ACG_BIT ) | ||
96 | #define FFEATURE_SPARE_29_MASK (1 << FEATURE_SPARE_29_BIT ) | 97 | #define FFEATURE_SPARE_29_MASK (1 << FEATURE_SPARE_29_BIT ) |
97 | #define FFEATURE_SPARE_30_MASK (1 << FEATURE_SPARE_30_BIT ) | 98 | #define FFEATURE_SPARE_30_MASK (1 << FEATURE_SPARE_30_BIT ) |
98 | #define FFEATURE_SPARE_31_MASK (1 << FEATURE_SPARE_31_BIT ) | 99 | #define FFEATURE_SPARE_31_MASK (1 << FEATURE_SPARE_31_BIT ) |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu9_driver_if.h b/drivers/gpu/drm/amd/powerplay/inc/smu9_driver_if.h index 532186b6f941..f6d6c61f796a 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smu9_driver_if.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smu9_driver_if.h | |||
@@ -312,7 +312,10 @@ typedef struct { | |||
312 | 312 | ||
313 | PllSetting_t GfxBoostState; | 313 | PllSetting_t GfxBoostState; |
314 | 314 | ||
315 | uint32_t Reserved[14]; | 315 | uint8_t AcgEnable[NUM_GFXCLK_DPM_LEVELS]; |
316 | GbVdroopTable_t AcgBtcGbVdroopTable; | ||
317 | QuadraticInt_t AcgAvfsGb; | ||
318 | uint32_t Reserved[4]; | ||
316 | 319 | ||
317 | /* Padding - ignore */ | 320 | /* Padding - ignore */ |
318 | uint32_t MmHubPadding[7]; /* SMU internal use */ | 321 | uint32_t MmHubPadding[7]; /* SMU internal use */ |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h index 976e942ec694..5d61cc9d4554 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h | |||
@@ -131,6 +131,7 @@ struct pp_smumgr_func { | |||
131 | bool (*is_dpm_running)(struct pp_hwmgr *hwmgr); | 131 | bool (*is_dpm_running)(struct pp_hwmgr *hwmgr); |
132 | int (*populate_requested_graphic_levels)(struct pp_hwmgr *hwmgr, | 132 | int (*populate_requested_graphic_levels)(struct pp_hwmgr *hwmgr, |
133 | struct amd_pp_profile *request); | 133 | struct amd_pp_profile *request); |
134 | bool (*is_hw_avfs_present)(struct pp_smumgr *smumgr); | ||
134 | }; | 135 | }; |
135 | 136 | ||
136 | struct pp_smumgr { | 137 | struct pp_smumgr { |
@@ -202,6 +203,8 @@ extern bool smum_is_dpm_running(struct pp_hwmgr *hwmgr); | |||
202 | extern int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, | 203 | extern int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, |
203 | struct amd_pp_profile *request); | 204 | struct amd_pp_profile *request); |
204 | 205 | ||
206 | extern bool smum_is_hw_avfs_present(struct pp_smumgr *smumgr); | ||
207 | |||
205 | #define SMUM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT | 208 | #define SMUM_FIELD_SHIFT(reg, field) reg##__##field##__SHIFT |
206 | 209 | ||
207 | #define SMUM_FIELD_MASK(reg, field) reg##__##field##_MASK | 210 | #define SMUM_FIELD_MASK(reg, field) reg##__##field##_MASK |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/vega10_ppsmc.h b/drivers/gpu/drm/amd/powerplay/inc/vega10_ppsmc.h index b4af9e85dfa5..cb070ebc7de1 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/vega10_ppsmc.h +++ b/drivers/gpu/drm/amd/powerplay/inc/vega10_ppsmc.h | |||
@@ -124,6 +124,10 @@ typedef uint16_t PPSMC_Result; | |||
124 | #define PPSMC_MSG_NumOfDisplays 0x56 | 124 | #define PPSMC_MSG_NumOfDisplays 0x56 |
125 | #define PPSMC_MSG_ReadSerialNumTop32 0x58 | 125 | #define PPSMC_MSG_ReadSerialNumTop32 0x58 |
126 | #define PPSMC_MSG_ReadSerialNumBottom32 0x59 | 126 | #define PPSMC_MSG_ReadSerialNumBottom32 0x59 |
127 | #define PPSMC_MSG_RunAcgBtc 0x5C | ||
128 | #define PPSMC_MSG_RunAcgInClosedLoop 0x5D | ||
129 | #define PPSMC_MSG_RunAcgInOpenLoop 0x5E | ||
130 | #define PPSMC_MSG_InitializeAcg 0x5F | ||
127 | #define PPSMC_MSG_GetCurrPkgPwr 0x61 | 131 | #define PPSMC_MSG_GetCurrPkgPwr 0x61 |
128 | #define PPSMC_Message_Count 0x62 | 132 | #define PPSMC_Message_Count 0x62 |
129 | 133 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.c index 6a320b27aefd..8712f093d6d9 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.c | |||
@@ -2129,6 +2129,25 @@ int fiji_thermal_setup_fan_table(struct pp_hwmgr *hwmgr) | |||
2129 | return 0; | 2129 | return 0; |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | |||
2133 | int fiji_thermal_avfs_enable(struct pp_hwmgr *hwmgr) | ||
2134 | { | ||
2135 | int ret; | ||
2136 | struct pp_smumgr *smumgr = (struct pp_smumgr *)(hwmgr->smumgr); | ||
2137 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); | ||
2138 | |||
2139 | if (smu_data->avfs.avfs_btc_status != AVFS_BTC_ENABLEAVFS) | ||
2140 | return 0; | ||
2141 | |||
2142 | ret = smum_send_msg_to_smc(smumgr, PPSMC_MSG_EnableAvfs); | ||
2143 | |||
2144 | if (!ret) | ||
2145 | /* If this param is not changed, this function could fire unnecessarily */ | ||
2146 | smu_data->avfs.avfs_btc_status = AVFS_BTC_COMPLETED_PREVIOUSLY; | ||
2147 | |||
2148 | return ret; | ||
2149 | } | ||
2150 | |||
2132 | static int fiji_program_mem_timing_parameters(struct pp_hwmgr *hwmgr) | 2151 | static int fiji_program_mem_timing_parameters(struct pp_hwmgr *hwmgr) |
2133 | { | 2152 | { |
2134 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); | 2153 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.h b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.h index 0e9e1f2d7238..d9c72d992e30 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.h | |||
@@ -48,5 +48,6 @@ int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr); | |||
48 | bool fiji_is_dpm_running(struct pp_hwmgr *hwmgr); | 48 | bool fiji_is_dpm_running(struct pp_hwmgr *hwmgr); |
49 | int fiji_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, | 49 | int fiji_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, |
50 | struct amd_pp_profile *request); | 50 | struct amd_pp_profile *request); |
51 | int fiji_thermal_avfs_enable(struct pp_hwmgr *hwmgr); | ||
51 | #endif | 52 | #endif |
52 | 53 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c index a1cb78552cf6..6ae948fc524f 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | |||
@@ -161,56 +161,47 @@ static int fiji_start_smu_in_non_protection_mode(struct pp_smumgr *smumgr) | |||
161 | 161 | ||
162 | static int fiji_setup_pwr_virus(struct pp_smumgr *smumgr) | 162 | static int fiji_setup_pwr_virus(struct pp_smumgr *smumgr) |
163 | { | 163 | { |
164 | int i, result = -1; | 164 | int i; |
165 | int result = -EINVAL; | ||
165 | uint32_t reg, data; | 166 | uint32_t reg, data; |
166 | const PWR_Command_Table *virus = PwrVirusTable; | ||
167 | struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | ||
168 | 167 | ||
169 | priv->avfs.AvfsBtcStatus = AVFS_LOAD_VIRUS; | 168 | const PWR_Command_Table *pvirus = PwrVirusTable; |
170 | for (i = 0; (i < PWR_VIRUS_TABLE_SIZE); i++) { | 169 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
171 | switch (virus->command) { | 170 | |
171 | for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) { | ||
172 | switch (pvirus->command) { | ||
172 | case PwrCmdWrite: | 173 | case PwrCmdWrite: |
173 | reg = virus->reg; | 174 | reg = pvirus->reg; |
174 | data = virus->data; | 175 | data = pvirus->data; |
175 | cgs_write_register(smumgr->device, reg, data); | 176 | cgs_write_register(smumgr->device, reg, data); |
176 | break; | 177 | break; |
178 | |||
177 | case PwrCmdEnd: | 179 | case PwrCmdEnd: |
178 | priv->avfs.AvfsBtcStatus = AVFS_BTC_VIRUS_LOADED; | ||
179 | result = 0; | 180 | result = 0; |
180 | break; | 181 | break; |
182 | |||
181 | default: | 183 | default: |
182 | pr_err("Table Exit with Invalid Command!"); | 184 | pr_info("Table Exit with Invalid Command!"); |
183 | priv->avfs.AvfsBtcStatus = AVFS_BTC_VIRUS_FAIL; | 185 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
184 | result = -1; | 186 | result = -EINVAL; |
185 | break; | 187 | break; |
186 | } | 188 | } |
187 | virus++; | 189 | pvirus++; |
188 | } | 190 | } |
191 | |||
189 | return result; | 192 | return result; |
190 | } | 193 | } |
191 | 194 | ||
192 | static int fiji_start_avfs_btc(struct pp_smumgr *smumgr) | 195 | static int fiji_start_avfs_btc(struct pp_smumgr *smumgr) |
193 | { | 196 | { |
194 | int result = 0; | 197 | int result = 0; |
195 | struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | 198 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
196 | 199 | ||
197 | priv->avfs.AvfsBtcStatus = AVFS_BTC_STARTED; | 200 | if (0 != smu_data->avfs.avfs_btc_param) { |
198 | if (priv->avfs.AvfsBtcParam) { | 201 | if (0 != smu7_send_msg_to_smc_with_parameter(smumgr, |
199 | if (!smum_send_msg_to_smc_with_parameter(smumgr, | 202 | PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) { |
200 | PPSMC_MSG_PerformBtc, priv->avfs.AvfsBtcParam)) { | 203 | pr_info("[AVFS][Fiji_PerformBtc] PerformBTC SMU msg failed"); |
201 | if (!smum_send_msg_to_smc(smumgr, PPSMC_MSG_EnableAvfs)) { | 204 | result = -EINVAL; |
202 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_UNSAVED; | ||
203 | result = 0; | ||
204 | } else { | ||
205 | pr_err("[AVFS][fiji_start_avfs_btc] Attempt" | ||
206 | " to Enable AVFS Failed!"); | ||
207 | smum_send_msg_to_smc(smumgr, PPSMC_MSG_DisableAvfs); | ||
208 | result = -1; | ||
209 | } | ||
210 | } else { | ||
211 | pr_err("[AVFS][fiji_start_avfs_btc] " | ||
212 | "PerformBTC SMU msg failed"); | ||
213 | result = -1; | ||
214 | } | 205 | } |
215 | } | 206 | } |
216 | /* Soft-Reset to reset the engine before loading uCode */ | 207 | /* Soft-Reset to reset the engine before loading uCode */ |
@@ -224,42 +215,6 @@ static int fiji_start_avfs_btc(struct pp_smumgr *smumgr) | |||
224 | return result; | 215 | return result; |
225 | } | 216 | } |
226 | 217 | ||
227 | static int fiji_setup_pm_fuse_for_avfs(struct pp_smumgr *smumgr) | ||
228 | { | ||
229 | int result = 0; | ||
230 | uint32_t table_start; | ||
231 | uint32_t charz_freq_addr, inversion_voltage_addr, charz_freq; | ||
232 | uint16_t inversion_voltage; | ||
233 | |||
234 | charz_freq = 0x30750000; /* In 10KHz units 0x00007530 Actual value */ | ||
235 | inversion_voltage = 0x1A04; /* mV Q14.2 0x41A Actual value */ | ||
236 | |||
237 | PP_ASSERT_WITH_CODE(0 == smu7_read_smc_sram_dword(smumgr, | ||
238 | SMU7_FIRMWARE_HEADER_LOCATION + offsetof(SMU73_Firmware_Header, | ||
239 | PmFuseTable), &table_start, 0x40000), | ||
240 | "[AVFS][Fiji_SetupGfxLvlStruct] SMU could not communicate " | ||
241 | "starting address of PmFuse structure", | ||
242 | return -1;); | ||
243 | |||
244 | charz_freq_addr = table_start + | ||
245 | offsetof(struct SMU73_Discrete_PmFuses, PsmCharzFreq); | ||
246 | inversion_voltage_addr = table_start + | ||
247 | offsetof(struct SMU73_Discrete_PmFuses, InversionVoltage); | ||
248 | |||
249 | result = smu7_copy_bytes_to_smc(smumgr, charz_freq_addr, | ||
250 | (uint8_t *)(&charz_freq), sizeof(charz_freq), 0x40000); | ||
251 | PP_ASSERT_WITH_CODE(0 == result, | ||
252 | "[AVFS][fiji_setup_pm_fuse_for_avfs] charz_freq could not " | ||
253 | "be populated.", return -1;); | ||
254 | |||
255 | result = smu7_copy_bytes_to_smc(smumgr, inversion_voltage_addr, | ||
256 | (uint8_t *)(&inversion_voltage), sizeof(inversion_voltage), 0x40000); | ||
257 | PP_ASSERT_WITH_CODE(0 == result, "[AVFS][fiji_setup_pm_fuse_for_avfs] " | ||
258 | "charz_freq could not be populated.", return -1;); | ||
259 | |||
260 | return result; | ||
261 | } | ||
262 | |||
263 | static int fiji_setup_graphics_level_structure(struct pp_smumgr *smumgr) | 218 | static int fiji_setup_graphics_level_structure(struct pp_smumgr *smumgr) |
264 | { | 219 | { |
265 | int32_t vr_config; | 220 | int32_t vr_config; |
@@ -298,93 +253,41 @@ static int fiji_setup_graphics_level_structure(struct pp_smumgr *smumgr) | |||
298 | return 0; | 253 | return 0; |
299 | } | 254 | } |
300 | 255 | ||
301 | /* Work in Progress */ | ||
302 | static int fiji_restore_vft_table(struct pp_smumgr *smumgr) | ||
303 | { | ||
304 | struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | ||
305 | |||
306 | if (AVFS_BTC_COMPLETED_SAVED == priv->avfs.AvfsBtcStatus) { | ||
307 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED; | ||
308 | return 0; | ||
309 | } else | ||
310 | return -EINVAL; | ||
311 | } | ||
312 | |||
313 | /* Work in Progress */ | ||
314 | static int fiji_save_vft_table(struct pp_smumgr *smumgr) | ||
315 | { | ||
316 | struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | ||
317 | |||
318 | if (AVFS_BTC_COMPLETED_SAVED == priv->avfs.AvfsBtcStatus) { | ||
319 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED; | ||
320 | return 0; | ||
321 | } else | ||
322 | return -EINVAL; | ||
323 | } | ||
324 | |||
325 | static int fiji_avfs_event_mgr(struct pp_smumgr *smumgr, bool smu_started) | 256 | static int fiji_avfs_event_mgr(struct pp_smumgr *smumgr, bool smu_started) |
326 | { | 257 | { |
327 | struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | 258 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
328 | 259 | ||
329 | switch (priv->avfs.AvfsBtcStatus) { | 260 | switch (smu_data->avfs.avfs_btc_status) { |
330 | case AVFS_BTC_COMPLETED_SAVED: /*S3 State - Pre SMU Start */ | 261 | case AVFS_BTC_COMPLETED_PREVIOUSLY: |
331 | priv->avfs.AvfsBtcStatus = AVFS_BTC_RESTOREVFT_FAILED; | ||
332 | PP_ASSERT_WITH_CODE(0 == fiji_restore_vft_table(smumgr), | ||
333 | "[AVFS][fiji_avfs_event_mgr] Could not Copy Graphics " | ||
334 | "Level table over to SMU", | ||
335 | return -1;); | ||
336 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED; | ||
337 | break; | ||
338 | case AVFS_BTC_COMPLETED_RESTORED: /*S3 State - Post SMU Start*/ | ||
339 | priv->avfs.AvfsBtcStatus = AVFS_BTC_SMUMSG_ERROR; | ||
340 | PP_ASSERT_WITH_CODE(0 == smum_send_msg_to_smc(smumgr, | ||
341 | 0x666), | ||
342 | "[AVFS][fiji_avfs_event_mgr] SMU did not respond " | ||
343 | "correctly to VftTableIsValid Msg", | ||
344 | return -1;); | ||
345 | priv->avfs.AvfsBtcStatus = AVFS_BTC_SMUMSG_ERROR; | ||
346 | PP_ASSERT_WITH_CODE(0 == smum_send_msg_to_smc(smumgr, | ||
347 | PPSMC_MSG_EnableAvfs), | ||
348 | "[AVFS][fiji_avfs_event_mgr] SMU did not respond " | ||
349 | "correctly to EnableAvfs Message Msg", | ||
350 | return -1;); | ||
351 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_SAVED; | ||
352 | break; | 262 | break; |
263 | |||
353 | case AVFS_BTC_BOOT: /*Cold Boot State - Post SMU Start*/ | 264 | case AVFS_BTC_BOOT: /*Cold Boot State - Post SMU Start*/ |
354 | if (!smu_started) | 265 | if (!smu_started) |
355 | break; | 266 | break; |
356 | priv->avfs.AvfsBtcStatus = AVFS_BTC_FAILED; | 267 | smu_data->avfs.avfs_btc_status = AVFS_BTC_FAILED; |
357 | PP_ASSERT_WITH_CODE(0 == fiji_setup_pm_fuse_for_avfs(smumgr), | ||
358 | "[AVFS][fiji_avfs_event_mgr] Failure at " | ||
359 | "fiji_setup_pm_fuse_for_avfs", | ||
360 | return -1;); | ||
361 | priv->avfs.AvfsBtcStatus = AVFS_BTC_DPMTABLESETUP_FAILED; | ||
362 | PP_ASSERT_WITH_CODE(0 == fiji_setup_graphics_level_structure(smumgr), | 268 | PP_ASSERT_WITH_CODE(0 == fiji_setup_graphics_level_structure(smumgr), |
363 | "[AVFS][fiji_avfs_event_mgr] Could not Copy Graphics Level" | 269 | "[AVFS][fiji_avfs_event_mgr] Could not Copy Graphics Level" |
364 | " table over to SMU", | 270 | " table over to SMU", |
365 | return -1;); | 271 | return -EINVAL;); |
366 | priv->avfs.AvfsBtcStatus = AVFS_BTC_VIRUS_FAIL; | 272 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
367 | PP_ASSERT_WITH_CODE(0 == fiji_setup_pwr_virus(smumgr), | 273 | PP_ASSERT_WITH_CODE(0 == fiji_setup_pwr_virus(smumgr), |
368 | "[AVFS][fiji_avfs_event_mgr] Could not setup " | 274 | "[AVFS][fiji_avfs_event_mgr] Could not setup " |
369 | "Pwr Virus for AVFS ", | 275 | "Pwr Virus for AVFS ", |
370 | return -1;); | 276 | return -EINVAL;); |
371 | priv->avfs.AvfsBtcStatus = AVFS_BTC_FAILED; | 277 | smu_data->avfs.avfs_btc_status = AVFS_BTC_FAILED; |
372 | PP_ASSERT_WITH_CODE(0 == fiji_start_avfs_btc(smumgr), | 278 | PP_ASSERT_WITH_CODE(0 == fiji_start_avfs_btc(smumgr), |
373 | "[AVFS][fiji_avfs_event_mgr] Failure at " | 279 | "[AVFS][fiji_avfs_event_mgr] Failure at " |
374 | "fiji_start_avfs_btc. AVFS Disabled", | 280 | "fiji_start_avfs_btc. AVFS Disabled", |
375 | return -1;); | 281 | return -EINVAL;); |
376 | priv->avfs.AvfsBtcStatus = AVFS_BTC_SAVEVFT_FAILED; | 282 | |
377 | PP_ASSERT_WITH_CODE(0 == fiji_save_vft_table(smumgr), | 283 | smu_data->avfs.avfs_btc_status = AVFS_BTC_ENABLEAVFS; |
378 | "[AVFS][fiji_avfs_event_mgr] Could not save VFT Table", | ||
379 | return -1;); | ||
380 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_SAVED; | ||
381 | break; | 284 | break; |
382 | case AVFS_BTC_DISABLED: /* Do nothing */ | 285 | case AVFS_BTC_DISABLED: /* Do nothing */ |
383 | break; | ||
384 | case AVFS_BTC_NOTSUPPORTED: /* Do nothing */ | 286 | case AVFS_BTC_NOTSUPPORTED: /* Do nothing */ |
287 | case AVFS_BTC_ENABLEAVFS: | ||
385 | break; | 288 | break; |
386 | default: | 289 | default: |
387 | pr_err("[AVFS] Something is broken. See log!"); | 290 | pr_err("AVFS failed status is %x !\n", smu_data->avfs.avfs_btc_status); |
388 | break; | 291 | break; |
389 | } | 292 | } |
390 | return 0; | 293 | return 0; |
@@ -477,19 +380,6 @@ static int fiji_smu_init(struct pp_smumgr *smumgr) | |||
477 | if (smu7_init(smumgr)) | 380 | if (smu7_init(smumgr)) |
478 | return -EINVAL; | 381 | return -EINVAL; |
479 | 382 | ||
480 | fiji_priv->avfs.AvfsBtcStatus = AVFS_BTC_BOOT; | ||
481 | if (fiji_is_hw_avfs_present(smumgr)) | ||
482 | /* AVFS Parameter | ||
483 | * 0 - BTC DC disabled, BTC AC disabled | ||
484 | * 1 - BTC DC enabled, BTC AC disabled | ||
485 | * 2 - BTC DC disabled, BTC AC enabled | ||
486 | * 3 - BTC DC enabled, BTC AC enabled | ||
487 | * Default is 0 - BTC DC disabled, BTC AC disabled | ||
488 | */ | ||
489 | fiji_priv->avfs.AvfsBtcParam = 0; | ||
490 | else | ||
491 | fiji_priv->avfs.AvfsBtcStatus = AVFS_BTC_NOTSUPPORTED; | ||
492 | |||
493 | for (i = 0; i < SMU73_MAX_LEVELS_GRAPHICS; i++) | 383 | for (i = 0; i < SMU73_MAX_LEVELS_GRAPHICS; i++) |
494 | fiji_priv->activity_target[i] = 30; | 384 | fiji_priv->activity_target[i] = 30; |
495 | 385 | ||
@@ -514,10 +404,12 @@ const struct pp_smumgr_func fiji_smu_funcs = { | |||
514 | .init_smc_table = fiji_init_smc_table, | 404 | .init_smc_table = fiji_init_smc_table, |
515 | .update_sclk_threshold = fiji_update_sclk_threshold, | 405 | .update_sclk_threshold = fiji_update_sclk_threshold, |
516 | .thermal_setup_fan_table = fiji_thermal_setup_fan_table, | 406 | .thermal_setup_fan_table = fiji_thermal_setup_fan_table, |
407 | .thermal_avfs_enable = fiji_thermal_avfs_enable, | ||
517 | .populate_all_graphic_levels = fiji_populate_all_graphic_levels, | 408 | .populate_all_graphic_levels = fiji_populate_all_graphic_levels, |
518 | .populate_all_memory_levels = fiji_populate_all_memory_levels, | 409 | .populate_all_memory_levels = fiji_populate_all_memory_levels, |
519 | .get_mac_definition = fiji_get_mac_definition, | 410 | .get_mac_definition = fiji_get_mac_definition, |
520 | .initialize_mc_reg_table = fiji_initialize_mc_reg_table, | 411 | .initialize_mc_reg_table = fiji_initialize_mc_reg_table, |
521 | .is_dpm_running = fiji_is_dpm_running, | 412 | .is_dpm_running = fiji_is_dpm_running, |
522 | .populate_requested_graphic_levels = fiji_populate_requested_graphic_levels, | 413 | .populate_requested_graphic_levels = fiji_populate_requested_graphic_levels, |
414 | .is_hw_avfs_present = fiji_is_hw_avfs_present, | ||
523 | }; | 415 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.h index adcbdfb209be..175bf9f8ef9c 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.h | |||
@@ -28,17 +28,8 @@ | |||
28 | #include "smu7_smumgr.h" | 28 | #include "smu7_smumgr.h" |
29 | 29 | ||
30 | 30 | ||
31 | |||
32 | struct fiji_smu_avfs { | ||
33 | enum AVFS_BTC_STATUS AvfsBtcStatus; | ||
34 | uint32_t AvfsBtcParam; | ||
35 | }; | ||
36 | |||
37 | |||
38 | struct fiji_smumgr { | 31 | struct fiji_smumgr { |
39 | struct smu7_smumgr smu7_data; | 32 | struct smu7_smumgr smu7_data; |
40 | |||
41 | struct fiji_smu_avfs avfs; | ||
42 | struct SMU73_Discrete_DpmTable smc_state_table; | 33 | struct SMU73_Discrete_DpmTable smc_state_table; |
43 | struct SMU73_Discrete_Ulv ulv_setting; | 34 | struct SMU73_Discrete_Ulv ulv_setting; |
44 | struct SMU73_Discrete_PmFuses power_tune_table; | 35 | struct SMU73_Discrete_PmFuses power_tune_table; |
@@ -47,7 +38,5 @@ struct fiji_smumgr { | |||
47 | 38 | ||
48 | }; | 39 | }; |
49 | 40 | ||
50 | |||
51 | |||
52 | #endif | 41 | #endif |
53 | 42 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c index f68e759e8be2..99a00bd39256 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c | |||
@@ -1498,7 +1498,7 @@ static int polaris10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) | |||
1498 | table_info->vdd_dep_on_sclk; | 1498 | table_info->vdd_dep_on_sclk; |
1499 | 1499 | ||
1500 | 1500 | ||
1501 | if (smu_data->avfs.avfs_btc_status == AVFS_BTC_NOTSUPPORTED) | 1501 | if (((struct smu7_smumgr *)smu_data)->avfs.avfs_btc_status == AVFS_BTC_NOTSUPPORTED) |
1502 | return result; | 1502 | return result; |
1503 | 1503 | ||
1504 | result = atomctrl_get_avfs_information(hwmgr, &avfs_params); | 1504 | result = atomctrl_get_avfs_information(hwmgr, &avfs_params); |
@@ -1889,7 +1889,7 @@ int polaris10_thermal_avfs_enable(struct pp_hwmgr *hwmgr) | |||
1889 | { | 1889 | { |
1890 | int ret; | 1890 | int ret; |
1891 | struct pp_smumgr *smumgr = (struct pp_smumgr *)(hwmgr->smumgr); | 1891 | struct pp_smumgr *smumgr = (struct pp_smumgr *)(hwmgr->smumgr); |
1892 | struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(smumgr->backend); | 1892 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
1893 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); | 1893 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); |
1894 | 1894 | ||
1895 | if (smu_data->avfs.avfs_btc_status == AVFS_BTC_NOTSUPPORTED) | 1895 | if (smu_data->avfs.avfs_btc_status == AVFS_BTC_NOTSUPPORTED) |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c index 9616cedc139c..75f43dadc56b 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c | |||
@@ -60,16 +60,14 @@ static const SMU74_Discrete_GraphicsLevel avfs_graphics_level_polaris10[8] = { | |||
60 | static const SMU74_Discrete_MemoryLevel avfs_memory_level_polaris10 = { | 60 | static const SMU74_Discrete_MemoryLevel avfs_memory_level_polaris10 = { |
61 | 0x100ea446, 0, 0x30750000, 0x01, 0x01, 0x01, 0x00, 0x00, 0x64, 0x00, 0x00, 0x1f00, 0x00, 0x00}; | 61 | 0x100ea446, 0, 0x30750000, 0x01, 0x01, 0x01, 0x00, 0x00, 0x64, 0x00, 0x00, 0x1f00, 0x00, 0x00}; |
62 | 62 | ||
63 | |||
64 | static int polaris10_setup_pwr_virus(struct pp_smumgr *smumgr) | 63 | static int polaris10_setup_pwr_virus(struct pp_smumgr *smumgr) |
65 | { | 64 | { |
66 | int i; | 65 | int i; |
67 | int result = -1; | 66 | int result = -EINVAL; |
68 | uint32_t reg, data; | 67 | uint32_t reg, data; |
69 | 68 | ||
70 | const PWR_Command_Table *pvirus = pwr_virus_table; | 69 | const PWR_Command_Table *pvirus = pwr_virus_table; |
71 | struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(smumgr->backend); | 70 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
72 | |||
73 | 71 | ||
74 | for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) { | 72 | for (i = 0; i < PWR_VIRUS_TABLE_SIZE; i++) { |
75 | switch (pvirus->command) { | 73 | switch (pvirus->command) { |
@@ -86,7 +84,7 @@ static int polaris10_setup_pwr_virus(struct pp_smumgr *smumgr) | |||
86 | default: | 84 | default: |
87 | pr_info("Table Exit with Invalid Command!"); | 85 | pr_info("Table Exit with Invalid Command!"); |
88 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; | 86 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
89 | result = -1; | 87 | result = -EINVAL; |
90 | break; | 88 | break; |
91 | } | 89 | } |
92 | pvirus++; | 90 | pvirus++; |
@@ -98,7 +96,7 @@ static int polaris10_setup_pwr_virus(struct pp_smumgr *smumgr) | |||
98 | static int polaris10_perform_btc(struct pp_smumgr *smumgr) | 96 | static int polaris10_perform_btc(struct pp_smumgr *smumgr) |
99 | { | 97 | { |
100 | int result = 0; | 98 | int result = 0; |
101 | struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(smumgr->backend); | 99 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
102 | 100 | ||
103 | if (0 != smu_data->avfs.avfs_btc_param) { | 101 | if (0 != smu_data->avfs.avfs_btc_param) { |
104 | if (0 != smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) { | 102 | if (0 != smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) { |
@@ -172,10 +170,11 @@ static int polaris10_setup_graphics_level_structure(struct pp_smumgr *smumgr) | |||
172 | return 0; | 170 | return 0; |
173 | } | 171 | } |
174 | 172 | ||
173 | |||
175 | static int | 174 | static int |
176 | polaris10_avfs_event_mgr(struct pp_smumgr *smumgr, bool SMU_VFT_INTACT) | 175 | polaris10_avfs_event_mgr(struct pp_smumgr *smumgr, bool SMU_VFT_INTACT) |
177 | { | 176 | { |
178 | struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(smumgr->backend); | 177 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(smumgr->backend); |
179 | 178 | ||
180 | switch (smu_data->avfs.avfs_btc_status) { | 179 | switch (smu_data->avfs.avfs_btc_status) { |
181 | case AVFS_BTC_COMPLETED_PREVIOUSLY: | 180 | case AVFS_BTC_COMPLETED_PREVIOUSLY: |
@@ -185,30 +184,31 @@ polaris10_avfs_event_mgr(struct pp_smumgr *smumgr, bool SMU_VFT_INTACT) | |||
185 | 184 | ||
186 | smu_data->avfs.avfs_btc_status = AVFS_BTC_DPMTABLESETUP_FAILED; | 185 | smu_data->avfs.avfs_btc_status = AVFS_BTC_DPMTABLESETUP_FAILED; |
187 | PP_ASSERT_WITH_CODE(0 == polaris10_setup_graphics_level_structure(smumgr), | 186 | PP_ASSERT_WITH_CODE(0 == polaris10_setup_graphics_level_structure(smumgr), |
188 | "[AVFS][Polaris10_AVFSEventMgr] Could not Copy Graphics Level table over to SMU", | 187 | "[AVFS][Polaris10_AVFSEventMgr] Could not Copy Graphics Level table over to SMU", |
189 | return -1); | 188 | return -EINVAL); |
190 | 189 | ||
191 | if (smu_data->avfs.avfs_btc_param > 1) { | 190 | if (smu_data->avfs.avfs_btc_param > 1) { |
192 | pr_info("[AVFS][Polaris10_AVFSEventMgr] AC BTC has not been successfully verified on Fiji. There may be in this setting."); | 191 | pr_info("[AVFS][Polaris10_AVFSEventMgr] AC BTC has not been successfully verified on Fiji. There may be in this setting."); |
193 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; | 192 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
194 | PP_ASSERT_WITH_CODE(-1 == polaris10_setup_pwr_virus(smumgr), | 193 | PP_ASSERT_WITH_CODE(0 == polaris10_setup_pwr_virus(smumgr), |
195 | "[AVFS][Polaris10_AVFSEventMgr] Could not setup Pwr Virus for AVFS ", | 194 | "[AVFS][Polaris10_AVFSEventMgr] Could not setup Pwr Virus for AVFS ", |
196 | return -1); | 195 | return -EINVAL); |
197 | } | 196 | } |
198 | 197 | ||
199 | smu_data->avfs.avfs_btc_status = AVFS_BTC_FAILED; | 198 | smu_data->avfs.avfs_btc_status = AVFS_BTC_FAILED; |
200 | PP_ASSERT_WITH_CODE(0 == polaris10_perform_btc(smumgr), | 199 | PP_ASSERT_WITH_CODE(0 == polaris10_perform_btc(smumgr), |
201 | "[AVFS][Polaris10_AVFSEventMgr] Failure at SmuPolaris10_PerformBTC. AVFS Disabled", | 200 | "[AVFS][Polaris10_AVFSEventMgr] Failure at SmuPolaris10_PerformBTC. AVFS Disabled", |
202 | return -1); | 201 | return -EINVAL); |
203 | 202 | smu_data->avfs.avfs_btc_status = AVFS_BTC_ENABLEAVFS; | |
204 | break; | 203 | break; |
205 | 204 | ||
206 | case AVFS_BTC_DISABLED: | 205 | case AVFS_BTC_DISABLED: |
206 | case AVFS_BTC_ENABLEAVFS: | ||
207 | case AVFS_BTC_NOTSUPPORTED: | 207 | case AVFS_BTC_NOTSUPPORTED: |
208 | break; | 208 | break; |
209 | 209 | ||
210 | default: | 210 | default: |
211 | pr_info("[AVFS] Something is broken. See log!"); | 211 | pr_err("AVFS failed status is %x!\n", smu_data->avfs.avfs_btc_status); |
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | 214 | ||
@@ -376,11 +376,6 @@ static int polaris10_smu_init(struct pp_smumgr *smumgr) | |||
376 | if (smu7_init(smumgr)) | 376 | if (smu7_init(smumgr)) |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | 378 | ||
379 | if (polaris10_is_hw_avfs_present(smumgr)) | ||
380 | smu_data->avfs.avfs_btc_status = AVFS_BTC_BOOT; | ||
381 | else | ||
382 | smu_data->avfs.avfs_btc_status = AVFS_BTC_NOTSUPPORTED; | ||
383 | |||
384 | for (i = 0; i < SMU74_MAX_LEVELS_GRAPHICS; i++) | 379 | for (i = 0; i < SMU74_MAX_LEVELS_GRAPHICS; i++) |
385 | smu_data->activity_target[i] = PPPOLARIS10_TARGETACTIVITY_DFLT; | 380 | smu_data->activity_target[i] = PPPOLARIS10_TARGETACTIVITY_DFLT; |
386 | 381 | ||
@@ -410,4 +405,5 @@ const struct pp_smumgr_func polaris10_smu_funcs = { | |||
410 | .get_mac_definition = polaris10_get_mac_definition, | 405 | .get_mac_definition = polaris10_get_mac_definition, |
411 | .is_dpm_running = polaris10_is_dpm_running, | 406 | .is_dpm_running = polaris10_is_dpm_running, |
412 | .populate_requested_graphic_levels = polaris10_populate_requested_graphic_levels, | 407 | .populate_requested_graphic_levels = polaris10_populate_requested_graphic_levels, |
408 | .is_hw_avfs_present = polaris10_is_hw_avfs_present, | ||
413 | }; | 409 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h index 49ebf1d5a53c..5e19c24b0561 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.h | |||
@@ -32,11 +32,6 @@ | |||
32 | 32 | ||
33 | #define SMC_RAM_END 0x40000 | 33 | #define SMC_RAM_END 0x40000 |
34 | 34 | ||
35 | struct polaris10_avfs { | ||
36 | enum AVFS_BTC_STATUS avfs_btc_status; | ||
37 | uint32_t avfs_btc_param; | ||
38 | }; | ||
39 | |||
40 | struct polaris10_pt_defaults { | 35 | struct polaris10_pt_defaults { |
41 | uint8_t SviLoadLineEn; | 36 | uint8_t SviLoadLineEn; |
42 | uint8_t SviLoadLineVddC; | 37 | uint8_t SviLoadLineVddC; |
@@ -51,8 +46,6 @@ struct polaris10_pt_defaults { | |||
51 | uint16_t BAPMTI_RC[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; | 46 | uint16_t BAPMTI_RC[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS]; |
52 | }; | 47 | }; |
53 | 48 | ||
54 | |||
55 | |||
56 | struct polaris10_range_table { | 49 | struct polaris10_range_table { |
57 | uint32_t trans_lower_frequency; /* in 10khz */ | 50 | uint32_t trans_lower_frequency; /* in 10khz */ |
58 | uint32_t trans_upper_frequency; | 51 | uint32_t trans_upper_frequency; |
@@ -61,14 +54,13 @@ struct polaris10_range_table { | |||
61 | struct polaris10_smumgr { | 54 | struct polaris10_smumgr { |
62 | struct smu7_smumgr smu7_data; | 55 | struct smu7_smumgr smu7_data; |
63 | uint8_t protected_mode; | 56 | uint8_t protected_mode; |
64 | struct polaris10_avfs avfs; | ||
65 | SMU74_Discrete_DpmTable smc_state_table; | 57 | SMU74_Discrete_DpmTable smc_state_table; |
66 | struct SMU74_Discrete_Ulv ulv_setting; | 58 | struct SMU74_Discrete_Ulv ulv_setting; |
67 | struct SMU74_Discrete_PmFuses power_tune_table; | 59 | struct SMU74_Discrete_PmFuses power_tune_table; |
68 | struct polaris10_range_table range_table[NUM_SCLK_RANGE]; | 60 | struct polaris10_range_table range_table[NUM_SCLK_RANGE]; |
69 | const struct polaris10_pt_defaults *power_tune_defaults; | 61 | const struct polaris10_pt_defaults *power_tune_defaults; |
70 | uint32_t activity_target[SMU74_MAX_LEVELS_GRAPHICS]; | 62 | uint32_t activity_target[SMU74_MAX_LEVELS_GRAPHICS]; |
71 | uint32_t bif_sclk_table[SMU74_MAX_LEVELS_LINK]; | 63 | uint32_t bif_sclk_table[SMU74_MAX_LEVELS_LINK]; |
72 | }; | 64 | }; |
73 | 65 | ||
74 | 66 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 35ac27681415..76347ff6d655 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | |||
@@ -540,7 +540,6 @@ int smu7_upload_smu_firmware_image(struct pp_smumgr *smumgr) | |||
540 | return result; | 540 | return result; |
541 | } | 541 | } |
542 | 542 | ||
543 | |||
544 | int smu7_init(struct pp_smumgr *smumgr) | 543 | int smu7_init(struct pp_smumgr *smumgr) |
545 | { | 544 | { |
546 | struct smu7_smumgr *smu_data; | 545 | struct smu7_smumgr *smu_data; |
@@ -596,6 +595,11 @@ int smu7_init(struct pp_smumgr *smumgr) | |||
596 | (cgs_handle_t)smu_data->smu_buffer.handle); | 595 | (cgs_handle_t)smu_data->smu_buffer.handle); |
597 | return -EINVAL); | 596 | return -EINVAL); |
598 | 597 | ||
598 | if (smum_is_hw_avfs_present(smumgr)) | ||
599 | smu_data->avfs.avfs_btc_status = AVFS_BTC_BOOT; | ||
600 | else | ||
601 | smu_data->avfs.avfs_btc_status = AVFS_BTC_NOTSUPPORTED; | ||
602 | |||
599 | return 0; | 603 | return 0; |
600 | } | 604 | } |
601 | 605 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h index 919be435b49c..ee5e32d2921e 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h | |||
@@ -37,6 +37,11 @@ struct smu7_buffer_entry { | |||
37 | unsigned long handle; | 37 | unsigned long handle; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | struct smu7_avfs { | ||
41 | enum AVFS_BTC_STATUS avfs_btc_status; | ||
42 | uint32_t avfs_btc_param; | ||
43 | }; | ||
44 | |||
40 | struct smu7_smumgr { | 45 | struct smu7_smumgr { |
41 | uint8_t *header; | 46 | uint8_t *header; |
42 | uint8_t *mec_image; | 47 | uint8_t *mec_image; |
@@ -50,7 +55,8 @@ struct smu7_smumgr { | |||
50 | uint32_t arb_table_start; | 55 | uint32_t arb_table_start; |
51 | uint32_t ulv_setting_starts; | 56 | uint32_t ulv_setting_starts; |
52 | uint8_t security_hard_key; | 57 | uint8_t security_hard_key; |
53 | uint32_t acpi_optimization; | 58 | uint32_t acpi_optimization; |
59 | struct smu7_avfs avfs; | ||
54 | }; | 60 | }; |
55 | 61 | ||
56 | 62 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c index bcc61ffd13cb..3bdf6478de7f 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c | |||
@@ -43,7 +43,8 @@ MODULE_FIRMWARE("amdgpu/polaris11_smc.bin"); | |||
43 | MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); | 43 | MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); |
44 | MODULE_FIRMWARE("amdgpu/polaris11_k_smc.bin"); | 44 | MODULE_FIRMWARE("amdgpu/polaris11_k_smc.bin"); |
45 | MODULE_FIRMWARE("amdgpu/polaris12_smc.bin"); | 45 | MODULE_FIRMWARE("amdgpu/polaris12_smc.bin"); |
46 | 46 | MODULE_FIRMWARE("amdgpu/vega10_smc.bin"); | |
47 | MODULE_FIRMWARE("amdgpu/vega10_acg_smc.bin"); | ||
47 | 48 | ||
48 | int smum_early_init(struct pp_instance *handle) | 49 | int smum_early_init(struct pp_instance *handle) |
49 | { | 50 | { |
@@ -403,3 +404,11 @@ int smum_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, | |||
403 | 404 | ||
404 | return 0; | 405 | return 0; |
405 | } | 406 | } |
407 | |||
408 | bool smum_is_hw_avfs_present(struct pp_smumgr *smumgr) | ||
409 | { | ||
410 | if (smumgr->smumgr_funcs->is_hw_avfs_present) | ||
411 | return smumgr->smumgr_funcs->is_hw_avfs_present(smumgr); | ||
412 | |||
413 | return false; | ||
414 | } | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c index 269678443862..408514c965a0 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | |||
@@ -356,6 +356,9 @@ int vega10_set_tools_address(struct pp_smumgr *smumgr) | |||
356 | static int vega10_verify_smc_interface(struct pp_smumgr *smumgr) | 356 | static int vega10_verify_smc_interface(struct pp_smumgr *smumgr) |
357 | { | 357 | { |
358 | uint32_t smc_driver_if_version; | 358 | uint32_t smc_driver_if_version; |
359 | struct cgs_system_info sys_info = {0}; | ||
360 | uint32_t dev_id; | ||
361 | uint32_t rev_id; | ||
359 | 362 | ||
360 | PP_ASSERT_WITH_CODE(!vega10_send_msg_to_smc(smumgr, | 363 | PP_ASSERT_WITH_CODE(!vega10_send_msg_to_smc(smumgr, |
361 | PPSMC_MSG_GetDriverIfVersion), | 364 | PPSMC_MSG_GetDriverIfVersion), |
@@ -363,12 +366,27 @@ static int vega10_verify_smc_interface(struct pp_smumgr *smumgr) | |||
363 | return -EINVAL); | 366 | return -EINVAL); |
364 | vega10_read_arg_from_smc(smumgr, &smc_driver_if_version); | 367 | vega10_read_arg_from_smc(smumgr, &smc_driver_if_version); |
365 | 368 | ||
366 | if (smc_driver_if_version != SMU9_DRIVER_IF_VERSION) { | 369 | sys_info.size = sizeof(struct cgs_system_info); |
367 | pr_err("Your firmware(0x%x) doesn't match \ | 370 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_DEV; |
368 | SMU9_DRIVER_IF_VERSION(0x%x). \ | 371 | cgs_query_system_info(smumgr->device, &sys_info); |
369 | Please update your firmware!\n", | 372 | dev_id = (uint32_t)sys_info.value; |
370 | smc_driver_if_version, SMU9_DRIVER_IF_VERSION); | 373 | |
371 | return -EINVAL; | 374 | sys_info.size = sizeof(struct cgs_system_info); |
375 | sys_info.info_id = CGS_SYSTEM_INFO_PCIE_REV; | ||
376 | cgs_query_system_info(smumgr->device, &sys_info); | ||
377 | rev_id = (uint32_t)sys_info.value; | ||
378 | |||
379 | if (!((dev_id == 0x687f) && | ||
380 | ((rev_id == 0xc0) || | ||
381 | (rev_id == 0xc1) || | ||
382 | (rev_id == 0xc3)))) { | ||
383 | if (smc_driver_if_version != SMU9_DRIVER_IF_VERSION) { | ||
384 | pr_err("Your firmware(0x%x) doesn't match \ | ||
385 | SMU9_DRIVER_IF_VERSION(0x%x). \ | ||
386 | Please update your firmware!\n", | ||
387 | smc_driver_if_version, SMU9_DRIVER_IF_VERSION); | ||
388 | return -EINVAL; | ||
389 | } | ||
372 | } | 390 | } |
373 | 391 | ||
374 | return 0; | 392 | return 0; |
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h b/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h index dbd4fd3a810b..8bd38102b58e 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h +++ b/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h | |||
@@ -16,16 +16,16 @@ TRACE_EVENT(amd_sched_job, | |||
16 | TP_ARGS(sched_job), | 16 | TP_ARGS(sched_job), |
17 | TP_STRUCT__entry( | 17 | TP_STRUCT__entry( |
18 | __field(struct amd_sched_entity *, entity) | 18 | __field(struct amd_sched_entity *, entity) |
19 | __field(struct amd_sched_job *, sched_job) | ||
20 | __field(struct dma_fence *, fence) | 19 | __field(struct dma_fence *, fence) |
21 | __field(const char *, name) | 20 | __field(const char *, name) |
21 | __field(uint64_t, id) | ||
22 | __field(u32, job_count) | 22 | __field(u32, job_count) |
23 | __field(int, hw_job_count) | 23 | __field(int, hw_job_count) |
24 | ), | 24 | ), |
25 | 25 | ||
26 | TP_fast_assign( | 26 | TP_fast_assign( |
27 | __entry->entity = sched_job->s_entity; | 27 | __entry->entity = sched_job->s_entity; |
28 | __entry->sched_job = sched_job; | 28 | __entry->id = sched_job->id; |
29 | __entry->fence = &sched_job->s_fence->finished; | 29 | __entry->fence = &sched_job->s_fence->finished; |
30 | __entry->name = sched_job->sched->name; | 30 | __entry->name = sched_job->sched->name; |
31 | __entry->job_count = kfifo_len( | 31 | __entry->job_count = kfifo_len( |
@@ -33,8 +33,9 @@ TRACE_EVENT(amd_sched_job, | |||
33 | __entry->hw_job_count = atomic_read( | 33 | __entry->hw_job_count = atomic_read( |
34 | &sched_job->sched->hw_rq_count); | 34 | &sched_job->sched->hw_rq_count); |
35 | ), | 35 | ), |
36 | TP_printk("entity=%p, sched job=%p, fence=%p, ring=%s, job count:%u, hw job count:%d", | 36 | TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d", |
37 | __entry->entity, __entry->sched_job, __entry->fence, __entry->name, | 37 | __entry->entity, __entry->id, |
38 | __entry->fence, __entry->name, | ||
38 | __entry->job_count, __entry->hw_job_count) | 39 | __entry->job_count, __entry->hw_job_count) |
39 | ); | 40 | ); |
40 | 41 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 17d3dafc8319..f339c1c10fa1 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -1388,12 +1388,12 @@ static const struct drm_mode_config_funcs radeon_mode_funcs = { | |||
1388 | .output_poll_changed = radeon_output_poll_changed | 1388 | .output_poll_changed = radeon_output_poll_changed |
1389 | }; | 1389 | }; |
1390 | 1390 | ||
1391 | static struct drm_prop_enum_list radeon_tmds_pll_enum_list[] = | 1391 | static const struct drm_prop_enum_list radeon_tmds_pll_enum_list[] = |
1392 | { { 0, "driver" }, | 1392 | { { 0, "driver" }, |
1393 | { 1, "bios" }, | 1393 | { 1, "bios" }, |
1394 | }; | 1394 | }; |
1395 | 1395 | ||
1396 | static struct drm_prop_enum_list radeon_tv_std_enum_list[] = | 1396 | static const struct drm_prop_enum_list radeon_tv_std_enum_list[] = |
1397 | { { TV_STD_NTSC, "ntsc" }, | 1397 | { { TV_STD_NTSC, "ntsc" }, |
1398 | { TV_STD_PAL, "pal" }, | 1398 | { TV_STD_PAL, "pal" }, |
1399 | { TV_STD_PAL_M, "pal-m" }, | 1399 | { TV_STD_PAL_M, "pal-m" }, |
@@ -1404,25 +1404,25 @@ static struct drm_prop_enum_list radeon_tv_std_enum_list[] = | |||
1404 | { TV_STD_SECAM, "secam" }, | 1404 | { TV_STD_SECAM, "secam" }, |
1405 | }; | 1405 | }; |
1406 | 1406 | ||
1407 | static struct drm_prop_enum_list radeon_underscan_enum_list[] = | 1407 | static const struct drm_prop_enum_list radeon_underscan_enum_list[] = |
1408 | { { UNDERSCAN_OFF, "off" }, | 1408 | { { UNDERSCAN_OFF, "off" }, |
1409 | { UNDERSCAN_ON, "on" }, | 1409 | { UNDERSCAN_ON, "on" }, |
1410 | { UNDERSCAN_AUTO, "auto" }, | 1410 | { UNDERSCAN_AUTO, "auto" }, |
1411 | }; | 1411 | }; |
1412 | 1412 | ||
1413 | static struct drm_prop_enum_list radeon_audio_enum_list[] = | 1413 | static const struct drm_prop_enum_list radeon_audio_enum_list[] = |
1414 | { { RADEON_AUDIO_DISABLE, "off" }, | 1414 | { { RADEON_AUDIO_DISABLE, "off" }, |
1415 | { RADEON_AUDIO_ENABLE, "on" }, | 1415 | { RADEON_AUDIO_ENABLE, "on" }, |
1416 | { RADEON_AUDIO_AUTO, "auto" }, | 1416 | { RADEON_AUDIO_AUTO, "auto" }, |
1417 | }; | 1417 | }; |
1418 | 1418 | ||
1419 | /* XXX support different dither options? spatial, temporal, both, etc. */ | 1419 | /* XXX support different dither options? spatial, temporal, both, etc. */ |
1420 | static struct drm_prop_enum_list radeon_dither_enum_list[] = | 1420 | static const struct drm_prop_enum_list radeon_dither_enum_list[] = |
1421 | { { RADEON_FMT_DITHER_DISABLE, "off" }, | 1421 | { { RADEON_FMT_DITHER_DISABLE, "off" }, |
1422 | { RADEON_FMT_DITHER_ENABLE, "on" }, | 1422 | { RADEON_FMT_DITHER_ENABLE, "on" }, |
1423 | }; | 1423 | }; |
1424 | 1424 | ||
1425 | static struct drm_prop_enum_list radeon_output_csc_enum_list[] = | 1425 | static const struct drm_prop_enum_list radeon_output_csc_enum_list[] = |
1426 | { { RADEON_OUTPUT_CSC_BYPASS, "bypass" }, | 1426 | { { RADEON_OUTPUT_CSC_BYPASS, "bypass" }, |
1427 | { RADEON_OUTPUT_CSC_TVRGB, "tvrgb" }, | 1427 | { RADEON_OUTPUT_CSC_TVRGB, "tvrgb" }, |
1428 | { RADEON_OUTPUT_CSC_YCBCR601, "ycbcr601" }, | 1428 | { RADEON_OUTPUT_CSC_YCBCR601, "ycbcr601" }, |
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index e141fcd5e8e1..7fc63fecb8c1 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c | |||
@@ -346,9 +346,12 @@ int radeon_fbdev_init(struct radeon_device *rdev) | |||
346 | if (list_empty(&rdev->ddev->mode_config.connector_list)) | 346 | if (list_empty(&rdev->ddev->mode_config.connector_list)) |
347 | return 0; | 347 | return 0; |
348 | 348 | ||
349 | /* select 8 bpp console on RN50 or 16MB cards */ | 349 | /* select 8 bpp console on 8MB cards, or 16 bpp on RN50 or 32MB */ |
350 | if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32*1024*1024)) | 350 | if (rdev->mc.real_vram_size <= (8*1024*1024)) |
351 | bpp_sel = 8; | 351 | bpp_sel = 8; |
352 | else if (ASIC_IS_RN50(rdev) || | ||
353 | rdev->mc.real_vram_size <= (32*1024*1024)) | ||
354 | bpp_sel = 16; | ||
352 | 355 | ||
353 | rfbdev = kzalloc(sizeof(struct radeon_fbdev), GFP_KERNEL); | 356 | rfbdev = kzalloc(sizeof(struct radeon_fbdev), GFP_KERNEL); |
354 | if (!rfbdev) | 357 | if (!rfbdev) |
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c index fff0d11b0600..afaf10db47cc 100644 --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c | |||
@@ -283,6 +283,10 @@ int radeon_irq_kms_init(struct radeon_device *rdev) | |||
283 | int r = 0; | 283 | int r = 0; |
284 | 284 | ||
285 | spin_lock_init(&rdev->irq.lock); | 285 | spin_lock_init(&rdev->irq.lock); |
286 | |||
287 | /* Disable vblank irqs aggressively for power-saving */ | ||
288 | rdev->ddev->vblank_disable_immediate = true; | ||
289 | |||
286 | r = drm_vblank_init(rdev->ddev, rdev->num_crtc); | 290 | r = drm_vblank_init(rdev->ddev, rdev->num_crtc); |
287 | if (r) { | 291 | if (r) { |
288 | return r; | 292 | return r; |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index faa021396da3..2804b4a15896 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -178,7 +178,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
178 | static void radeon_evict_flags(struct ttm_buffer_object *bo, | 178 | static void radeon_evict_flags(struct ttm_buffer_object *bo, |
179 | struct ttm_placement *placement) | 179 | struct ttm_placement *placement) |
180 | { | 180 | { |
181 | static struct ttm_place placements = { | 181 | static const struct ttm_place placements = { |
182 | .fpfn = 0, | 182 | .fpfn = 0, |
183 | .lpfn = 0, | 183 | .lpfn = 0, |
184 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | 184 | .flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM |
diff --git a/drivers/gpu/drm/radeon/vce_v2_0.c b/drivers/gpu/drm/radeon/vce_v2_0.c index fce214482e72..b0a43b68776d 100644 --- a/drivers/gpu/drm/radeon/vce_v2_0.c +++ b/drivers/gpu/drm/radeon/vce_v2_0.c | |||
@@ -104,6 +104,10 @@ static void vce_v2_0_disable_cg(struct radeon_device *rdev) | |||
104 | WREG32(VCE_CGTT_CLK_OVERRIDE, 7); | 104 | WREG32(VCE_CGTT_CLK_OVERRIDE, 7); |
105 | } | 105 | } |
106 | 106 | ||
107 | /* | ||
108 | * Local variable sw_cg is used for debugging purposes, in case we | ||
109 | * ran into problems with dynamic clock gating. Don't remove it. | ||
110 | */ | ||
107 | void vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable) | 111 | void vce_v2_0_enable_mgcg(struct radeon_device *rdev, bool enable) |
108 | { | 112 | { |
109 | bool sw_cg = false; | 113 | bool sw_cg = false; |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index b442d12f2f7d..a01e5c90fd87 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c | |||
@@ -294,10 +294,87 @@ static void ttm_bo_vm_close(struct vm_area_struct *vma) | |||
294 | vma->vm_private_data = NULL; | 294 | vma->vm_private_data = NULL; |
295 | } | 295 | } |
296 | 296 | ||
297 | static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo, | ||
298 | unsigned long offset, | ||
299 | void *buf, int len, int write) | ||
300 | { | ||
301 | unsigned long page = offset >> PAGE_SHIFT; | ||
302 | unsigned long bytes_left = len; | ||
303 | int ret; | ||
304 | |||
305 | /* Copy a page at a time, that way no extra virtual address | ||
306 | * mapping is needed | ||
307 | */ | ||
308 | offset -= page << PAGE_SHIFT; | ||
309 | do { | ||
310 | unsigned long bytes = min(bytes_left, PAGE_SIZE - offset); | ||
311 | struct ttm_bo_kmap_obj map; | ||
312 | void *ptr; | ||
313 | bool is_iomem; | ||
314 | |||
315 | ret = ttm_bo_kmap(bo, page, 1, &map); | ||
316 | if (ret) | ||
317 | return ret; | ||
318 | |||
319 | ptr = (uint8_t *)ttm_kmap_obj_virtual(&map, &is_iomem) + offset; | ||
320 | WARN_ON_ONCE(is_iomem); | ||
321 | if (write) | ||
322 | memcpy(ptr, buf, bytes); | ||
323 | else | ||
324 | memcpy(buf, ptr, bytes); | ||
325 | ttm_bo_kunmap(&map); | ||
326 | |||
327 | page++; | ||
328 | bytes_left -= bytes; | ||
329 | offset = 0; | ||
330 | } while (bytes_left); | ||
331 | |||
332 | return len; | ||
333 | } | ||
334 | |||
335 | static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr, | ||
336 | void *buf, int len, int write) | ||
337 | { | ||
338 | unsigned long offset = (addr) - vma->vm_start; | ||
339 | struct ttm_buffer_object *bo = vma->vm_private_data; | ||
340 | int ret; | ||
341 | |||
342 | if (len < 1 || (offset + len) >> PAGE_SHIFT > bo->num_pages) | ||
343 | return -EIO; | ||
344 | |||
345 | ret = ttm_bo_reserve(bo, true, false, NULL); | ||
346 | if (ret) | ||
347 | return ret; | ||
348 | |||
349 | switch (bo->mem.mem_type) { | ||
350 | case TTM_PL_SYSTEM: | ||
351 | if (unlikely(bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)) { | ||
352 | ret = ttm_tt_swapin(bo->ttm); | ||
353 | if (unlikely(ret != 0)) | ||
354 | return ret; | ||
355 | } | ||
356 | /* fall through */ | ||
357 | case TTM_PL_TT: | ||
358 | ret = ttm_bo_vm_access_kmap(bo, offset, buf, len, write); | ||
359 | break; | ||
360 | default: | ||
361 | if (bo->bdev->driver->access_memory) | ||
362 | ret = bo->bdev->driver->access_memory( | ||
363 | bo, offset, buf, len, write); | ||
364 | else | ||
365 | ret = -EIO; | ||
366 | } | ||
367 | |||
368 | ttm_bo_unreserve(bo); | ||
369 | |||
370 | return ret; | ||
371 | } | ||
372 | |||
297 | static const struct vm_operations_struct ttm_bo_vm_ops = { | 373 | static const struct vm_operations_struct ttm_bo_vm_ops = { |
298 | .fault = ttm_bo_vm_fault, | 374 | .fault = ttm_bo_vm_fault, |
299 | .open = ttm_bo_vm_open, | 375 | .open = ttm_bo_vm_open, |
300 | .close = ttm_bo_vm_close | 376 | .close = ttm_bo_vm_close, |
377 | .access = ttm_bo_vm_access | ||
301 | }; | 378 | }; |
302 | 379 | ||
303 | static struct ttm_buffer_object *ttm_bo_vm_lookup(struct ttm_bo_device *bdev, | 380 | static struct ttm_buffer_object *ttm_bo_vm_lookup(struct ttm_bo_device *bdev, |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 990d529f823c..d30850e07936 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -472,6 +472,23 @@ struct ttm_bo_driver { | |||
472 | */ | 472 | */ |
473 | unsigned long (*io_mem_pfn)(struct ttm_buffer_object *bo, | 473 | unsigned long (*io_mem_pfn)(struct ttm_buffer_object *bo, |
474 | unsigned long page_offset); | 474 | unsigned long page_offset); |
475 | |||
476 | /** | ||
477 | * Read/write memory buffers for ptrace access | ||
478 | * | ||
479 | * @bo: the BO to access | ||
480 | * @offset: the offset from the start of the BO | ||
481 | * @buf: pointer to source/destination buffer | ||
482 | * @len: number of bytes to copy | ||
483 | * @write: whether to read (0) from or write (non-0) to BO | ||
484 | * | ||
485 | * If successful, this function should return the number of | ||
486 | * bytes copied, -EIO otherwise. If the number of bytes | ||
487 | * returned is < len, the function may be called again with | ||
488 | * the remainder of the buffer to copy. | ||
489 | */ | ||
490 | int (*access_memory)(struct ttm_buffer_object *bo, unsigned long offset, | ||
491 | void *buf, int len, int write); | ||
475 | }; | 492 | }; |
476 | 493 | ||
477 | /** | 494 | /** |