Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: use function pointer for gfxhub functions

gfxhub functions are now called from function pointers,
instead of from asic-specific functions.

Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Oak Zeng and committed by
Alex Deucher
8ffff9b4 825c91d0

+155 -83
+4
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 104 104 #include "amdgpu_mes.h" 105 105 #include "amdgpu_umc.h" 106 106 #include "amdgpu_mmhub.h" 107 + #include "amdgpu_gfxhub.h" 107 108 #include "amdgpu_df.h" 108 109 109 110 #define MAX_GPU_INSTANCE 16 ··· 881 880 882 881 /* mmhub */ 883 882 struct amdgpu_mmhub mmhub; 883 + 884 + /* gfxhub */ 885 + struct amdgpu_gfxhub gfxhub; 884 886 885 887 /* gfx */ 886 888 struct amdgpu_gfx gfx;
+1 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10.c
··· 32 32 #include "v10_structs.h" 33 33 #include "nv.h" 34 34 #include "nvd.h" 35 - #include "gfxhub_v2_0.h" 36 35 37 36 enum hqd_dequeue_request_type { 38 37 NO_ACTION = 0, ··· 752 753 } 753 754 754 755 /* SDMA is on gfxhub as well for Navi1* series */ 755 - gfxhub_v2_0_setup_vm_pt_regs(adev, vmid, page_table_base); 756 + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 756 757 } 757 758 758 759 const struct kfd2kgd_calls gfx_v10_kfd2kgd = {
+1 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
··· 31 31 #include "v10_structs.h" 32 32 #include "nv.h" 33 33 #include "nvd.h" 34 - #include "gfxhub_v2_1.h" 35 34 36 35 enum hqd_dequeue_request_type { 37 36 NO_ACTION = 0, ··· 656 657 struct amdgpu_device *adev = get_amdgpu_device(kgd); 657 658 658 659 /* SDMA is on gfxhub as well for Navi1* series */ 659 - gfxhub_v2_1_setup_vm_pt_regs(adev, vmid, page_table_base); 660 + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 660 661 } 661 662 662 663 #if 0
+1 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
··· 36 36 #include "v9_structs.h" 37 37 #include "soc15.h" 38 38 #include "soc15d.h" 39 - #include "mmhub_v1_0.h" 40 - #include "gfxhub_v1_0.h" 41 - 42 39 43 40 enum hqd_dequeue_request_type { 44 41 NO_ACTION = 0, ··· 700 703 701 704 adev->mmhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 702 705 703 - gfxhub_v1_0_setup_vm_pt_regs(adev, vmid, page_table_base); 706 + adev->gfxhub.funcs->setup_vm_pt_regs(adev, vmid, page_table_base); 704 707 } 705 708 706 709 const struct kfd2kgd_calls gfx_v9_kfd2kgd = {
+43
drivers/gpu/drm/amd/amdgpu/amdgpu_gfxhub.h
··· 1 + /* 2 + * Copyright 2020 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 + #ifndef __AMDGPU_GFXHUB_H__ 24 + #define __AMDGPU_GFXHUB_H__ 25 + 26 + struct amdgpu_gfxhub_funcs { 27 + u64 (*get_fb_location)(struct amdgpu_device *adev); 28 + u64 (*get_mc_fb_offset)(struct amdgpu_device *adev); 29 + void (*setup_vm_pt_regs)(struct amdgpu_device *adev, uint32_t vmid, 30 + uint64_t page_table_base); 31 + int (*gart_enable)(struct amdgpu_device *adev); 32 + 33 + void (*gart_disable)(struct amdgpu_device *adev); 34 + void (*set_fault_enable_default)(struct amdgpu_device *adev, bool value); 35 + void (*init)(struct amdgpu_device *adev); 36 + int (*get_xgmi_info)(struct amdgpu_device *adev); 37 + }; 38 + 39 + struct amdgpu_gfxhub { 40 + const struct amdgpu_gfxhub_funcs *funcs; 41 + }; 42 + 43 + #endif
+10
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c
··· 403 403 hub->eng_addr_distance = mmVM_INVALIDATE_ENG1_ADDR_RANGE_LO32 - 404 404 mmVM_INVALIDATE_ENG0_ADDR_RANGE_LO32; 405 405 } 406 + 407 + 408 + const struct amdgpu_gfxhub_funcs gfxhub_v1_0_funcs = { 409 + .get_mc_fb_offset = gfxhub_v1_0_get_mc_fb_offset, 410 + .setup_vm_pt_regs = gfxhub_v1_0_setup_vm_pt_regs, 411 + .gart_enable = gfxhub_v1_0_gart_enable, 412 + .gart_disable = gfxhub_v1_0_gart_disable, 413 + .set_fault_enable_default = gfxhub_v1_0_set_fault_enable_default, 414 + .init = gfxhub_v1_0_init, 415 + };
+1
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.h
··· 33 33 void gfxhub_v1_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 34 34 uint64_t page_table_base); 35 35 36 + extern const struct amdgpu_gfxhub_funcs gfxhub_v1_0_funcs; 36 37 #endif
+12 -1
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
··· 21 21 * 22 22 */ 23 23 #include "amdgpu.h" 24 + #include "gfxhub_v1_0.h" 24 25 #include "gfxhub_v1_1.h" 25 26 26 27 #include "gc/gc_9_2_1_offset.h" ··· 29 28 30 29 #include "soc15_common.h" 31 30 32 - int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev) 31 + static int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev) 33 32 { 34 33 u32 xgmi_lfb_cntl = RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_CNTL); 35 34 u32 max_region = ··· 67 66 68 67 return 0; 69 68 } 69 + 70 + const struct amdgpu_gfxhub_funcs gfxhub_v1_1_funcs = { 71 + .get_mc_fb_offset = gfxhub_v1_0_get_mc_fb_offset, 72 + .setup_vm_pt_regs = gfxhub_v1_0_setup_vm_pt_regs, 73 + .gart_enable = gfxhub_v1_0_gart_enable, 74 + .gart_disable = gfxhub_v1_0_gart_disable, 75 + .set_fault_enable_default = gfxhub_v1_0_set_fault_enable_default, 76 + .init = gfxhub_v1_0_init, 77 + .get_xgmi_info = gfxhub_v1_1_get_xgmi_info, 78 + };
+1 -1
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h
··· 24 24 #ifndef __GFXHUB_V1_1_H__ 25 25 #define __GFXHUB_V1_1_H__ 26 26 27 - int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev); 27 + extern const struct amdgpu_gfxhub_funcs gfxhub_v1_1_funcs; 28 28 29 29 #endif
+17 -7
drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.c
··· 102 102 GCVM_L2_PROTECTION_FAULT_STATUS, RW)); 103 103 } 104 104 105 - u64 gfxhub_v2_0_get_fb_location(struct amdgpu_device *adev) 105 + static u64 gfxhub_v2_0_get_fb_location(struct amdgpu_device *adev) 106 106 { 107 107 u64 base = RREG32_SOC15(GC, 0, mmGCMC_VM_FB_LOCATION_BASE); 108 108 ··· 112 112 return base; 113 113 } 114 114 115 - u64 gfxhub_v2_0_get_mc_fb_offset(struct amdgpu_device *adev) 115 + static u64 gfxhub_v2_0_get_mc_fb_offset(struct amdgpu_device *adev) 116 116 { 117 117 return (u64)RREG32_SOC15(GC, 0, mmGCMC_VM_FB_OFFSET) << 24; 118 118 } 119 119 120 - void gfxhub_v2_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 120 + static void gfxhub_v2_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 121 121 uint64_t page_table_base) 122 122 { 123 123 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; ··· 342 342 } 343 343 } 344 344 345 - int gfxhub_v2_0_gart_enable(struct amdgpu_device *adev) 345 + static int gfxhub_v2_0_gart_enable(struct amdgpu_device *adev) 346 346 { 347 347 /* GART Enable. */ 348 348 gfxhub_v2_0_init_gart_aperture_regs(adev); ··· 358 358 return 0; 359 359 } 360 360 361 - void gfxhub_v2_0_gart_disable(struct amdgpu_device *adev) 361 + static void gfxhub_v2_0_gart_disable(struct amdgpu_device *adev) 362 362 { 363 363 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; 364 364 u32 tmp; ··· 389 389 * @adev: amdgpu_device pointer 390 390 * @value: true redirects VM faults to the default page 391 391 */ 392 - void gfxhub_v2_0_set_fault_enable_default(struct amdgpu_device *adev, 392 + static void gfxhub_v2_0_set_fault_enable_default(struct amdgpu_device *adev, 393 393 bool value) 394 394 { 395 395 u32 tmp; ··· 431 431 .get_invalidate_req = gfxhub_v2_0_get_invalidate_req, 432 432 }; 433 433 434 - void gfxhub_v2_0_init(struct amdgpu_device *adev) 434 + static void gfxhub_v2_0_init(struct amdgpu_device *adev) 435 435 { 436 436 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; 437 437 ··· 472 472 473 473 hub->vmhub_funcs = &gfxhub_v2_0_vmhub_funcs; 474 474 } 475 + 476 + const struct amdgpu_gfxhub_funcs gfxhub_v2_0_funcs = { 477 + .get_fb_location = gfxhub_v2_0_get_fb_location, 478 + .get_mc_fb_offset = gfxhub_v2_0_get_mc_fb_offset, 479 + .setup_vm_pt_regs = gfxhub_v2_0_setup_vm_pt_regs, 480 + .gart_enable = gfxhub_v2_0_gart_enable, 481 + .gart_disable = gfxhub_v2_0_gart_disable, 482 + .set_fault_enable_default = gfxhub_v2_0_set_fault_enable_default, 483 + .init = gfxhub_v2_0_init, 484 + };
+1 -9
drivers/gpu/drm/amd/amdgpu/gfxhub_v2_0.h
··· 24 24 #ifndef __GFXHUB_V2_0_H__ 25 25 #define __GFXHUB_V2_0_H__ 26 26 27 - u64 gfxhub_v2_0_get_fb_location(struct amdgpu_device *adev); 28 - int gfxhub_v2_0_gart_enable(struct amdgpu_device *adev); 29 - void gfxhub_v2_0_gart_disable(struct amdgpu_device *adev); 30 - void gfxhub_v2_0_set_fault_enable_default(struct amdgpu_device *adev, 31 - bool value); 32 - void gfxhub_v2_0_init(struct amdgpu_device *adev); 33 - u64 gfxhub_v2_0_get_mc_fb_offset(struct amdgpu_device *adev); 34 - void gfxhub_v2_0_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 35 - uint64_t page_table_base); 27 + extern const struct amdgpu_gfxhub_funcs gfxhub_v2_0_funcs; 36 28 37 29 #endif
+19 -8
drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
··· 102 102 GCVM_L2_PROTECTION_FAULT_STATUS, RW)); 103 103 } 104 104 105 - u64 gfxhub_v2_1_get_fb_location(struct amdgpu_device *adev) 105 + static u64 gfxhub_v2_1_get_fb_location(struct amdgpu_device *adev) 106 106 { 107 107 u64 base = RREG32_SOC15(GC, 0, mmGCMC_VM_FB_LOCATION_BASE); 108 108 ··· 112 112 return base; 113 113 } 114 114 115 - u64 gfxhub_v2_1_get_mc_fb_offset(struct amdgpu_device *adev) 115 + static u64 gfxhub_v2_1_get_mc_fb_offset(struct amdgpu_device *adev) 116 116 { 117 117 return (u64)RREG32_SOC15(GC, 0, mmGCMC_VM_FB_OFFSET) << 24; 118 118 } 119 119 120 - void gfxhub_v2_1_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 120 + static void gfxhub_v2_1_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 121 121 uint64_t page_table_base) 122 122 { 123 123 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; ··· 348 348 } 349 349 } 350 350 351 - int gfxhub_v2_1_gart_enable(struct amdgpu_device *adev) 351 + static int gfxhub_v2_1_gart_enable(struct amdgpu_device *adev) 352 352 { 353 353 if (amdgpu_sriov_vf(adev)) { 354 354 /* ··· 376 376 return 0; 377 377 } 378 378 379 - void gfxhub_v2_1_gart_disable(struct amdgpu_device *adev) 379 + static void gfxhub_v2_1_gart_disable(struct amdgpu_device *adev) 380 380 { 381 381 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; 382 382 u32 tmp; ··· 405 405 * @adev: amdgpu_device pointer 406 406 * @value: true redirects VM faults to the default page 407 407 */ 408 - void gfxhub_v2_1_set_fault_enable_default(struct amdgpu_device *adev, 408 + static void gfxhub_v2_1_set_fault_enable_default(struct amdgpu_device *adev, 409 409 bool value) 410 410 { 411 411 u32 tmp; ··· 454 454 .get_invalidate_req = gfxhub_v2_1_get_invalidate_req, 455 455 }; 456 456 457 - void gfxhub_v2_1_init(struct amdgpu_device *adev) 457 + static void gfxhub_v2_1_init(struct amdgpu_device *adev) 458 458 { 459 459 struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_GFXHUB_0]; 460 460 ··· 496 496 hub->vmhub_funcs = &gfxhub_v2_1_vmhub_funcs; 497 497 } 498 498 499 - int gfxhub_v2_1_get_xgmi_info(struct amdgpu_device *adev) 499 + static int gfxhub_v2_1_get_xgmi_info(struct amdgpu_device *adev) 500 500 { 501 501 u32 xgmi_lfb_cntl = RREG32_SOC15(GC, 0, mmGCMC_VM_XGMI_LFB_CNTL); 502 502 u32 max_region = ··· 531 531 532 532 return 0; 533 533 } 534 + 535 + const struct amdgpu_gfxhub_funcs gfxhub_v2_1_funcs = { 536 + .get_fb_location = gfxhub_v2_1_get_fb_location, 537 + .get_mc_fb_offset = gfxhub_v2_1_get_mc_fb_offset, 538 + .setup_vm_pt_regs = gfxhub_v2_1_setup_vm_pt_regs, 539 + .gart_enable = gfxhub_v2_1_gart_enable, 540 + .gart_disable = gfxhub_v2_1_gart_disable, 541 + .set_fault_enable_default = gfxhub_v2_1_set_fault_enable_default, 542 + .init = gfxhub_v2_1_init, 543 + .get_xgmi_info = gfxhub_v2_1_get_xgmi_info, 544 + };
+1 -11
drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.h
··· 24 24 #ifndef __GFXHUB_V2_1_H__ 25 25 #define __GFXHUB_V2_1_H__ 26 26 27 - u64 gfxhub_v2_1_get_fb_location(struct amdgpu_device *adev); 28 - int gfxhub_v2_1_gart_enable(struct amdgpu_device *adev); 29 - void gfxhub_v2_1_gart_disable(struct amdgpu_device *adev); 30 - void gfxhub_v2_1_set_fault_enable_default(struct amdgpu_device *adev, 31 - bool value); 32 - void gfxhub_v2_1_init(struct amdgpu_device *adev); 33 - u64 gfxhub_v2_1_get_mc_fb_offset(struct amdgpu_device *adev); 34 - void gfxhub_v2_1_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid, 35 - uint64_t page_table_base); 36 - 37 - int gfxhub_v2_1_get_xgmi_info(struct amdgpu_device *adev); 27 + extern const struct amdgpu_gfxhub_funcs gfxhub_v2_1_funcs; 38 28 39 29 #endif
+22 -31
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
··· 634 634 adev->mmhub.funcs = &mmhub_v2_0_funcs; 635 635 } 636 636 637 + static void gmc_v10_0_set_gfxhub_funcs(struct amdgpu_device *adev) 638 + { 639 + switch (adev->asic_type) { 640 + case CHIP_SIENNA_CICHLID: 641 + case CHIP_NAVY_FLOUNDER: 642 + adev->gfxhub.funcs = &gfxhub_v2_1_funcs; 643 + break; 644 + default: 645 + adev->gfxhub.funcs = &gfxhub_v2_0_funcs; 646 + break; 647 + } 648 + } 649 + 650 + 637 651 static int gmc_v10_0_early_init(void *handle) 638 652 { 639 653 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 640 654 641 655 gmc_v10_0_set_mmhub_funcs(adev); 656 + gmc_v10_0_set_gfxhub_funcs(adev); 642 657 gmc_v10_0_set_gmc_funcs(adev); 643 658 gmc_v10_0_set_irq_funcs(adev); 644 659 gmc_v10_0_set_umc_funcs(adev); ··· 691 676 { 692 677 u64 base = 0; 693 678 694 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 695 - adev->asic_type == CHIP_NAVY_FLOUNDER) 696 - base = gfxhub_v2_1_get_fb_location(adev); 697 - else 698 - base = gfxhub_v2_0_get_fb_location(adev); 679 + base = adev->gfxhub.funcs->get_fb_location(adev); 699 680 700 681 /* add the xgmi offset of the physical node */ 701 682 base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size; ··· 700 689 amdgpu_gmc_gart_location(adev, mc); 701 690 702 691 /* base offset of vram pages */ 703 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 704 - adev->asic_type == CHIP_NAVY_FLOUNDER) 705 - adev->vm_manager.vram_base_offset = gfxhub_v2_1_get_mc_fb_offset(adev); 706 - else 707 - adev->vm_manager.vram_base_offset = gfxhub_v2_0_get_mc_fb_offset(adev); 692 + adev->vm_manager.vram_base_offset = adev->gfxhub.funcs->get_mc_fb_offset(adev); 708 693 709 694 /* add the xgmi offset of the physical node */ 710 695 adev->vm_manager.vram_base_offset += ··· 784 777 int r, vram_width = 0, vram_type = 0, vram_vendor = 0; 785 778 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 786 779 787 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 788 - adev->asic_type == CHIP_NAVY_FLOUNDER) 789 - gfxhub_v2_1_init(adev); 790 - else 791 - gfxhub_v2_0_init(adev); 780 + adev->gfxhub.funcs->init(adev); 792 781 793 782 adev->mmhub.funcs->init(adev); 794 783 ··· 855 852 } 856 853 857 854 if (adev->gmc.xgmi.supported) { 858 - r = gfxhub_v2_1_get_xgmi_info(adev); 855 + r = adev->gfxhub.funcs->get_xgmi_info(adev); 859 856 if (r) 860 857 return r; 861 858 } ··· 947 944 if (r) 948 945 return r; 949 946 950 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 951 - adev->asic_type == CHIP_NAVY_FLOUNDER) 952 - r = gfxhub_v2_1_gart_enable(adev); 953 - else 954 - r = gfxhub_v2_0_gart_enable(adev); 947 + r = adev->gfxhub.funcs->gart_enable(adev); 955 948 if (r) 956 949 return r; 957 950 ··· 968 969 value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ? 969 970 false : true; 970 971 971 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 972 - adev->asic_type == CHIP_NAVY_FLOUNDER) 973 - gfxhub_v2_1_set_fault_enable_default(adev, value); 974 - else 975 - gfxhub_v2_0_set_fault_enable_default(adev, value); 972 + adev->gfxhub.funcs->set_fault_enable_default(adev, value); 976 973 adev->mmhub.funcs->set_fault_enable_default(adev, value); 977 974 gmc_v10_0_flush_gpu_tlb(adev, 0, AMDGPU_MMHUB_0, 0); 978 975 gmc_v10_0_flush_gpu_tlb(adev, 0, AMDGPU_GFXHUB_0, 0); ··· 1009 1014 */ 1010 1015 static void gmc_v10_0_gart_disable(struct amdgpu_device *adev) 1011 1016 { 1012 - if (adev->asic_type == CHIP_SIENNA_CICHLID || 1013 - adev->asic_type == CHIP_NAVY_FLOUNDER) 1014 - gfxhub_v2_1_gart_disable(adev); 1015 - else 1016 - gfxhub_v2_0_gart_disable(adev); 1017 + adev->gfxhub.funcs->gart_disable(adev); 1017 1018 adev->mmhub.funcs->gart_disable(adev); 1018 1019 amdgpu_gart_table_vram_unpin(adev); 1019 1020 }
+21 -7
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 1164 1164 } 1165 1165 } 1166 1166 1167 + static void gmc_v9_0_set_gfxhub_funcs(struct amdgpu_device *adev) 1168 + { 1169 + switch (adev->asic_type) { 1170 + case CHIP_ARCTURUS: 1171 + case CHIP_VEGA20: 1172 + adev->gfxhub.funcs = &gfxhub_v1_1_funcs; 1173 + break; 1174 + default: 1175 + adev->gfxhub.funcs = &gfxhub_v1_0_funcs; 1176 + break; 1177 + } 1178 + } 1179 + 1167 1180 static int gmc_v9_0_early_init(void *handle) 1168 1181 { 1169 1182 struct amdgpu_device *adev = (struct amdgpu_device *)handle; ··· 1185 1172 gmc_v9_0_set_irq_funcs(adev); 1186 1173 gmc_v9_0_set_umc_funcs(adev); 1187 1174 gmc_v9_0_set_mmhub_funcs(adev); 1175 + gmc_v9_0_set_gfxhub_funcs(adev); 1188 1176 1189 1177 adev->gmc.shared_aperture_start = 0x2000000000000000ULL; 1190 1178 adev->gmc.shared_aperture_end = ··· 1248 1234 amdgpu_gmc_gart_location(adev, mc); 1249 1235 amdgpu_gmc_agp_location(adev, mc); 1250 1236 /* base offset of vram pages */ 1251 - adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); 1237 + adev->vm_manager.vram_base_offset = adev->gfxhub.funcs->get_mc_fb_offset(adev); 1252 1238 1253 1239 /* XXX: add the xgmi offset of the physical node? */ 1254 1240 adev->vm_manager.vram_base_offset += ··· 1283 1269 1284 1270 #ifdef CONFIG_X86_64 1285 1271 if (adev->flags & AMD_IS_APU) { 1286 - adev->gmc.aper_base = gfxhub_v1_0_get_mc_fb_offset(adev); 1272 + adev->gmc.aper_base = adev->gfxhub.funcs->get_mc_fb_offset(adev); 1287 1273 adev->gmc.aper_size = adev->gmc.real_vram_size; 1288 1274 } 1289 1275 #endif ··· 1353 1339 int r, vram_width = 0, vram_type = 0, vram_vendor = 0; 1354 1340 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1355 1341 1356 - gfxhub_v1_0_init(adev); 1342 + adev->gfxhub.funcs->init(adev); 1357 1343 1358 1344 adev->mmhub.funcs->init(adev); 1359 1345 ··· 1467 1453 adev->need_swiotlb = drm_need_swiotlb(44); 1468 1454 1469 1455 if (adev->gmc.xgmi.supported) { 1470 - r = gfxhub_v1_1_get_xgmi_info(adev); 1456 + r = adev->gfxhub.funcs->get_xgmi_info(adev); 1471 1457 if (r) 1472 1458 return r; 1473 1459 } ··· 1583 1569 if (r) 1584 1570 return r; 1585 1571 1586 - r = gfxhub_v1_0_gart_enable(adev); 1572 + r = adev->gfxhub.funcs->gart_enable(adev); 1587 1573 if (r) 1588 1574 return r; 1589 1575 ··· 1650 1636 value = true; 1651 1637 1652 1638 if (!amdgpu_sriov_vf(adev)) { 1653 - gfxhub_v1_0_set_fault_enable_default(adev, value); 1639 + adev->gfxhub.funcs->set_fault_enable_default(adev, value); 1654 1640 adev->mmhub.funcs->set_fault_enable_default(adev, value); 1655 1641 } 1656 1642 for (i = 0; i < adev->num_vmhubs; ++i) ··· 1673 1659 */ 1674 1660 static void gmc_v9_0_gart_disable(struct amdgpu_device *adev) 1675 1661 { 1676 - gfxhub_v1_0_gart_disable(adev); 1662 + adev->gfxhub.funcs->gart_disable(adev); 1677 1663 adev->mmhub.funcs->gart_disable(adev); 1678 1664 amdgpu_gart_table_vram_unpin(adev); 1679 1665 }