Skip to content

Commit

Permalink
drm/amdgpu: Query P2PDMA distance only if CONFIG_HSA_AMD_P2P is defined
Browse files Browse the repository at this point in the history
CONFIG_HSA_AMD_P2P indicates the requirements that are needed for P2P DMA
Mappings. It is important to note that enabling CONFIG_HSA_AMD_P2P is a
necessary but insufficient condition. It is possible to encounter runtime
errors - e.g. CPU's do not support Inter-CPU transport of PCIe transaction
packets i.e. P2PDMA distance API may return error

Signed-off-by: Ramesh Errabolu <Ramesh.Errabolu@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
  • Loading branch information
rerrabolu committed Oct 18, 2022
1 parent 437f02c commit c191515
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -5577,6 +5577,12 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
* Return true if @peer_adev can access (DMA) @adev through the PCIe
* BAR, i.e. @adev is "large BAR" and the BAR matches the DMA mask of
* @peer_adev.
*
* @note: CONFIG_HSA_AMD_P2P indicates support for P2P DMA mappings. Query
* P2PDMA distance only if the kernel has all the prerequisites for P2P DMA
* support. Otherwise fall back to the less reliable legacy P2P support to
* avoid regressions.
*
*/
bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
struct amdgpu_device *peer_adev)
Expand All @@ -5587,7 +5593,7 @@ bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
resource_size_t aper_limit =
adev->gmc.aper_base + adev->gmc.aper_size - 1;

#ifdef CONFIG_PCI_P2PDMA
#ifdef CONFIG_HSA_AMD_P2P
p2p_access = !adev->gmc.xgmi.connected_to_cpu &&
!(pci_p2pdma_distance_many(adev->pdev,
&peer_adev->dev, 1, true) < 0);
Expand Down

0 comments on commit c191515

Please sign in to comment.