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 81C064A2E1D for ; Thu, 2 Jul 2026 13:44:43 +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=1782999884; cv=none; b=hcIffRLmg+FzyJRkqluDRFiD0j7/9k0uEvjZb8kTIScMqTTxM1ZvZ/TIrXksEiQV5vFuhxsGbNykjr0yJZ/9cuYXVJQwOHVjbPaNcW4hhvW/R4F0jiP5X33b9ARJUigWXenJPfSC37wNOjkV1NPppKmHlAVtB7V1kvSPMDa2mU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782999884; c=relaxed/simple; bh=lR98lxEbhbbF1xIiWb1kkAkNRqCFwF+omC/zVnpBF7U=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=G3UHWeL+UPXH4TJlI2XnQHEEJuIKetZ+4XKR/03kjsZHjlHH3Zhx6q+o/GZWh81Ud7LCTkvkcw+IY0neVZyMSrcOExofzkHUWFoKYs+uVuny5cin/dpZF601hJrsUI6sc47GgRlG+osfjb7STZ6xQOLGAPdCJ7/teqDEkIynuQw= 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=Ok/jHZaU; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gUsf4GXt; 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="Ok/jHZaU"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gUsf4GXt" 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 662DcXCQ564716 for ; Thu, 2 Jul 2026 13:44:42 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= dhQYWsgUDbnG/kOSy7DZkDM/sDPwiVS2gdi7188nGOY=; b=Ok/jHZaUrjTfbp6e cS/e8ZFWzwjRdrQcr+xSuwNtcZyg4eIK2iPqxogE2SiPV/PQQE9oLDgZaIb8GkAp Fv0I9WYal79fZ0qdTf6KVmw+p66nRnx1KzqaoTQhLi6unUFIKsZHoCSYH6jcJ1AV SkTjHccHoyUPXA+JgLOPqj7oI+A3X5cF47FL70ncA6cm9burdB6oiq7ATS708uLk XoekjmRh2CIN408ipWWpJceHwMo6qOCjFUZyeixeg5Iw/1rOvcjbpP20tiBNH6u5 F5ZPHefhBu+zlEF7LLZR3p08SSqjygw2uF6xcEkkZlX9B6Qm9ZBR22aaYJEnzuEn 9zqUyg== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4f5s2500yc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 02 Jul 2026 13:44:42 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2c9f0073e20so27940975ad.1 for ; Thu, 02 Jul 2026 06:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782999881; x=1783604681; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=dhQYWsgUDbnG/kOSy7DZkDM/sDPwiVS2gdi7188nGOY=; b=gUsf4GXti+ifDFejD50I/0pZt5zgjdu8JwfmGjLwtOmyQT83GCi1xvP3tPXGIlmeyg JZ7mX9G4jrJjqr1hJMWRn7PNYoFi8pnefoo4gRucNSoFvi1tKx2ZaJ4M7k1BwLRTrvMO knChWyBBPSE+BJ20EVYvm71gx1lcjW0bvN1jw5nUYrC1XvL71EVaY0zMs/jEb5b06V3S BuLxGF0Q2SBlyBv28PiuV3aQXIPe5jgEQjmqVF+TRZ/Yho6jptLPD4Gf/eyxOgq1eW8/ GdaUt+NiKqLGqGjEMOzl+VetS9UgGA34pDUB0INbB4JoEpQhJSk1iYcNQBWaOWxsPNvf CQ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782999881; x=1783604681; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from: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=dhQYWsgUDbnG/kOSy7DZkDM/sDPwiVS2gdi7188nGOY=; b=O2qAICcM23P5rAWeB8EanwOainC9nCV/YmlKbd8QmlE24pvHQG4ZMQX0xaFkuatsTI j2XHj9/QXCbPRpGic5sC8MuLYsP/q1cZCzB8yGY/3jU0ssfFpnDk81sXkpBFL1Uscyjx yqJ+INGoDHNpzKKPCOxl65CcIw7eXhEsxNVNwUPL09qL7Q/wxaluJrP/QNdiAs5ZOBr8 HvwOTncjqiFvk77mNPiXuEaThDSlzTcGDW0J0GQwt2ghydRWj2Kv3Bs8HH7nK8VhBPGs 1F6PsP3+H68RQKzNMbSi3LViPoGUwIkWVoOLDSqgbqxOsk3qIv5eHbTt5s1ULenmwpqD lsxw== X-Forwarded-Encrypted: i=1; AHgh+RrrLIR6qpU5+nOmF2lCtwXH51SoHnTJK0prRTCuj5jvmlgkBM11t8MDhtrc932eM3M1K7Zn3QnGtCtA/Co=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6vdKfWkbRvAj8RX1DuynwWhDWY4G6FoWmQMuavKDk4ne1tVKo S4bMPQdYcVX1FGad5tro+iysu7t2bTIY0fvgZi2lK8sJGDPZe5D8PmmC6uUoOdVXH/YNjdKv5VP lc6dy2QgQXv78bIJO/pp7CZHg23QjIf7jdDkXzp9voHWCdWpFGzmLvojoSY8HZ/x7L90= X-Gm-Gg: AfdE7cmbZXLpbkwIYggHvR7zQ/ec+rol5AgtFp9VSBeDT9CoCvgnq41mzAB36loyAOr i5x4RVGF/arL6sHNnVzZeDUxh6EbPaeE4UZbyOW1rKzejXF7zwSX+MPD1BA+y16nDwyJNwU4kHj 1uODcItfKuyLx1z0YiQ8Wo4yLLNR4973rDOpgLENfCIOonl3+aoStXFpNdio0rYv4ICGoH82FGK Kai8pvynzf5TAohz3Vm2XbJpzbtsp6C8X59pUZZRYUJ47iP1OT6dQlBLLJz/3awFshKqQE6hCJs LaPpvzRqAa5RvJx7TrQtrPLhaxfDtEK5BItfQ2nONIY2Ng9KaXgZOpoQTwQH8EXaI+Ej32NnaKt 43wFsSVwDlw41TanA5iCL6u8qDpxt3EZjctcXHqQ= X-Received: by 2002:a17:902:dac3:b0:2c9:fb11:1bf4 with SMTP id d9443c01a7336-2ca7e6545e6mr63214135ad.7.1782999881374; Thu, 02 Jul 2026 06:44:41 -0700 (PDT) X-Received: by 2002:a17:902:dac3:b0:2c9:fb11:1bf4 with SMTP id d9443c01a7336-2ca7e6545e6mr63213895ad.7.1782999880797; Thu, 02 Jul 2026 06:44:40 -0700 (PDT) Received: from [10.219.56.198] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ca9a90b01csm14150485ad.26.2026.07.02.06.44.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jul 2026 06:44:40 -0700 (PDT) Message-ID: <70dd2528-e0b3-4bbf-af8c-7dcdd3bd4008@oss.qualcomm.com> Date: Thu, 2 Jul 2026 19:14:37 +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 From: Bibek Kumar Patro 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> <75e435db-a24a-4852-8ca2-23f46e161fcd@oss.qualcomm.com> Content-Language: en-US In-Reply-To: <75e435db-a24a-4852-8ca2-23f46e161fcd@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=U7uiy+ru c=1 sm=1 tr=0 ts=6a466b4a cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=4LGNN7F37lkCH3xNYkkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: q7OglxjHu63L_uCAc0djmK-FSrBiT7jb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzAyMDE0MyBTYWx0ZWRfX1nQA5dKl7H+z mpgNCn1P93WcAxMJW6vHvyAEB21qDJjpD6PqIkvNunsSupuRNKjByYFwLkopXbGPizebapSxQ7Z q0MbgakZiDtg1vnzt5DXTnF5LzKq2GQ6xE7FmiXMhPAgtGM0XmbbcccTZku1RTUHGB/5g4nMNR1 wW9Zjeg/LkHnw8Be4lqX+nLMR/7Zenfym0MLnThkhYB/JtV1DLe6a2QNKPguAhO2riPTlxxhlG1 6WMOKFXraHrrCEKT+xnmRSom30rGmC6Ux6vS2GZPp8yt//4BFU7Cnsu8an8xgi+XvCl64odGidQ bW4/udeEKyHpRLU+G02iYbaopoMesYCm0hn5qK0CZL/kiWjvRpWakVKI64gX2KaTwKRPDhg0hng aCjocwwHqhLtDw1hue9QuaJb+2g473aMeAZ8GYzu4F898EPhgy3z7uLWAJZbrXc8YclGZPHfOzA VExcyy6oyJ//EuuvAnQ== X-Proofpoint-GUID: q7OglxjHu63L_uCAc0djmK-FSrBiT7jb X-Proofpoint-Spam-Info: AW1haW4tMjYwNzAyMDE0MyBTYWx0ZWRfXzmAm/fr6uBqH vekAATnGGj+16yD9PvljxQ6nFEW6+Yv5k2K97h4KMpPXbDfywyJlVxtteI7O5NY/6vhGbXlIDyd gzhosiqmEYUve+UtDdByVhQrVFWbTlA= 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-07-02_01,2026-06-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607020143 On 6/22/2026 8:15 PM, Bibek Kumar Patro wrote: > > > 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 might have misunderstood your query Michael, you're correct. I rechecked my system configuration with 8 CPUs and CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2, and I did not get the "roundup" message. I did a few experiments while developing the patch initially with CONFIG_SWIOTLB_DEFAULT_SIZE_MB across a range of values. CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1 gives the roundup message: [ 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) With CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1: nslabs = CONFIG_SWIOTLB_DEFAULT_SIZE_MB << 9 = 1 << 9 = 512 With 8 CPUs, default_nareas = 8, so the minimum required nslabs is: IO_TLB_SEGSIZE * default_nareas = 128 * 8 = 1024 Since 512 < 1024, nslabs is rounded up to 1024 (2MB), which explains the roundup message. I have incorrectly labelled this log in cover letter by posting the logs for CONFIG_SWIOTLB_DEFAULT_SIZE_MB=1 instead of CONFIG_SWIOTLB_DEFAULT_SIZE_MB=2 I will correct this info in the cover letter while sending the next revision along with the documentation update as you suggested. Thanks & regards, Bibek > > 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 >>> >> >