[PATCH 1/1] dma-direct: Fix dma_direct_use_pool helper

From: Alexander Stein
Date: Mon Dec 13 2021 - 07:33:25 EST


During refactoring the logic around gfpflags_allow_blocking() got inverted
due to missing '!'. Fix this by adding it back.

Fixes: 8d7c141bb80f ("dma-direct: add a dma_direct_use_pool helper")
Signed-off-by: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxx>
---
I bisected this to the commit in 'Fixed:' tag. Here is the splat:
------------[ cut here ]------------
Failed to get suitable pool for 30be0000.ethernet
WARNING: CPU: 0 PID: 62 at kernel/dma/pool.c:279 dma_alloc_from_pool+0x88/0x1d0
Modules linked in:
CPU: 0 PID: 62 Comm: kworker/u8:2 Not tainted 5.16.0-rc4-tq+ #238
Hardware name: TQ-Systems GmbH i.MX8MQ TQMa8MQ on MBa8Mx (DT)
Workqueue: events_unbound deferred_probe_work_func
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : dma_alloc_from_pool+0x88/0x1d0
lr : dma_alloc_from_pool+0x88/0x1d0
sp : ffff8000126b3860
x29: ffff8000126b3860 x28: ffff800012133d68 x27: 0000000000000000
x26: ffff0000c03e0000 x25: ffff8000126b3930 x24: ffff0000c08ee010
x23: ffff800012133d48 x22: ffff80001011f4b0 x21: ffff800011712820
x20: 0000000000018000 x19: ffff0000c0ef8000 x18: 0000000000000014
x17: 756420676e697375 x16: 202c646e756f6620 x15: 0000000000000000
x14: 0000000000000000 x13: 20726f66206c6f6f x12: 7020656c62617469
x11: 656820747563205b x10: 000000000000000a x9 : ffff8000126b3860
x8 : 000000000000000a x7 : 0000000000000011 x6 : 000000000000000a
x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000ffffffff
x2 : ffff800011eb6b30 x1 : 0000000000000000 x0 : 0000000000000000
Call trace:
dma_alloc_from_pool+0x88/0x1d0
dma_direct_alloc+0x8c/0x39c
dma_alloc_attrs+0x7c/0xe4
dmam_alloc_attrs+0x68/0xbc
fec_enet_init+0xfc/0x504
fec_probe+0x558/0x8b0
platform_probe+0x64/0x100
call_driver_probe+0x28/0x130
really_probe+0xbc/0x390
__driver_probe_device+0xfc/0x144
driver_probe_device+0xcc/0x150
__device_attach_driver+0xd4/0x180
bus_for_each_drv+0x74/0xc4
__device_attach+0xd8/0x1e0
device_initial_probe+0x10/0x20
bus_probe_device+0x90/0xa0
deferred_probe_work_func+0x9c/0xf0
process_one_work+0x1cc/0x360
worker_thread+0x214/0x3b0
kthread+0x150/0x160
ret_from_fork+0x10/0x20
---[ end trace 3934c72dbe137fa9 ]---

kernel/dma/direct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index d0a317ed8f02..50f48e9e4598 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -162,7 +162,7 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
*/
static bool dma_direct_use_pool(struct device *dev, gfp_t gfp)
{
- return gfpflags_allow_blocking(gfp) && !is_swiotlb_for_alloc(dev);
+ return !gfpflags_allow_blocking(gfp) && !is_swiotlb_for_alloc(dev);
}

static void *dma_direct_alloc_from_pool(struct device *dev, size_t size,
--
2.25.1