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

Revert "drm/amd/display: move vmid determination logic out of dc"

This reverts commit 11cd74cdb98aa6f4d6f54a0082dd28e0d4743746.

Revert this to apply the version that includes DCN2 support.

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

+143 -13
+2 -2
drivers/gpu/drm/amd/display/dc/Makefile
··· 41 41 include $(AMD_DC) 42 42 43 43 DISPLAY_CORE = dc.o dc_link.o dc_resource.o dc_hw_sequencer.o dc_sink.o \ 44 - dc_surface.o dc_link_hwss.o dc_link_dp.o dc_link_ddc.o dc_debug.o dc_stream.o 45 - 44 + dc_surface.o dc_link_hwss.o dc_link_dp.o dc_link_ddc.o dc_debug.o dc_stream.o \ 45 + dc_vm_helper.o 46 46 47 47 AMD_DISPLAY_CORE = $(addprefix $(AMDDALPATH)/dc/core/,$(DISPLAY_CORE)) 48 48
+123
drivers/gpu/drm/amd/display/dc/core/dc_vm_helper.c
··· 1 + /* 2 + * Copyright 2018 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 + * Authors: AMD 23 + * 24 + */ 25 + 26 + #include "vm_helper.h" 27 + 28 + static void mark_vmid_used(struct vm_helper *vm_helper, unsigned int pos, uint8_t hubp_idx) 29 + { 30 + struct vmid_usage vmids = vm_helper->hubp_vmid_usage[hubp_idx]; 31 + 32 + vmids.vmid_usage[0] = vmids.vmid_usage[1]; 33 + vmids.vmid_usage[1] = 1 << pos; 34 + } 35 + 36 + static void add_ptb_to_table(struct vm_helper *vm_helper, unsigned int vmid, uint64_t ptb) 37 + { 38 + vm_helper->ptb_assigned_to_vmid[vmid] = ptb; 39 + vm_helper->num_vmids_available--; 40 + } 41 + 42 + static void clear_entry_from_vmid_table(struct vm_helper *vm_helper, unsigned int vmid) 43 + { 44 + vm_helper->ptb_assigned_to_vmid[vmid] = 0; 45 + vm_helper->num_vmids_available++; 46 + } 47 + 48 + static void evict_vmids(struct vm_helper *vm_helper) 49 + { 50 + int i; 51 + uint16_t ord = 0; 52 + 53 + for (i = 0; i < vm_helper->num_vmid; i++) 54 + ord |= vm_helper->hubp_vmid_usage[i].vmid_usage[0] | vm_helper->hubp_vmid_usage[i].vmid_usage[1]; 55 + 56 + // At this point any positions with value 0 are unused vmids, evict them 57 + for (i = 1; i < vm_helper->num_vmid; i++) { 58 + if (ord & (1u << i)) 59 + clear_entry_from_vmid_table(vm_helper, i); 60 + } 61 + } 62 + 63 + // Return value of -1 indicates vmid table unitialized or ptb dne in the table 64 + static int get_existing_vmid_for_ptb(struct vm_helper *vm_helper, uint64_t ptb) 65 + { 66 + int i; 67 + 68 + for (i = 0; i < vm_helper->num_vmid; i++) { 69 + if (vm_helper->ptb_assigned_to_vmid[i] == ptb) 70 + return i; 71 + } 72 + 73 + return -1; 74 + } 75 + 76 + // Expected to be called only when there's an available vmid 77 + static int get_next_available_vmid(struct vm_helper *vm_helper) 78 + { 79 + int i; 80 + 81 + for (i = 1; i < vm_helper->num_vmid; i++) { 82 + if (vm_helper->ptb_assigned_to_vmid[i] == 0) 83 + return i; 84 + } 85 + 86 + return -1; 87 + } 88 + 89 + uint8_t get_vmid_for_ptb(struct vm_helper *vm_helper, int64_t ptb, uint8_t hubp_idx) 90 + { 91 + unsigned int vmid = 0; 92 + int vmid_exists = -1; 93 + 94 + // Physical address gets vmid 0 95 + if (ptb == 0) 96 + return 0; 97 + 98 + vmid_exists = get_existing_vmid_for_ptb(vm_helper, ptb); 99 + 100 + if (vmid_exists != -1) { 101 + mark_vmid_used(vm_helper, vmid_exists, hubp_idx); 102 + vmid = vmid_exists; 103 + } else { 104 + if (vm_helper->num_vmids_available == 0) 105 + evict_vmids(vm_helper); 106 + 107 + vmid = get_next_available_vmid(vm_helper); 108 + mark_vmid_used(vm_helper, vmid, hubp_idx); 109 + add_ptb_to_table(vm_helper, vmid, ptb); 110 + } 111 + 112 + return vmid; 113 + } 114 + 115 + void init_vm_helper(struct vm_helper *vm_helper, unsigned int num_vmid, unsigned int num_hubp) 116 + { 117 + vm_helper->num_vmid = num_vmid; 118 + vm_helper->num_hubp = num_hubp; 119 + vm_helper->num_vmids_available = num_vmid - 1; 120 + 121 + memset(vm_helper->hubp_vmid_usage, 0, sizeof(vm_helper->hubp_vmid_usage[0]) * MAX_HUBP); 122 + memset(vm_helper->ptb_assigned_to_vmid, 0, sizeof(vm_helper->ptb_assigned_to_vmid[0]) * MAX_VMID); 123 + }
-1
drivers/gpu/drm/amd/display/dc/dc.h
··· 458 458 }; 459 459 460 460 struct dc *dc_create(const struct dc_init_data *init_params); 461 - int dc_get_vmid_use_vector(struct dc *dc); 462 461 void dc_init_callbacks(struct dc *dc, 463 462 const struct dc_callback_init *init_params); 464 463 void dc_destroy(struct dc **dc);
-2
drivers/gpu/drm/amd/display/dc/dc_hw_types.h
··· 99 99 }; 100 100 101 101 union large_integer page_table_base; 102 - 103 - uint8_t vmid; 104 102 }; 105 103 106 104 struct dc_size {
+2 -1
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
··· 317 317 bool hubp1_program_surface_flip_and_addr( 318 318 struct hubp *hubp, 319 319 const struct dc_plane_address *address, 320 - bool flip_immediate) 320 + bool flip_immediate, 321 + uint8_t vmid) 321 322 { 322 323 struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); 323 324
+2 -1
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 1237 1237 pipe_ctx->plane_res.hubp->funcs->hubp_program_surface_flip_and_addr( 1238 1238 pipe_ctx->plane_res.hubp, 1239 1239 &plane_state->address, 1240 - plane_state->flip_immediate); 1240 + plane_state->flip_immediate, 1241 + 0); 1241 1242 1242 1243 plane_state->status.requested_address = plane_state->address; 1243 1244
+2 -1
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
··· 80 80 bool (*hubp_program_surface_flip_and_addr)( 81 81 struct hubp *hubp, 82 82 const struct dc_plane_address *address, 83 - bool flip_immediate); 83 + bool flip_immediate, 84 + uint8_t vmid); 84 85 85 86 void (*hubp_program_pte_vm)( 86 87 struct hubp *hubp,
-1
drivers/gpu/drm/amd/display/dc/inc/hw/vmid.h
··· 44 44 uint64_t page_table_end_addr; 45 45 enum dcn_hubbub_page_table_depth depth; 46 46 enum dcn_hubbub_page_table_block_size block_size; 47 - uint64_t page_table_base_addr; 48 47 }; 49 48 50 49 #endif /* DAL_DC_INC_HW_VMID_H_ */
+12 -4
drivers/gpu/drm/amd/display/dc/inc/vm_helper.h
··· 28 28 29 29 #include "dc_types.h" 30 30 31 + #define MAX_VMID 16 31 32 #define MAX_HUBP 6 32 33 33 34 struct vmid_usage { 34 - int vmid_usage[2]; 35 + uint16_t vmid_usage[2]; 35 36 }; 36 37 37 38 struct vm_helper { 38 39 unsigned int num_vmid; 40 + unsigned int num_hubp; 41 + unsigned int num_vmids_available; 42 + uint64_t ptb_assigned_to_vmid[MAX_VMID]; 39 43 struct vmid_usage hubp_vmid_usage[MAX_HUBP]; 40 44 }; 41 45 42 - void vm_helper_mark_vmid_used(struct vm_helper *vm_helper, unsigned int pos, uint8_t hubp_idx); 46 + uint8_t get_vmid_for_ptb( 47 + struct vm_helper *vm_helper, 48 + int64_t ptb, 49 + uint8_t pipe_idx); 43 50 44 - void vm_helper_init( 51 + void init_vm_helper( 45 52 struct vm_helper *vm_helper, 46 - unsigned int num_vmid); 53 + unsigned int num_vmid, 54 + unsigned int num_hubp); 47 55 48 56 #endif /* DC_INC_VM_HELPER_H_ */