From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: gaoxu <gaoxu2@hihonor.com>,
Suren Baghdasaryan <surenb@google.com>,
Christoph Hellwig <hch@lst.de>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.10 12/22] dma-remap: use kvmalloc_array/kvfree for larger dma memory remap
Date: Sun, 23 Jul 2023 21:24:09 -0400 [thread overview]
Message-ID: <20230724012419.2317649-12-sashal@kernel.org> (raw)
In-Reply-To: <20230724012419.2317649-1-sashal@kernel.org>
From: gaoxu <gaoxu2@hihonor.com>
[ Upstream commit 51ff97d54f02b4444dfc42e380ac4c058e12d5dd ]
If dma_direct_alloc() alloc memory in size of 64MB, the inner function
dma_common_contiguous_remap() will allocate 128KB memory by invoking
the function kmalloc_array(). and the kmalloc_array seems to fail to try to
allocate 128KB mem.
Call trace:
[14977.928623] qcrosvm: page allocation failure: order:5, mode:0x40cc0
[14977.928638] dump_backtrace.cfi_jt+0x0/0x8
[14977.928647] dump_stack_lvl+0x80/0xb8
[14977.928652] warn_alloc+0x164/0x200
[14977.928657] __alloc_pages_slowpath+0x9f0/0xb4c
[14977.928660] __alloc_pages+0x21c/0x39c
[14977.928662] kmalloc_order+0x48/0x108
[14977.928666] kmalloc_order_trace+0x34/0x154
[14977.928668] __kmalloc+0x548/0x7e4
[14977.928673] dma_direct_alloc+0x11c/0x4f8
[14977.928678] dma_alloc_attrs+0xf4/0x138
[14977.928680] gh_vm_ioctl_set_fw_name+0x3c4/0x610 [gunyah]
[14977.928698] gh_vm_ioctl+0x90/0x14c [gunyah]
[14977.928705] __arm64_sys_ioctl+0x184/0x210
work around by doing kvmalloc_array instead.
Signed-off-by: Gao Xu <gaoxu2@hihonor.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/dma/remap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c
index 905c3fa005f10..5bff061993102 100644
--- a/kernel/dma/remap.c
+++ b/kernel/dma/remap.c
@@ -43,13 +43,13 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
void *vaddr;
int i;
- pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
+ pages = kvmalloc_array(count, sizeof(struct page *), GFP_KERNEL);
if (!pages)
return NULL;
for (i = 0; i < count; i++)
pages[i] = nth_page(page, i);
vaddr = vmap(pages, count, VM_DMA_COHERENT, prot);
- kfree(pages);
+ kvfree(pages);
return vaddr;
}
--
2.39.2
next prev parent reply other threads:[~2023-07-24 1:28 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 1:23 [PATCH AUTOSEL 5.10 01/22] drm/radeon: Fix integer overflow in radeon_cs_parser_init Sasha Levin
2023-07-24 1:23 ` Sasha Levin
2023-07-24 1:23 ` [PATCH AUTOSEL 5.10 02/22] ALSA: emu10k1: roll up loops in DSP setup code for Audigy Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 03/22] ASoC: Intel: sof_sdw: add quirk for MTL RVP Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 04/22] ASoC: Intel: sof_sdw: add quirk for LNL RVP Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 05/22] PCI: tegra194: Fix possible array out of bounds access Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 06/22] ARM: dts: imx6dl: prtrvt, prtvt7, prti6q, prtwd2: fix USB related warnings Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 07/22] ASoC: Intel: sof_sdw: Add support for Rex soundwire Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 08/22] iopoll: Call cpu_relax() in busy loops Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 09/22] quota: Properly disable quotas when add_dquot_ref() fails Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 10/22] quota: fix warning in dqgrab() Sasha Levin
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 11/22] ALSA: hda: Add Loongson LS7A HD-Audio support Sasha Levin
2023-07-24 1:24 ` Sasha Levin [this message]
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 13/22] drm/amdgpu: install stub fence into potential unused fence pointers Sasha Levin
2023-07-24 1:24 ` Sasha Levin
2023-07-24 1:24 ` Sasha Levin
2023-08-30 18:53 ` Chia-I Wu
2023-08-30 18:53 ` Chia-I Wu
2023-08-31 10:27 ` Christian König
2023-08-31 10:27 ` Christian König
2023-08-31 10:56 ` Greg KH
2023-08-31 10:56 ` Greg KH
2023-08-31 10:56 ` Greg KH
2023-08-31 13:26 ` Christian König
2023-08-31 13:26 ` Christian König
2023-08-31 13:26 ` Christian König
2023-08-31 14:01 ` Greg KH
2023-08-31 14:01 ` Greg KH
2023-08-31 14:01 ` Greg KH
2023-08-31 18:55 ` Chia-I Wu
2023-08-31 18:55 ` Chia-I Wu
2023-09-01 6:02 ` Christian König
2023-09-01 6:02 ` Christian König
2023-09-04 0:41 ` Eddie Chapman
2023-09-04 0:41 ` Eddie Chapman
2023-08-31 10:29 ` Greg KH
2023-08-31 10:29 ` Greg KH
2023-09-10 20:43 ` Bryan Jennings
2023-09-10 20:43 ` Bryan Jennings
2023-09-10 20:43 ` Bryan Jennings
2023-09-12 11:31 ` Greg KH
2023-09-12 11:31 ` Greg KH
2023-09-12 11:31 ` Greg KH
2023-10-07 9:50 ` Greg KH
2023-10-07 9:50 ` Greg KH
2023-10-07 9:50 ` Greg KH
2023-10-09 12:46 ` Christian König
2023-10-09 12:46 ` Christian König
2023-10-09 12:46 ` Christian König
2023-10-09 18:09 ` Greg KH
2023-10-09 18:09 ` Greg KH
2023-10-09 18:09 ` Greg KH
2023-07-24 1:24 ` [PATCH AUTOSEL 5.10 14/22] HID: add quirk for 03f0:464a HP Elite Presenter Mouse Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724012419.2317649-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gaoxu2@hihonor.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.