Skip to content

Commit 9e7f06c

Browse files
tiwaiChristoph Hellwig
authored andcommitted
swiotlb: fix unexpected swiotlb_alloc_coherent failures
The code refactoring by commit 0176adb ("swiotlb: refactor coherent buffer allocation") made swiotlb_alloc_buffer almost always failing due to a thinko: namely, the function evaluates the dma_coherent_ok call incorrectly and dealing as if it's invalid. This ends up with weird errors like iwlwifi probe failure or amdgpu screen flickering. This patch corrects the logic error. Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088658 Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088902 Fixes: 0176adb ("swiotlb: refactor coherent buffer allocation") Cc: <[email protected]> # v4.16+ Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent b284d4d commit 9e7f06c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/swiotlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ swiotlb_alloc_buffer(struct device *dev, size_t size, dma_addr_t *dma_handle,
719719
goto out_warn;
720720

721721
*dma_handle = __phys_to_dma(dev, phys_addr);
722-
if (dma_coherent_ok(dev, *dma_handle, size))
722+
if (!dma_coherent_ok(dev, *dma_handle, size))
723723
goto out_unmap;
724724

725725
memset(phys_to_virt(phys_addr), 0, size);

0 commit comments

Comments
 (0)