]>
Commit | Line | Data |
---|---|---|
2cd6bbae GKH |
1 | From 9e7f06c8beee304ee21b791653fefcd713f48b9a Mon Sep 17 00:00:00 2001 |
2 | From: Takashi Iwai <tiwai@suse.de> | |
3 | Date: Tue, 10 Apr 2018 19:05:13 +0200 | |
4 | Subject: swiotlb: fix unexpected swiotlb_alloc_coherent failures | |
5 | ||
6 | From: Takashi Iwai <tiwai@suse.de> | |
7 | ||
8 | commit 9e7f06c8beee304ee21b791653fefcd713f48b9a upstream. | |
9 | ||
10 | The code refactoring by commit 0176adb00406 ("swiotlb: refactor coherent | |
11 | buffer allocation") made swiotlb_alloc_buffer almost always failing due | |
12 | to a thinko: namely, the function evaluates the dma_coherent_ok call | |
13 | incorrectly and dealing as if it's invalid. This ends up with weird | |
14 | errors like iwlwifi probe failure or amdgpu screen flickering. | |
15 | ||
16 | This patch corrects the logic error. | |
17 | ||
18 | Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088658 | |
19 | Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1088902 | |
20 | Fixes: 0176adb00406 ("swiotlb: refactor coherent buffer allocation") | |
21 | Cc: <stable@vger.kernel.org> # v4.16+ | |
22 | Signed-off-by: Takashi Iwai <tiwai@suse.de> | |
23 | Signed-off-by: Christoph Hellwig <hch@lst.de> | |
24 | Cc: Jean Delvare <jdelvare@suse.de> | |
25 | Signed-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); |