drm/amdgpu: Add parsing of acpi xcc objects
Subsystems (3)
Alex Deucher
maintainerPATCH 1/7 drm/amdgpu: Add parsing of acpi xcc objects
From: Lijo Lazar <[email protected]>
Add parsing of ACPI xcc objects and fill in relevant info from them by invoking the DSM methods.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 294 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + 3 files changed, 297 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1425,11 +1425,13 @@ int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);void amdgpu_acpi_get_backlight_caps (struct amdgpu_dm_backlight_caps *caps);bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev);void amdgpu_acpi_detect (void ); +void amdgpu_acpi_release (void );#else static inline int amdgpu_acpi_init (struct amdgpu_device *adev) {return 0 ; }static inline void amdgpu_acpi_fini (struct amdgpu_device *adev) { }static inline bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev) {return false; }static inline void amdgpu_acpi_detect (void ) { } +static inline void amdgpu_acpi_release (void ) { }static inline bool amdgpu_acpi_is_power_shift_control_supported (void ) {return false; }static inline int amdgpu_acpi_power_shift_control (struct amdgpu_device *adev,u8 dev_state,bool drv_state) {return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +294 -0
312 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -2907,6 +2907,7 @@ static void __exit amdgpu_exit(void)amdgpu_amdkfd_fini ();pci_unregister_driver (&amdgpu_kms_pci_driver);amdgpu_unregister_atpx_handler (); +amdgpu_acpi_release ();amdgpu_sync_fini ();amdgpu_fence_slab_fini ();mmu_notifier_synchronize ();
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 2/7 drm/amdgpu: Add API to get tmr info from acpi
From: Lijo Lazar <[email protected]>
In certain configs, TMR information is available from ACPI. Add API to fetch the information.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 +++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
@@ -1421,6 +1421,8 @@ int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev, u8 dev_state, bool drv_state);int amdgpu_acpi_smart_shift_update (struct drm_device *dev,enum amdgpu_ss ss_state);int amdgpu_acpi_pcie_notify_device_ready (struct amdgpu_device *adev); +int amdgpu_acpi_get_tmr_info (struct amdgpu_device *adev,u64 *tmr_offset, +u64 *tmr_size);void amdgpu_acpi_get_backlight_caps (struct amdgpu_dm_backlight_caps *caps);bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev);
@@ -1428,6 +1430,11 @@ void amdgpu_acpi_detect(void);void amdgpu_acpi_release (void );#else static inline int amdgpu_acpi_init (struct amdgpu_device *adev) {return 0 ; } +static inline int amdgpu_acpi_get_tmr_info (struct amdgpu_device *adev, +u64 *tmr_offset,u64 *tmr_size) +{ +return -EINVAL ; +}static inline void amdgpu_acpi_fini (struct amdgpu_device *adev) { }static inline bool amdgpu_acpi_should_gpu_reset (struct amdgpu_device *adev) {return false; }static inline void amdgpu_acpi_detect (void ) { }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +20 -0
@@ -1072,6 +1072,26 @@ static int amdgpu_acpi_enumerate_xcc(void)return 0 ; } +int amdgpu_acpi_get_tmr_info (struct amdgpu_device *adev,u64 *tmr_offset, +u64 *tmr_size) +{ +struct amdgpu_acpi_dev_info *dev_info; +u16 bdf; + +if (!tmr_offset || !tmr_size) +return -EINVAL ; + + bdf = (adev->pdev->bus->number <<8 ) | adev->pdev->devfn; + dev_info =amdgpu_acpi_get_dev (bdf); +if (!dev_info) +return -ENOENT ; + + *tmr_offset = dev_info->tmr_base; + *tmr_size = dev_info->tmr_size; + +return 0 ; +} +/** * amdgpu_acpi_event - handle notify events *
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 3/7 drm/amdgpu: Read discovery info from system memory
In reply to Alex DeucherFrom: Lijo Lazar <[email protected]>
On certain ASICs, discovery info is available at reserved region in system memory. The location is available through ACPI interface. Add API to read discovery info from there.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +23 -0
@@ -203,6 +203,29 @@ static int hw_id_map[MAX_HWIP] = { [PCIE_HWIP] = PCIE_HWID, }; +static int amdgpu_discovery_read_binary_from_sysmem (struct amdgpu_device *adev,uint8_t *binary) +{ +u64 tmr_offset, tmr_size, pos; +void *discv_regn; +int ret; + + ret =amdgpu_acpi_get_tmr_info (adev, &tmr_offset, &tmr_size); +if (ret) +return ret; + + pos = tmr_offset + tmr_size -DISCOVERY_TMR_OFFSET ; + +/* This region is read-only and reserved from system use */ + discv_regn =memremap (pos, adev->mman.discovery_tmr_size,MEMREMAP_WC ); +if (discv_regn) { +memcpy (binary, discv_regn, adev->mman.discovery_tmr_size); +memunmap (discv_regn); +return 0 ; + } + +return -ENOENT ; +} +static void amdgpu_discovery_read_binary_from_vram (struct amdgpu_device *adev,uint8_t *binary) {uint64_t vram_size = (uint64_t )RREG32 (mmRCC_CONFIG_MEMSIZE) <<20 ;
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 4/7 drm/amdgpu: Add fallback path for discovery info
In reply to Alex DeucherFrom: Lijo Lazar <[email protected]>
If SOC doesn't expose dedicated vram, discovery region may be available through system memory. Rename the existing interface to generic read_binary_from_mem and add a fallback path to read from system memory.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +16 -5
@@ -226,13 +226,21 @@ static int amdgpu_discovery_read_binary_from_sysmem(struct amdgpu_device *adev,return -ENOENT ; } -static void amdgpu_discovery_read_binary_from_vram (struct amdgpu_device *adev,uint8_t *binary) +static int amdgpu_discovery_read_binary_from_mem (struct amdgpu_device *adev, +uint8_t *binary) {uint64_t vram_size = (uint64_t )RREG32 (mmRCC_CONFIG_MEMSIZE) <<20 ; -uint64_t pos = vram_size -DISCOVERY_TMR_OFFSET ; +int ret =0 ; -amdgpu_device_vram_access (adev, pos, (uint32_t *)binary, - adev->mman.discovery_tmr_size, false); +if (vram_size) { +uint64_t pos = vram_size -DISCOVERY_TMR_OFFSET ; +amdgpu_device_vram_access (adev, pos, (uint32_t *)binary, + adev->mman.discovery_tmr_size, false); + }else { + ret =amdgpu_discovery_read_binary_from_sysmem (adev, binary); + } + +return ret; }static int amdgpu_discovery_read_binary_from_file (struct amdgpu_device *adev,uint8_t *binary)
@@ -338,7 +346,10 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev) } }else { -amdgpu_discovery_read_binary_from_vram (adev, adev->mman.discovery_bin); + r =amdgpu_discovery_read_binary_from_mem ( + adev, adev->mman.discovery_bin); +if (r) + goto out; }/* check the ip discovery binary signature */
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 5/7 drm/amdkfd: Flush TLB after unmapping for GFX v9.4.3
In reply to Alex DeucherFrom: Philip Yang <[email protected]>
kfd_flush_tlb_after_unmap should return true for GFX v9.4.3, to do TLB heavyweight flush after unmapping from GPU to guarantee that the GPU will not access pages after they have been unmapped. This also helps improve the mapping to GPU performance.
Without this, KFD accidently flush TLB after mapping to GPU because the vm update sequence number is increased by previous unmapping.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +3 -3
@@ -1405,9 +1405,9 @@ void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type);static inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev) { -return KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,2 ) || - (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && - dev->adev->sdma.instance[0 ].fw_version >=18 ) || +return KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,3 ) || +KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,2 ) || + (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && dev->sdma_fw_version >=18 ) ||KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,0 ); }
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 6/7 drm/amdgpu: Fix discovery sys node harvest info
In reply to Alex DeucherFrom: Lijo Lazar <[email protected]>
Initalize syfs nodes after harvest information is fetched and fetch the correct harvest info based on each IP instance.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +38 -3
@@ -877,6 +877,36 @@ static void ip_disc_release(struct kobject *kobj)kfree (ip_top); } +static uint8_t amdgpu_discovery_get_harvest_info (struct amdgpu_device *adev, +uint16_t hw_id,uint8_t inst) +{ +uint8_t harvest =0 ; + +/* Until a uniform way is figured, get mask based on hwid */ +switch (hw_id) { +case VCN_HWID : + harvest = (1 << inst) & adev->vcn.harvest_config; +break ; +case DMU_HWID : +if (adev->harvest_ip_mask &AMD_HARVEST_IP_DMU_MASK ) + harvest =0x1 ; +break ; +case UMC_HWID : +/* TODO: It needs another parsing; for now, ignore.*/ +break ; +case GC_HWID : + harvest = ((1 << inst) & adev->gfx.xcc_mask) ==0 ; +break ; +case SDMA0_HWID : + harvest = ((1 << inst) & adev->sdma.sdma_mask) ==0 ; +break ; +default : +break ; + } + +return harvest; +} + static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, struct ip_die_entry *ip_die_entry, const size_t _ip_offset, const int num_ips,
@@ -949,7 +979,10 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, ip_hw_instance->major = ip->major; ip_hw_instance->minor = ip->minor; ip_hw_instance->revision = ip->revision; - ip_hw_instance->harvest = ip->variant; + ip_hw_instance->harvest = +amdgpu_discovery_get_harvest_info ( + adev, ip_hw_instance->hw_id, + ip_hw_instance->num_instance); ip_hw_instance->num_base_addresses = ip->num_base_address;for (kk =0 ; kk < ip_hw_instance->num_base_addresses; kk++) {
@@ -1035,6 +1068,9 @@ static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)struct kset *die_kset;int res, ii; +if (!adev->mman.discovery_bin) +return -EINVAL ; + adev->ip_top =kzalloc (sizeof (*adev->ip_top),GFP_KERNEL );if (!adev->ip_top)return -ENOMEM ;
@@ -1282,8 +1318,6 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) } } -amdgpu_discovery_sysfs_init (adev); -return 0 ; }
@@ -2224,6 +2258,7 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) }amdgpu_discovery_init_soc_config (adev); +amdgpu_discovery_sysfs_init (adev);switch (adev->ip_versions[GC_HWIP ][0 ]) {case IP_VERSION (9 ,0 ,1 ):
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 7/7 drm/amdgpu: preserve the num_links in case of reflection
In reply to Alex DeucherFrom: Shiwu Zhang <[email protected]>
For topology reflection, each socket to every other socket has the exactly same topology info as the other way around. So it is safe to keep the reflected num_links value otherwise it will be overriden by the link info output of GET_PEER_LINKS command.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
@@ -1402,7 +1402,8 @@ int psp_xgmi_get_topology_info(struct psp_context *psp, topology->nodes[i].num_links = get_extended_data ? topology->nodes[i].num_links + link_info_output->nodes[i].num_links : - link_info_output->nodes[i].num_links; + ((requires_reflection && topology->nodes[i].num_links) ? topology->nodes[i].num_links : + link_info_output->nodes[i].num_links);/* reflect the topology information for bi-directionality */ if (requires_reflection && topology->nodes[i].num_hops)
Signature · 1 line
2.40.1