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

drm/amdgpu: Add NPS switch support for GC 9.4.3

Add dynamic NPS switch support for GC 9.4.3 variants. Only GC v9.4.3 and
GC v9.4.4 currently support this. NPS switch is only supported if an SOC
supports multiple NPS modes.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
c29aeadf d594ddc6

+58
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
··· 101 101 int (*get_compute_partition_mode)(struct amdgpu_device *adev); 102 102 u32 (*get_memory_partition_mode)(struct amdgpu_device *adev, 103 103 u32 *supp_modes); 104 + bool (*is_nps_switch_requested)(struct amdgpu_device *adev); 104 105 u64 (*get_pcie_replay_count)(struct amdgpu_device *adev); 105 106 void (*set_reg_remap)(struct amdgpu_device *adev); 106 107 };
+45
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 1395 1395 return gmc_v9_0_get_memory_partition(adev, NULL); 1396 1396 } 1397 1397 1398 + static bool gmc_v9_0_need_reset_on_init(struct amdgpu_device *adev) 1399 + { 1400 + if (adev->nbio.funcs && adev->nbio.funcs->is_nps_switch_requested && 1401 + adev->nbio.funcs->is_nps_switch_requested(adev)) { 1402 + adev->gmc.reset_flags |= AMDGPU_GMC_INIT_RESET_NPS; 1403 + return true; 1404 + } 1405 + 1406 + return false; 1407 + } 1408 + 1398 1409 static const struct amdgpu_gmc_funcs gmc_v9_0_gmc_funcs = { 1399 1410 .flush_gpu_tlb = gmc_v9_0_flush_gpu_tlb, 1400 1411 .flush_gpu_tlb_pasid = gmc_v9_0_flush_gpu_tlb_pasid, ··· 1417 1406 .override_vm_pte_flags = gmc_v9_0_override_vm_pte_flags, 1418 1407 .get_vbios_fb_size = gmc_v9_0_get_vbios_fb_size, 1419 1408 .query_mem_partition_mode = &gmc_v9_0_query_memory_partition, 1409 + .request_mem_partition_mode = &amdgpu_gmc_request_memory_partition, 1410 + .need_reset_on_init = &gmc_v9_0_need_reset_on_init, 1420 1411 }; 1421 1412 1422 1413 static void gmc_v9_0_set_gmc_funcs(struct amdgpu_device *adev) ··· 1556 1543 { 1557 1544 if (!adev->gmc.xgmi.connected_to_cpu) 1558 1545 adev->gmc.xgmi.ras = &xgmi_ras; 1546 + } 1547 + 1548 + static void gmc_v9_0_init_nps_details(struct amdgpu_device *adev) 1549 + { 1550 + adev->gmc.supported_nps_modes = 0; 1551 + 1552 + if (amdgpu_sriov_vf(adev) || (adev->flags & AMD_IS_APU)) 1553 + return; 1554 + 1555 + /*TODO: Check PSP version also which supports NPS switch. Otherwise keep 1556 + * supported modes as 0. 1557 + */ 1558 + switch (amdgpu_ip_version(adev, GC_HWIP, 0)) { 1559 + case IP_VERSION(9, 4, 3): 1560 + case IP_VERSION(9, 4, 4): 1561 + adev->gmc.supported_nps_modes = 1562 + BIT(AMDGPU_NPS1_PARTITION_MODE) | 1563 + BIT(AMDGPU_NPS4_PARTITION_MODE); 1564 + break; 1565 + default: 1566 + break; 1567 + } 1559 1568 } 1560 1569 1561 1570 static int gmc_v9_0_early_init(struct amdgpu_ip_block *ip_block) ··· 2200 2165 if (r) 2201 2166 return r; 2202 2167 2168 + gmc_v9_0_init_nps_details(adev); 2203 2169 /* 2204 2170 * number of VMs 2205 2171 * VMID 0 is reserved for System ··· 2471 2435 2472 2436 static int gmc_v9_0_resume(struct amdgpu_ip_block *ip_block) 2473 2437 { 2438 + struct amdgpu_device *adev = ip_block->adev; 2474 2439 int r; 2440 + 2441 + /* If a reset is done for NPS mode switch, read the memory range 2442 + * information again. 2443 + */ 2444 + if (adev->gmc.reset_flags & AMDGPU_GMC_INIT_RESET_NPS) { 2445 + gmc_v9_0_init_sw_mem_ranges(adev, adev->gmc.mem_partitions); 2446 + adev->gmc.reset_flags &= ~AMDGPU_GMC_INIT_RESET_NPS; 2447 + } 2475 2448 2476 2449 r = gmc_v9_0_hw_init(ip_block); 2477 2450 if (r)
+12
drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
··· 401 401 return px; 402 402 } 403 403 404 + static bool nbio_v7_9_is_nps_switch_requested(struct amdgpu_device *adev) 405 + { 406 + u32 tmp; 407 + 408 + tmp = RREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_MEM_STATUS); 409 + tmp = REG_GET_FIELD(tmp, BIF_BX_PF0_PARTITION_MEM_STATUS, 410 + CHANGE_STATUE); 411 + 412 + /* 0x8 - NPS switch requested */ 413 + return (tmp == 0x8); 414 + } 404 415 static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, 405 416 u32 *supp_modes) 406 417 { ··· 519 508 .remap_hdp_registers = nbio_v7_9_remap_hdp_registers, 520 509 .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode, 521 510 .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode, 511 + .is_nps_switch_requested = nbio_v7_9_is_nps_switch_requested, 522 512 .init_registers = nbio_v7_9_init_registers, 523 513 .get_pcie_replay_count = nbio_v7_9_get_pcie_replay_count, 524 514 .set_reg_remap = nbio_v7_9_set_reg_remap,