xref: /linux/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c (revision 6fdd68b1)
1bf0a60b7SAlex Deucher /*
2bf0a60b7SAlex Deucher  * Copyright 2018 Advanced Micro Devices, Inc.
3bf0a60b7SAlex Deucher  *
4bf0a60b7SAlex Deucher  * Permission is hereby granted, free of charge, to any person obtaining a
5bf0a60b7SAlex Deucher  * copy of this software and associated documentation files (the "Software"),
6bf0a60b7SAlex Deucher  * to deal in the Software without restriction, including without limitation
7bf0a60b7SAlex Deucher  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf0a60b7SAlex Deucher  * and/or sell copies of the Software, and to permit persons to whom the
9bf0a60b7SAlex Deucher  * Software is furnished to do so, subject to the following conditions:
10bf0a60b7SAlex Deucher  *
11bf0a60b7SAlex Deucher  * The above copyright notice and this permission notice shall be included in
12bf0a60b7SAlex Deucher  * all copies or substantial portions of the Software.
13bf0a60b7SAlex Deucher  *
14bf0a60b7SAlex Deucher  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf0a60b7SAlex Deucher  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf0a60b7SAlex Deucher  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bf0a60b7SAlex Deucher  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18bf0a60b7SAlex Deucher  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19bf0a60b7SAlex Deucher  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20bf0a60b7SAlex Deucher  * OTHER DEALINGS IN THE SOFTWARE.
21bf0a60b7SAlex Deucher  *
22bf0a60b7SAlex Deucher  */
23bf0a60b7SAlex Deucher #include "amdgpu.h"
24bf0a60b7SAlex Deucher #include "gfxhub_v1_1.h"
25bf0a60b7SAlex Deucher 
26bf0a60b7SAlex Deucher #include "gc/gc_9_2_1_offset.h"
27bf0a60b7SAlex Deucher #include "gc/gc_9_2_1_sh_mask.h"
28bf0a60b7SAlex Deucher 
29bf0a60b7SAlex Deucher #include "soc15_common.h"
30bf0a60b7SAlex Deucher 
31bf0a60b7SAlex Deucher int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev)
32bf0a60b7SAlex Deucher {
33bf0a60b7SAlex Deucher 	u32 xgmi_lfb_cntl = RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_CNTL);
34bf0a60b7SAlex Deucher 	u32 max_region =
35bf0a60b7SAlex Deucher 		REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_MAX_REGION);
36bf0a60b7SAlex Deucher 
37bf0a60b7SAlex Deucher 	/* PF_MAX_REGION=0 means xgmi is disabled */
38bf0a60b7SAlex Deucher 	if (max_region) {
39bf0a60b7SAlex Deucher 		adev->gmc.xgmi.num_physical_nodes = max_region + 1;
40bf0a60b7SAlex Deucher 		if (adev->gmc.xgmi.num_physical_nodes > 4)
41bf0a60b7SAlex Deucher 			return -EINVAL;
42bf0a60b7SAlex Deucher 
43bf0a60b7SAlex Deucher 		adev->gmc.xgmi.physical_node_id =
44bf0a60b7SAlex Deucher 			REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_LFB_REGION);
45bf0a60b7SAlex Deucher 		if (adev->gmc.xgmi.physical_node_id > 3)
46bf0a60b7SAlex Deucher 			return -EINVAL;
47*6fdd68b1SAlex Deucher 		adev->gmc.xgmi.node_segment_size = REG_GET_FIELD(
48*6fdd68b1SAlex Deucher 			RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_SIZE),
49*6fdd68b1SAlex Deucher 			MC_VM_XGMI_LFB_SIZE, PF_LFB_SIZE) << 24;
50bf0a60b7SAlex Deucher 	}
51bf0a60b7SAlex Deucher 
52bf0a60b7SAlex Deucher 	return 0;
53bf0a60b7SAlex Deucher }
54