From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 CE6193A641F for ; Wed, 17 Jun 2026 16:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781712829; cv=none; b=UHxPt0TTTHpddXVLhbPzY9/sKigNmDyrNmaQ+kd47qspml2wmW+W53ymEE1ljYT4P/DV2yey6VUZXUAn4sZSeDeCmOre+z0vYAPdOeh9TX0NqfFsSPHS+dF4Ygb3/Qyk5sykYQ+oQukOZmv0eyWYLtwaVNUFUZK7p+LX88BzK5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781712829; c=relaxed/simple; bh=VndfbIpPwbVRR9kgReMPg2FppcVxf5dvVDw8DC4+jFM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GEpXCe8gvi/2R48xKRpgGLmGjlmkKQaUjybkqjiAA3nDMXYbXOohHeo+QVzDEDjzBWKJjFc2vR7KC/jdtK31Wua7OkG8r7i3hsds+udslvc9w2qA6J4I8dM9uquTeC4vKFGzcv39CKguGXZRgWjEqxQPVBgRd4YOF5eb9K9qbUY= 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=M3KjLKXQ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=BwGSSb19; arc=none smtp.client-ip=205.220.180.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="M3KjLKXQ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="BwGSSb19" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65HFomJc3212369 for ; Wed, 17 Jun 2026 16:13:39 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= 1Fymbf6PKyafYj/na3W/ZlVJ43rZNNl0dvGx9jrs41Q=; b=M3KjLKXQfAKWyeLS e+WIlVluUjt3z+srXdLF3bCAQaPN7673hxzzWXRy45BYM84y2DxW+RXkfEHikfXO xBSt4PvGTu93+Vp7IwY24ZJHWyhUHAyHk7N+mnZfcrUeClnSdY1Evjh4lo2rn+ob T4UiJN16oCY3IQceshFICJJ6Y+06+gVKbfUIc04eg1ZSbC+KXac3Uj8mter308u6 ooN6VDRq/t3xV74wyq8H267G2lEI6Cm/z0EHCrsGSCCTJFrC9SM3d6ai4WwDPdhM xcZzaBDjBPSUcj+IoDqf5X6yeMboTegr6cqL3BXp4rkVHmeywuegOlTf3uke8B2y d5WKBQ== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eueerc6py-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 17 Jun 2026 16:13:39 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-8428419982eso5356572b3a.3 for ; Wed, 17 Jun 2026 09:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781712818; x=1782317618; 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=1Fymbf6PKyafYj/na3W/ZlVJ43rZNNl0dvGx9jrs41Q=; b=BwGSSb19VMTzHXyoQnPah33+CJO/WXswwqg7WL3JYuzof24NT7IzEx9ENovKdX/eDF u4yCZ76XKShlSqLkNuwDZ7uB8OXtu7YcGePXW8WFQtfaWAIpODwNHo4ctV6xvGKT3ce1 M9a0bzSaiwsxqjp3HGqvBflonUAyQHgQZ3YEYidOcq4bqoL7yHYs3HhmAe7xFKeq0+fG vCtkBUmX671VCmPm9Yo2Gv0hG0GV6w11JLO0AkDzQfP4Z/fdgZmyR+uERYJrOMC1K3wz /Pz7ey62sEp+ybOGr2XavxsPItOyXVwPZzctLp+pslYEhFTv7Pgz/Xi9hjC1j7GRu1EY +lFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781712818; x=1782317618; 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=1Fymbf6PKyafYj/na3W/ZlVJ43rZNNl0dvGx9jrs41Q=; b=CzlTQySnz3fQfbGferPHDxEAk3DbMPby+GnKu1tdTEeUHwLVEmFSwymPP7Jl1snkpm N/82a5Gg+YcrCrg/zf2NIBowIqGw9Tqexr9TMHySEn+Zl8e+t8F/Hsp0HoFpjY5tb760 /Kz5S6snjdUK2tfts5mcNXmwuwrQr2a27SGMsDIGtJY6sGahiV02KJIB3/O9zx/is1iJ 9EP+pOXCntsZLHlShDCOF2P/+UDMj8pZ01qLwACWCzQUkZxoDdMlBHrhbsZK6HxLq5ey htCgLOdCnlfOqHYIp13ML484XhYn/l2h4KS7CRhIbnjzLT1Y5u+pRbKu6qbT1UFUYGBi kLyQ== X-Forwarded-Encrypted: i=1; AFNElJ8fF6nSqEqHBfIowSJKjD8KlZX92yTLvLGpe/UgBOrraPpu0XynDqmJqXZu2ORDUBZpURnj27cK9iziYVk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxp4bDyBcLmrOFC1Ujo/MbS1v9sw2Evd6Q5InRJ3CWEaTsa0TDN +XIWk9WkJQdU3mamIOZSFyH3cBB41L+ZwQ1+BfJzkQQpAQXsiD/0YoTg4jUs6byUjXcFEF9jwYL ge9GyrzXLf7Y/PSoqGtexqYsX1LiO2wfLj4xemxomrD4Y3fftbToL9KQnCTRIBO4oM5qJYUtH/c 0= X-Gm-Gg: Acq92OHu0aXM9lJt5vSlwkBd82Y89AOx1XWKRfj2s/+t4UJvhfksMYxmvBnqIal+2YT SG4/uB5dAxpBPv3/6ls3aw9wJb2OVgq+abDO95lXOfhehzch1QPBShti6A9GTd2VmXbg1Q+rez8 SBb57/t4bvXfcPdDfTyxHyj9mXFy+nEranR2epWrP3nGqqkWFi+qIvfslZFAoyLRQRf5PkiqgpW KQoM4WjfDrlDM//dEilEOlzEFMEPhURR1qUA3ZkY8o8GUvF7injj0FZE0ufKhpNa8LwP6Tuzfgv 3KeUGw5X/I79pRBmcxR4MpUyLxF69Dh5eM9lS6jJ4PX61HIXW/nyqk/JYv+Drgp1QMVAVVP2pqG mWHxNRRviT5CkfrlJyxyXDf+u/2jEuFrZ1H2Er1Y= X-Received: by 2002:a05:6a00:2a0e:b0:842:5a8d:3036 with SMTP id d2e1a72fcca58-845245808femr5259209b3a.35.1781712818184; Wed, 17 Jun 2026 09:13:38 -0700 (PDT) X-Received: by 2002:a05:6a00:2a0e:b0:842:5a8d:3036 with SMTP id d2e1a72fcca58-845245808femr5259167b3a.35.1781712817730; Wed, 17 Jun 2026 09:13:37 -0700 (PDT) Received: from [10.219.57.228] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8434ad0118asm15320349b3a.27.2026.06.17.09.13.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jun 2026 09:13:37 -0700 (PDT) Message-ID: <6cbf7d5b-cf7c-4b31-b60e-06e508c633ca@oss.qualcomm.com> Date: Wed, 17 Jun 2026 21:43:21 +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: Mostafa Saleh Cc: Marek Szyprowski , Robin Murphy , 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: AW1haW4tMjYwNjE3MDE1NiBTYWx0ZWRfX6WQY+DVR6fh6 EAhdrUC+0/qpeRqHtL7d2eDvLDINzVJ0lP8jW3JyQHLzp3lWfUKJz1dwonSDsTVKM1UP+8vJwty TUK0dGvqeHlYg2P4Y3+JBGjhaiaJ5Bg= X-Proofpoint-GUID: t4SeZu_xCPVTTfQjLTLiD70RDNbSGvn3 X-Authority-Analysis: v=2.4 cv=d4fFDxjE c=1 sm=1 tr=0 ts=6a32c7b3 cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=9ljbhfWoGXrtH4PsthoA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE3MDE1NiBTYWx0ZWRfX+279B9X8x4Ni w9GrlOVdszBxS57NRGxGiFM/Yo4AXQoFpSqdiMXT8XL/LsZQ+TZZxnD8ws4HKLFT57Y2QCVR5RM cW45lZjHG5V7z2nzcq1RTJLT/EMrgLCDOIK1p/etlzyGX87nxzH+mRdIv+x+/qwe4CZKJflTJLh sbplpGt0tKR8sSnXT3q2PEKMXUXof2vUyrMHyG5MqcEvkoz40oXnYdU9IaiqguSjdmywXTfeEc0 H+oYcMXgzoZPOdYsJN30wcA8EVm4Mv7h0s3rVsZE5UNDhS80mVdqFFswz/qhLLMdxftDKWFCvur rbdG2yEx5cEhqNPlFojFv7HYBmuF34APFzl9gdyObnky67F9jvDxSM+1VGgLknV3Abiw2SiujID gsQn2Grl6zWEQjlxpm/8J+rY/X5FV5C7ZKK0MleSAMfW8dAMJ7KrzbbklyOBmPFAARN5RxKQZC8 EcOMj4Nl9i6GWf/Ingg== X-Proofpoint-ORIG-GUID: t4SeZu_xCPVTTfQjLTLiD70RDNbSGvn3 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-17_02,2026-06-17_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 clxscore=1015 adultscore=0 spamscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606170156 On 6/17/2026 2:17 PM, Mostafa Saleh wrote: > On Tue, Jun 16, 2026 at 10:36 PM wrote: >> >> 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. >> > > Just curious, why is not "swiotlb=" enough in your case? > We are looking for an approach where we can set a default value of IO_TLB_DEFAULT_SIZE to maintain and sustain it for a specific platform or a kernel configuration. So introducing a Kconfig tunable seemed to be a maintainable approach compared to "swiotlb=" runtime variable. (since defconfig is the right mechanism for platform specific compile-time defaults) Further in case of any bootloader constraints - to make default runtime parameter, it might require firmware changes on production devices as well. (since in embedded/mobile platforms the kernel command line is typically managed by the bootloader) Thanks & regards, Bibek > Thanks, > Mostafa > >> 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) >> --- >> 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 >> >>