Skip to content

Commit 328335a

Browse files
Gaurav Batramaddy-kerneldev
authored andcommitted
powerpc/powernv/iommu: iommu incorrectly bypass DMA APIs
In a PowerNV environment, for devices that supports DMA mask less than 64 bit but larger than 32 bits, iommu is incorrectly bypassing DMA APIs while allocating and mapping buffers for DMA operations. Devices are failing with ENOMEN during probe with the following messages amdgpu 0000:01:00.0: [drm] Detected VRAM RAM=4096M, BAR=4096M amdgpu 0000:01:00.0: [drm] RAM width 128bits GDDR5 amdgpu 0000:01:00.0: iommu: 64-bit OK but direct DMA is limited by 0 amdgpu 0000:01:00.0: dma_iommu_get_required_mask: returning bypass mask 0xfffffffffffffff amdgpu 0000:01:00.0: 4096M of VRAM memory ready amdgpu 0000:01:00.0: 32570M of GTT memory ready. amdgpu 0000:01:00.0: (-12) failed to allocate kernel bo amdgpu 0000:01:00.0: [drm] Debug VRAM access will use slowpath MM access amdgpu 0000:01:00.0: [drm] GART: num cpu pages 4096, num gpu pages 65536 amdgpu 0000:01:00.0: [drm] PCIE GART of 256M enabled (table at 0x000000F4FFF80000). amdgpu 0000:01:00.0: (-12) failed to allocate kernel bo amdgpu 0000:01:00.0: (-12) create WB bo failed amdgpu 0000:01:00.0: amdgpu_device_wb_init failed -12 amdgpu 0000:01:00.0: amdgpu_device_ip_init failed amdgpu 0000:01:00.0: Fatal error during GPU init amdgpu 0000:01:00.0: finishing device. amdgpu 0000:01:00.0: probe with driver amdgpu failed with error -12 amdgpu 0000:01:00.0: ttm finalized Fixes: 1471c51 ("powerpc/iommu: bypass DMA APIs for coherent allocations for pre-mapped memory") Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Reported-by: Dan Horák <dan@danny.cz> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5039 Tested-by: Dan Horak <dan@danny.cz> Closes: https://lore.kernel.org/linuxppc-dev/20260313142351.609bc4c3efe1184f64ca5f44@danny.cz/ Signed-off-by: Gaurav Batra <gbatra@linux.ibm.com> Closes: https://lore.kernel.org/linuxppc-dev/20260313142351.609bc4c3efe1184f64ca5f44@danny.cz/ [Maddy: Fixed tags] Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260331223022.47488-1-gbatra@linux.ibm.com
1 parent f338e77 commit 328335a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/powerpc/kernel/dma-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ bool arch_dma_unmap_sg_direct(struct device *dev, struct scatterlist *sg,
6767
}
6868
bool arch_dma_alloc_direct(struct device *dev)
6969
{
70-
if (dev->dma_ops_bypass)
70+
if (dev->dma_ops_bypass && dev->bus_dma_limit)
7171
return true;
7272

7373
return false;
7474
}
7575

7676
bool arch_dma_free_direct(struct device *dev, dma_addr_t dma_handle)
7777
{
78-
if (!dev->dma_ops_bypass)
78+
if (!dev->dma_ops_bypass || !dev->bus_dma_limit)
7979
return false;
8080

8181
return is_direct_handle(dev, dma_handle);

0 commit comments

Comments
 (0)