From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E380E3BC668 for ; Mon, 22 Jun 2026 14:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782139519; cv=none; b=j7fgA98yiEfAK4UZYmz/k4gAKG4h7QgiZ3K+5oNZZI/UZIyF0Z13G6qCnicKPA+0/3rElbHqkPR422xiWeXg3j0+5pI7f8REX7k/asxjbYqLI55wDc7mEPtc0Pu/9rIiz5fD8AaLykOaa6TZC5hBzB2H7U7K/VdEr2UYmuHGNh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782139519; c=relaxed/simple; bh=LA7aUgosHwpJNqhhdQ6Hlje+F/G2SdsLcNndAVB2eBE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Mr/ArsfEYC21K16wnA2TgyINwVXmjCAdS4ZBWIGLwytl8ncihIqqyRUM/lwxV3Vm7YHgUsheUxgHmCZiKMIcZ3d6sa0nn7GpJ611zkanzJvaNI46a91dvLCAZ+jpB74GnR2rUoeNNem+s26BEx6RBYEp365Bv8Arw9pooG7kRsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ZgzVryjJ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=OJFtqsZy; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="ZgzVryjJ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="OJFtqsZy" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65MDFjmJ3533226 for ; Mon, 22 Jun 2026 14:45:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= gV4xDRUurhfQjcVnQzsMOKQF1/Zp8ED3KFqFWdXznZ0=; b=ZgzVryjJ0FApmJcK P0vLglnB8o12f2Lf9AIhmXnRpEPnj24uPSb2WE2ObJ/obUZ/8PMQw7foD2M1hvuf eBU2t55Emfc0aFujQJfvM+1P8yayZmqbUxfQ6LPC27RfxXa4Jvp7RUDkjXQlCGrI Wq5/6ED48lVMIsXuJ1D1sVoB0hGFr4ng16YpusFhFZNEMOkNd2P+ziVdQ8+juOpD kJsFx33JDdplrgOK3j0TCl3Ae9Uow3xyhFycOYldfN/wZerRPlqxFaE9c7CkXmKe 8WPWC1wF2u/iZu6oZroxMYq2vgT3ZH7p90n1U0XETkN0zjNRUqte7CN9eq/YxOWh kP1AMg== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ey2yhrxnm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 22 Jun 2026 14:45:16 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-8421f5d76aaso3087490b3a.2 for ; Mon, 22 Jun 2026 07:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782139515; x=1782744315; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=gV4xDRUurhfQjcVnQzsMOKQF1/Zp8ED3KFqFWdXznZ0=; b=OJFtqsZyikcrgXxo5+2J7biKA+xtP0YNX8EVeGPZKAq+6cD8doqNbID7DkVY3SqCEf 1m+RPBvlEcwQz2349Rjkp2HE72QGJXaO4W72A8EBji25h6Zvx++jxFQe9OEBHZg51jR2 g3Ccb9eE5aRJRY/AHisDVELXPwi4VcYHoi+KfDyA3JJmoV4zeqN7AuvgQL5LMZoQtF9j UNUV+b9ulO+1nX9bgXOOGiZAEfvb7vyerxlHZ26eQLXr+smEQ85rnCEBSENliBVpC8ck yWz54h/r0lY9YPYpjIJstQV5XDrjKILeeY+oz/3AcuKYjnEFK58c2WbhiHbJRzbkn7hc fFNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782139515; x=1782744315; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gV4xDRUurhfQjcVnQzsMOKQF1/Zp8ED3KFqFWdXznZ0=; b=k3KC2dg1V9W6VEbZ3JaAwopqSeZ53wdxQ8Egi0+OdAzTHyDMcM4WyfDMTIExtPdYvW A0q7NcSSXBhfnsJ5D4D4aDlCqxXWclbq+s+hR7g9cJnxLZzhn7wZvHUmuNvKQglrWGXE ycU2NcI1/uRThabGxo1FUeYAtDZ2CMZ1S7dNkb9w7henjbLZNxbMN8HBo9Yzv2YSu1Vl oJDFZiRWYQoOHQA+1W+2Y2Gb/3IlTtk/G/3YJ27xDiWRU+6+OpGJuKmZ/Z04nitDyA9G Tq7qbtyyP6LjoBAereAGbZRAryNeBmbR0a4VOtQqmpTnlCQAnznYavP9fLbe10+3ddDW mJ5w== X-Forwarded-Encrypted: i=1; AFNElJ8r7cajZL3Q/ZK7EsGFRx9WYR0dY6iKpk/Xlmz/lkC16P4idE6o8AdGTEnfPCmmLgwnoqOD0zx4KiHK3c8=@vger.kernel.org X-Gm-Message-State: AOJu0YyOdig+fnZ/b6yLgO1M/Q6Jds+INQPPhNDzKRv7rzQNOJMP/ye5 dad0ySNovjSej7bVYnDO79Aiu9ZIS1EQMJSaCVXC6LZuLTckkLOIX861mycLRWCAmCuiO0xC1HA NiJfWPlmqv9pNgcV4MseGDgh5GMzJgZ6g1laojK/loiTmS8ni0JnfjkJwKPd9CzaYNgM= X-Gm-Gg: AfdE7ck2RhW0pwOfAehOLq6iMyK/e6NteGBlQkbJW0VW6QMGMNTV9OlmBnpDEr02mNq GqTnrwpqagCx8JmeDqGqqduFgcYRYapOvj+fUADNTV77WmGFEE4Oa9xUa1AOv/+kQv0EKRiWnXX xRQ2zFD7Tu7rWcikQlB9LAckq4Yn8b+LiYaWZuYKHL6Ktgl+MnljLE2WBYrXcpdD6MR/7fsgXfk UTgkDVUG70W8JG6Yu0k9B4Sh5MGz8uZbsJwrGpuCFvnL2JZc+L7tORO1A9rid25C/m6imcUsYeK VfkNnDwZzHuDB83xntGgANZHx841sYZqqNUcNpyL7Hdd2O+wBMtyK3awdpJckJoymKRhVqBfb1c zQrxRBvWpkDEvUc2ZFS5pUUU3AaIbcgSzrbP0UA== X-Received: by 2002:a05:6a00:4fc4:b0:81e:ef16:b288 with SMTP id d2e1a72fcca58-84550872119mr16323725b3a.22.1782139515131; Mon, 22 Jun 2026 07:45:15 -0700 (PDT) X-Received: by 2002:a05:6a00:4fc4:b0:81e:ef16:b288 with SMTP id d2e1a72fcca58-84550872119mr16323684b3a.22.1782139514575; Mon, 22 Jun 2026 07:45:14 -0700 (PDT) Received: from [10.219.56.41] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84564ecd784sm8132407b3a.54.2026.06.22.07.45.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jun 2026 07:45:14 -0700 (PDT) Message-ID: <75e435db-a24a-4852-8ca2-23f46e161fcd@oss.qualcomm.com> Date: Mon, 22 Jun 2026 20:15:10 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] swiotlb: introduce Kconfig option for compile-time default pool size To: Michael Kelley , Marek Szyprowski , Robin Murphy Cc: "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Jagadeesh Pagadala References: <20260617-swiotlb-v1-1-abfee3faf4ea@oss.qualcomm.com> Content-Language: en-US From: Bibek Kumar Patro In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYwNjIyMDE0NiBTYWx0ZWRfX/leQ+VcElVmZ cc+gfQh6KZqO25Vfuj5bCN5lB69yDh7KH2nRaL1TirOcqQ2nO6LzezJpxEyPgmUZh+ly0T1BdW5 F5ipyS3KeIGvvZTPR+ihgxuKM5FRv6U= X-Proofpoint-ORIG-GUID: esXrmniqn-kjsUr_w-m8FZCNA1gfBQ1A X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjIyMDE0NiBTYWx0ZWRfX66B01fZIb5fc gzdBl0NjsEZKnN8V2/xFLjGkGkSF5G0imwjvNIhy4nULkx2Ir6Flks0+k1gyJTFH42H56LT2uO4 lpa56B1yEI+KJ0zHrltWVI79YGc8feKBEJZKFGHDBDMoegLmM6j+GBCTI/eHLL3egnW/qpiPSYx d0Ttw02KAJvAYKGK6jUoFzIHKIR2jdvvddY2wszve317ggJyo9DLVsoA9o7SZFY9OkwwyeqeYxX 828G4LQb9N+teNkp1LBI9jm8ztrDzDu6aIWLktJZL2WMhU0xpGsGiHy438NXs08irlmggrjF8er 7F+tiKkNcwL5270NAoHB3gGVYWFINaZNXY/hNX3WaysoWf9ujLLqy0cu9ZBouC20nzOAzuZmAd7 5DD6i1FE2aEVXcE1rZoQICNm4iZZmCe0L7y1tPJFOT+r2aIn90uI408BrBl5/BAg2yk22adLN1s MkAGVMWgNoVuA2rAq5Q== X-Proofpoint-GUID: esXrmniqn-kjsUr_w-m8FZCNA1gfBQ1A X-Authority-Analysis: v=2.4 cv=cKbQdFeN c=1 sm=1 tr=0 ts=6a394a7c cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=9ljbhfWoGXrtH4PsthoA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-22_02,2026-06-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606220146 On 6/18/2026 9:34 PM, Michael Kelley wrote: > From: bibek.patro@oss.qualcomm.com Sent: Tuesday, June 16, 2026 2:36 PM >> >> From: Jagadeesh Pagadala >> >> The SWIOTLB bounce buffer pool size is hardcoded at 64 MB via >> IO_TLB_DEFAULT_SIZE with no compile-time knob to adjust it. On >> memory-constrained embedded or mobile platforms equipped with a >> hardware IOMMU (e.g., ARM SMMU) covering most DMA-capable devices, >> reserving 64 MB at boot is unnecessarily wasteful — the SWIOTLB is >> only exercised for devices that bypass the IOMMU or have restricted >> DMA address ranges. >> >> Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB, an integer Kconfig option >> (range 1–64 MB, default 64) that allows platforms to set a smaller >> compile-time default. IO_TLB_DEFAULT_SIZE is updated to derive from >> this value when CONFIG_SWIOTLB is enabled, preserving the existing >> 64 MB default when the option is not configured. >> >> The runtime "swiotlb=" kernel parameter override remains >> fully supported and takes precedence over the compile-time default. >> >> Signed-off-by: Jagadeesh Pagadala >> Signed-off-by: Bibek Kumar Patro >> --- >> The SWIOTLB bounce buffer pool size is hardcoded at 64 MB. On >> memory-constrained platforms with a hardware IOMMU (e.g., ARM SMMU), >> this reservation is wasteful as SWIOTLB is only needed for devices >> that bypass the IOMMU or have restricted DMA address ranges. >> >> Introduce CONFIG_SWIOTLB_DEFAULT_SIZE_MB (range 1–64 MB, default 64) >> to allow a smaller compile-time default. The runtime "swiotlb=" >> parameter override remains supported and takes precedence. >> >> Before (default 64 MB): >> [ 0.000000] software IO TLB: area num 8. >> [ 0.000000] software IO TLB: mapped [mem 0x00000000fbfff000-0x00000000fffff000] (64MB) >> >> After (CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2): >> [ 0.000000] software IO TLB: area num 8. >> [ 0.000000] software IO TLB: SWIOTLB bounce buffer size roundup to 2MB >> [ 0.000000] software IO TLB: mapped [mem 0x00000000ffdff000-0x00000000fffff000] (2MB) > > This message sequence is surprising to me -- there should not be any > roundup if the default size is 2 MiB and there are 8 CPUs. I ran the patch > with 8 CPUs and set CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2, and > no roundup was reported. I'm curious as to what configuration produced > the "roundup" message. > I see inside swiotlb.c, we have a print for rounding off based on the number of slabs, inside the check for "round_up_default_nslabs()" pr_info("SWIOTLB bounce buffer size roundup to %luMB", Probability of getting the print based on the number of slabs. > Also, there's some text in Documentation/core-api/swiotlb.rst that > describes the default size of the swiotlb, and how it can be overridden > with the swiotlb= kernel boot option. This patch should include an update > to that text to mention the new CONFIG option. > Ack, thanks for this suggestion. I will incorporate in next revision. It would be a good information for someone trying a similar approach for setting the default option to custom value. Thanks & regards, Bibek > Michael > >> --- >> include/linux/swiotlb.h | 8 ++++++-- >> kernel/dma/Kconfig | 22 ++++++++++++++++++++++ >> 2 files changed, 28 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h >> index 3dae0f592063..1665a9ce8f94 100644 >> --- a/include/linux/swiotlb.h >> +++ b/include/linux/swiotlb.h >> @@ -32,8 +32,12 @@ struct scatterlist; >> #define IO_TLB_SHIFT 11 >> #define IO_TLB_SIZE (1 << IO_TLB_SHIFT) >> >> -/* default to 64MB */ >> -#define IO_TLB_DEFAULT_SIZE (64UL<<20) >> +/* compile-time default; overridable via CONFIG_SWIOTLB_DEFAULT_SIZE_MB */ >> +#ifdef CONFIG_SWIOTLB >> +#define IO_TLB_DEFAULT_SIZE ((unsigned long)CONFIG_SWIOTLB_DEFAULT_SIZE_MB << 20) >> +#else >> +#define IO_TLB_DEFAULT_SIZE (64UL << 20) >> +#endif >> >> unsigned long swiotlb_size_or_default(void); >> void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags, >> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig >> index 0a4ba21a57a7..3830a63ae032 100644 >> --- a/kernel/dma/Kconfig >> +++ b/kernel/dma/Kconfig >> @@ -86,6 +86,28 @@ config SWIOTLB >> bool >> select NEED_DMA_MAP_STATE >> >> +config SWIOTLB_DEFAULT_SIZE_MB >> + int "Default SWIOTLB bounce buffer size in MB" >> + depends on SWIOTLB >> + range 1 64 >> + default 64 >> + help >> + Sets the default size of the software IO TLB (SWIOTLB) bounce buffer >> + pool allocated at boot time. The default is 64 MB. >> + >> + On memory-constrained embedded or mobile platforms (e.g., those with >> + a hardware IOMMU such as ARM SMMU covering most DMA-capable devices), >> + a smaller value such as 4 or 8 MB may be sufficient. The SWIOTLB is >> + then only needed for devices that bypass the IOMMU or have restricted >> + DMA address ranges. >> + >> + The minimum allowed value is 1 MB. This compile-time default can be >> + overridden at runtime using the "swiotlb=" kernel command line >> + parameter. Refer to Documentation/admin-guide/kernel-parameters.txt >> + for details. >> + >> + If unsure, leave at the default value of 64. >> + >> config SWIOTLB_DYNAMIC >> bool "Dynamic allocation of DMA bounce buffers" >> default n >> >> --- >> base-commit: 4fa3f5fabb30bf00d7475d5a33459ea83d639bf9 >> change-id: 20260617-swiotlb-c215ce0b23f7 >> >> Best regards, >> -- >> Bibek Kumar Patro >> >