* [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping
@ 2021-02-02 1:06 Douglas Anderson
2021-02-02 1:30 ` Yong Wu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Douglas Anderson @ 2021-02-02 1:06 UTC (permalink / raw)
To: Yong Wu, Will Deacon, joro
Cc: Douglas Anderson, Robin Murphy, iommu, linux-kernel
Sleeping while atomic = bad. Let's fix an obvious typo to try to avoid it.
The warning that was seen (on a downstream kernel with the problematic
patch backported):
BUG: sleeping function called from invalid context at mm/page_alloc.c:4726
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 9, name: ksoftirqd/0
CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.4.93-12508-gc10c93e28e39 #1
Call trace:
dump_backtrace+0x0/0x154
show_stack+0x20/0x2c
dump_stack+0xa0/0xfc
___might_sleep+0x11c/0x12c
__might_sleep+0x50/0x84
__alloc_pages_nodemask+0xf8/0x2bc
__arm_lpae_alloc_pages+0x48/0x1b4
__arm_lpae_map+0x124/0x274
__arm_lpae_map+0x1cc/0x274
arm_lpae_map+0x140/0x170
arm_smmu_map+0x78/0xbc
__iommu_map+0xd4/0x210
_iommu_map+0x4c/0x84
iommu_map_atomic+0x44/0x58
__iommu_dma_map+0x8c/0xc4
iommu_dma_map_page+0xac/0xf0
Fixes: d8c1df02ac7f ("iommu: Move iotlb_sync_map out from __iommu_map")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
I haven't done any serious testing on this. I saw a report of the
warning and the fix seemed obvious so I'm shooting it out.
drivers/iommu/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3d099a31ddca..2b06b01850d5 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2441,7 +2441,7 @@ static int _iommu_map(struct iommu_domain *domain, unsigned long iova,
const struct iommu_ops *ops = domain->ops;
int ret;
- ret = __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
+ ret = __iommu_map(domain, iova, paddr, size, prot, gfp);
if (ret == 0 && ops->iotlb_sync_map)
ops->iotlb_sync_map(domain, iova, size);
--
2.30.0.365.g02bc693789-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping
2021-02-02 1:06 [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping Douglas Anderson
@ 2021-02-02 1:30 ` Yong Wu
2021-02-02 13:52 ` Will Deacon
2021-02-02 13:58 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Yong Wu @ 2021-02-02 1:30 UTC (permalink / raw)
To: Douglas Anderson
Cc: Will Deacon, joro, Robin Murphy, iommu, linux-kernel, linux-mediatek
On Mon, 2021-02-01 at 17:06 -0800, Douglas Anderson wrote:
> Sleeping while atomic = bad. Let's fix an obvious typo to try to avoid it.
>
> The warning that was seen (on a downstream kernel with the problematic
> patch backported):
>
> BUG: sleeping function called from invalid context at mm/page_alloc.c:4726
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 9, name: ksoftirqd/0
> CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.4.93-12508-gc10c93e28e39 #1
> Call trace:
> dump_backtrace+0x0/0x154
> show_stack+0x20/0x2c
> dump_stack+0xa0/0xfc
> ___might_sleep+0x11c/0x12c
> __might_sleep+0x50/0x84
> __alloc_pages_nodemask+0xf8/0x2bc
> __arm_lpae_alloc_pages+0x48/0x1b4
> __arm_lpae_map+0x124/0x274
> __arm_lpae_map+0x1cc/0x274
> arm_lpae_map+0x140/0x170
> arm_smmu_map+0x78/0xbc
> __iommu_map+0xd4/0x210
> _iommu_map+0x4c/0x84
> iommu_map_atomic+0x44/0x58
> __iommu_dma_map+0x8c/0xc4
> iommu_dma_map_page+0xac/0xf0
>
> Fixes: d8c1df02ac7f ("iommu: Move iotlb_sync_map out from __iommu_map")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
oh. This is my fault. Thanks for the fix.
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> ---
> I haven't done any serious testing on this. I saw a report of the
> warning and the fix seemed obvious so I'm shooting it out.
>
> drivers/iommu/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 3d099a31ddca..2b06b01850d5 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2441,7 +2441,7 @@ static int _iommu_map(struct iommu_domain *domain, unsigned long iova,
> const struct iommu_ops *ops = domain->ops;
> int ret;
>
> - ret = __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
> + ret = __iommu_map(domain, iova, paddr, size, prot, gfp);
> if (ret == 0 && ops->iotlb_sync_map)
> ops->iotlb_sync_map(domain, iova, size);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping
2021-02-02 1:06 [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping Douglas Anderson
2021-02-02 1:30 ` Yong Wu
@ 2021-02-02 13:52 ` Will Deacon
2021-02-02 13:58 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2021-02-02 13:52 UTC (permalink / raw)
To: Douglas Anderson; +Cc: Yong Wu, joro, Robin Murphy, iommu, linux-kernel
On Mon, Feb 01, 2021 at 05:06:23PM -0800, Douglas Anderson wrote:
> Sleeping while atomic = bad. Let's fix an obvious typo to try to avoid it.
>
> The warning that was seen (on a downstream kernel with the problematic
> patch backported):
>
> BUG: sleeping function called from invalid context at mm/page_alloc.c:4726
> in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 9, name: ksoftirqd/0
> CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.4.93-12508-gc10c93e28e39 #1
> Call trace:
> dump_backtrace+0x0/0x154
> show_stack+0x20/0x2c
> dump_stack+0xa0/0xfc
> ___might_sleep+0x11c/0x12c
> __might_sleep+0x50/0x84
> __alloc_pages_nodemask+0xf8/0x2bc
> __arm_lpae_alloc_pages+0x48/0x1b4
> __arm_lpae_map+0x124/0x274
> __arm_lpae_map+0x1cc/0x274
> arm_lpae_map+0x140/0x170
> arm_smmu_map+0x78/0xbc
Damn, I'm annoyed that I didn't come across this in testing. Looks like
arm64 defconfig doesn't have DEBUG_ATOMIC_SLEEP, so that's probably why.
I'll see if I can adjust my scripts to enable that (and some others) for
the builds I actually run.
> __iommu_map+0xd4/0x210
> _iommu_map+0x4c/0x84
> iommu_map_atomic+0x44/0x58
> __iommu_dma_map+0x8c/0xc4
> iommu_dma_map_page+0xac/0xf0
>
> Fixes: d8c1df02ac7f ("iommu: Move iotlb_sync_map out from __iommu_map")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> I haven't done any serious testing on this. I saw a report of the
> warning and the fix seemed obvious so I'm shooting it out.
>
> drivers/iommu/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Will Deacon <will@kernel.org>
Joerg -- please can you apply this one on top of the pull request I sent
yesterday?
Cheers,
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping
2021-02-02 1:06 [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping Douglas Anderson
2021-02-02 1:30 ` Yong Wu
2021-02-02 13:52 ` Will Deacon
@ 2021-02-02 13:58 ` Joerg Roedel
2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2021-02-02 13:58 UTC (permalink / raw)
To: Douglas Anderson; +Cc: Yong Wu, Will Deacon, Robin Murphy, iommu, linux-kernel
On Mon, Feb 01, 2021 at 05:06:23PM -0800, Douglas Anderson wrote:
> drivers/iommu/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-02 19:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 1:06 [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping Douglas Anderson
2021-02-02 1:30 ` Yong Wu
2021-02-02 13:52 ` Will Deacon
2021-02-02 13:58 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).