From nobody Wed Feb 11 16:22:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1512C77B73 for ; Sat, 6 May 2023 07:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbjEFHuF convert rfc822-to-8bit (ORCPT ); Sat, 6 May 2023 03:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjEFHuC (ORCPT ); Sat, 6 May 2023 03:50:02 -0400 X-Greylist: delayed 598 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 06 May 2023 00:50:00 PDT Received: from mta17.hihonor.com (mta17.hihonor.com [8.141.223.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9B076A5 for ; Sat, 6 May 2023 00:50:00 -0700 (PDT) Received: from a003.hihonor.com (unknown [10.68.18.8]) by mta17.hihonor.com (SkyGuard) with ESMTPS id 4QCzlj45PyzCrrZ; Sat, 6 May 2023 15:32:17 +0800 (CST) Received: from a007.hihonor.com (10.68.22.31) by a003.hihonor.com (10.68.18.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21; Sat, 6 May 2023 15:33:34 +0800 Received: from a007.hihonor.com ([fe80::fc39:c25:3c0f:a4e7]) by a007.hihonor.com ([fe80::fc39:c25:3c0f:a4e7%10]) with mapi id 15.02.1118.021; Sat, 6 May 2023 15:33:34 +0800 From: gaoxu 00016977 To: "hch@lst.de" , "m.szyprowski@samsung.com" CC: "robin.murphy@arm.com" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "surenb@google.com" , yipengxiang 00013268 , wangbintian 00013160 , hanfeng 00012985 Subject: [PATCH] dma-remap: Use kvmalloc_array/kvfree for larger dma memory remap Thread-Topic: [PATCH] dma-remap: Use kvmalloc_array/kvfree for larger dma memory remap Thread-Index: Adl/7N1/zhRx438JTrqVRawCg6p65Q== Date: Sat, 6 May 2023 07:33:33 +0000 Message-ID: <18448ae569e24dfd84e811081ede376f@hihonor.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.164.11.140] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If dma_direct_alloc() alloc memory in size of 64MB, the inner function dma_common_contiguous_remap() will allocate 128KB memory by invoking=20 the function kmalloc_array(). and the kmalloc_array seems to fail to try to allocate 128KB mem. work around by doing kvmalloc_array instead. Signed-off-by: Gao Xu Reviewed-by: Suren Baghdasaryan --- 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 b45266680..27596= f3b4 100644 --- a/kernel/dma/remap.c +++ b/kernel/dma/remap.c @@ -43,13 +43,13 @@ void *dma_common_contiguous_remap(struct page *page, si= ze_t size, void *vaddr; int i; =20 - pages =3D kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); + pages =3D kvmalloc_array(count, sizeof(struct page *), GFP_KERNEL); if (!pages) return NULL; for (i =3D 0; i < count; i++) pages[i] =3D nth_page(page, i); vaddr =3D vmap(pages, count, VM_DMA_COHERENT, prot); - kfree(pages); + kvfree(pages); =20 return vaddr; } -- 2.17.1