]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.16.4/swiotlb-fix-unexpected-swiotlb_alloc_coherent-failures.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / swiotlb-fix-unexpected-swiotlb_alloc_coherent-failures.patch
CommitLineData
2cd6bbae
GKH
1From 9e7f06c8beee304ee21b791653fefcd713f48b9a Mon Sep 17 00:00:00 2001
2From: Takashi Iwai <tiwai@suse.de>
3Date: Tue, 10 Apr 2018 19:05:13 +0200
4Subject: swiotlb: fix unexpected swiotlb_alloc_coherent failures
5
6From: Takashi Iwai <tiwai@suse.de>
7
8commit 9e7f06c8beee304ee21b791653fefcd713f48b9a upstream.
9
10The code refactoring by commit 0176adb00406 ("swiotlb: refactor coherent
11buffer allocation") made swiotlb_alloc_buffer almost always failing due
12to a thinko: namely, the function evaluates the dma_coherent_ok call
13incorrectly and dealing as if it's invalid. This ends up with weird
14errors like iwlwifi probe failure or amdgpu screen flickering.
15
16This patch corrects the logic error.
17
18Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088658
19Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088902
20Fixes: 0176adb00406 ("swiotlb: refactor coherent buffer allocation")
21Cc: <stable@vger.kernel.org> # v4.16+
22Signed-off-by: Takashi Iwai <tiwai@suse.de>
23Signed-off-by: Christoph Hellwig <hch@lst.de>
24Cc: Jean Delvare <jdelvare@suse.de>
25Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27---
28 lib/swiotlb.c | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31--- a/lib/swiotlb.c
32+++ b/lib/swiotlb.c
33@@ -732,7 +732,7 @@ swiotlb_alloc_buffer(struct device *dev,
34 goto out_warn;
35
36 *dma_handle = swiotlb_phys_to_dma(dev, phys_addr);
37- if (dma_coherent_ok(dev, *dma_handle, size))
38+ if (!dma_coherent_ok(dev, *dma_handle, size))
39 goto out_unmap;
40
41 memset(phys_to_virt(phys_addr), 0, size);