From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D50682080E9 for ; Tue, 18 Mar 2025 10:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294788; cv=none; b=qBFs9kz0tZRye/xlKZDj4HUM619sXhQDjtiYiVYA8W9z8UlCHjQNxWRxb4OLR+8rZIGqbGG3qQawlHiCifiVWQNQrfHOj7fnZMZu/lEeIHVSbvh+lcSOocFISW8wInOz/JMLfF1MbDnMocBWyIk8xbwdPenW0igNrwrgH0WxsLk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742294788; c=relaxed/simple; bh=BH/02l/7jfK62esHmL2nQqidEObr1IPIfhlBILiTzRU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oBYljF/Arm/OXb8Cp/PRdArqi3wZSQfZBkA1zoBziZLev4nPmlwfXMolvfQi0iTe67rVuTWNDYCZGodl9oOva7sppb8vovp85r3TO4OWNJbO/lZdE9qKGPve6ZUXg3hbtvKCq17frnPUTqLOxJ2qK53j1QW53kl0FwL+muzWyJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MXe/Cxhg; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MXe/Cxhg" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-43cf3192d8bso32975e9.1 for ; Tue, 18 Mar 2025 03:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742294784; x=1742899584; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=MXe/CxhgR4YPfXnkNhk2z1cK8G0CgjsERaz3ggQJR5D2FaqIqvXWsvhlq7E/6DNwvA 2+ZxFFk8DQ5cHnp+wakfRu6aYQ872X0ek9Z5uNkyTUwnlKuaTM+4nIugNOw0f4u0B81/ iq4JIFDWZM0sx6kE4pIcVmmXuyOUcPIiIgtfCAsw7AxD7SYST9J681V6497UfSJj4BIa 24Xz91uTgLT+AlyNTYqWYFQgap9ggxyie0F+8lesgl99E3OTpbSnszc4Xl+vv+2UyqY/ qpZxRd4qJJv1kTZ2XZ4P4Gs8GOorU5QrO8pWVbJsNcTYABRcrTWHSm0bP2uGcN/A7rom MC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742294784; x=1742899584; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=r7+bEHQO739zT/4Jk2FzAV10wVA901SCSaMyo0FiRbatlXPS7PyPlxETgs97lNitaY GXM617Dys0+O+Lnff0dPQa7tY/q4dx5KAXDXfYdXcSSAbMlz2rdJ6MJhEmQWXcFIOfDp uudi9yLNFsFtevAZO8C97vsnEeDQg0yOjeIoXJg5H4AR4knIEBp2l5Lkdoe/hlIHhayS JOKQqryG0DfTKrSgrSZ8L+zbXdT2zknZgeBPt2g7soF+8sei9G5+fuPTebkXY6P9lFYe ZwM1hdldEtpc++q8txu/mEvkiKacxICW+/eqOq8iaCiDmz/pzrqoJSg+mvBDyBlVf6IU JQow== X-Forwarded-Encrypted: i=1; AJvYcCUVNiAeKLbTJIBqCO+8iTF/xW0TGwkh+VixmQupb6uQRCVGENn4F70AlN09vTlOqLgwMZ8laQ==@lists.linux.dev X-Gm-Message-State: AOJu0YzR1p4NgGLm8pz2AeV0SSI14NNWxPOSB4sX2Y5JzJBJV+B5i9LW y0N590VoY4B7aiXmHuqx9j3u59x4g9nbnsh8hoO17BrqQWlShvTEpaaVvxPwZg== X-Gm-Gg: ASbGnct2OrUGwQuoncwlwvqcjYaOxabnSykARj3vGmDEirNPNjdWipOtOKFh37/79Wq SzBmwGDBlG/hugDe0oOdrhM8uaM/MXoLDSHSACTFm2LEbdoL+5ZYHL8wIu5oQvphn1XEJ9hRCe5 ko2B4UaQ/xEDcGVGgRG3E5be1zsmYT9D+n9U2PfvfRkd26qjp76DcDWKyoFjqrT2SUPrQMuIWf2 r7ReZot25LA46yAey6ZcpddmJxYRBOZf9FrgfpeeTMUF5ILT51wdQnc0Y9Gu0Rd7u4u9RCPFavk 57qYRhYD0pzvoBc+Eb6Fq+gvoGd1a9B6fSufSRDpEOM9I8hrmT/6C7YydQz505avTJ8ZYTtbWlT gkSEB X-Google-Smtp-Source: AGHT+IHJJJKc86lCeSfkPHpB/CtXXs0Prp3Nz9+7FXSfTlHmKZ30/6jEnzkR0iwoq3j3jwsYbn5hfA== X-Received: by 2002:a05:600c:1d20:b0:439:4a76:c246 with SMTP id 5b1f17b1804b1-43d3e14f871mr474575e9.6.1742294783884; Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Received: from google.com (88.140.78.34.bc.googleusercontent.com. [34.78.140.88]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d1ffbcf00sm129988595e9.10.2025.03.18.03.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Date: Tue, 18 Mar 2025 10:46:18 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: Alim Akhtar , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Lu Baolu , David Woodhouse , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Marek Szyprowski , Hector Martin , Palmer Dabbelt , Paul Walmsley , Robin Murphy , Samuel Holland , Suravee Suthikulpanit , Sven Peter , Thierry Reding , Tomasz Jeznach , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Bagas Sanjaya , Joerg Roedel , Pasha Tatashin , patches@lists.linux.dev, David Rientjes , Matthew Wilcox Subject: Re: [PATCH v3 20/23] iommu: Update various drivers to pass in lg2sz instead of order to iommu pages Message-ID: References: <0-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20250317133500.GC9311@nvidia.com> Precedence: bulk X-Mailing-List: asahi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250317133500.GC9311@nvidia.com> On Mon, Mar 17, 2025 at 10:35:00AM -0300, Jason Gunthorpe wrote: > On Wed, Mar 12, 2025 at 12:59:00PM +0000, Mostafa Saleh wrote: > > > --- a/drivers/iommu/io-pgtable-arm.c > > > +++ b/drivers/iommu/io-pgtable-arm.c > > > @@ -263,14 +263,13 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, > > > void *cookie) > > > { > > > struct device *dev = cfg->iommu_dev; > > > - int order = get_order(size); > > > dma_addr_t dma; > > > void *pages; > > > > > > if (cfg->alloc) > > > pages = cfg->alloc(cookie, size, gfp); > > > else > > > - pages = iommu_alloc_pages_node(dev_to_node(dev), gfp, order); > > > + pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, size); > > > > Although, the current implementation of iommu_alloc_pages_node_sz() would round > > the size to order, but this is not correct according to the API definition > > "The returned allocation is round_up_pow_two(size) big, and is physically aligned > > to its size." > > Yes.. The current implementation is limited to full PAGE_SIZE only, > the documentation imagines a future where it is not. Drivers should > ideally not assume the PAGE_SIZE limit during this conversion. > > > I'd say we can align the size or use min with 64 bytes before calling the > > function would be enough (or change the API to state that allocations > > are rounded to order) > > OK, like this: > > if (cfg->alloc) { > pages = cfg->alloc(cookie, size, gfp); > } else { > /* > * For very small starting-level translation tables the HW > * requires a minimum alignment of at least 64 to cover all > * cases. > */ > pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, > max(size, 64)); > } Yes, that looks good. Thanks, Mostafa > > Thanks, > Jason From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0238C35FF8 for ; Tue, 18 Mar 2025 10:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vprtb36LYqSkcjhzc9bPfjxUvgTIzu5iW6L0KCzjqJY=; b=WJuiDadWxySoHi dEBlRe0Qq1/GnVrT0UR9mw+H4MiTrDYbd5XgBYzcGrAqvQQFFA6M3MHqNB1ZltJ42lPkR5l0vvJ0o NTzvQIvOOZTLYqe5HoxTu8dg/PFN1lvv1T4eiWSdMrH/4O6pwXD6JwgCdSN68jHtfjXSWQ66ca3pp RsO+ZvHfPys0KGwiFSDsC6u3PIoWVSqFUwbVskQKUBsjcUo8mPl4I3FB93VmqCNslGcyKRuaJGxqy Og7YjfFPLPpbVDGjsYm87YI/T/+Gt3g/hiLE6C2A8CiznvapFUDVz2Ye0y2Tuxom+h/YstMG2pE88 e/4PGvy4O4A7k1NQMXyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuUUW-00000005ayK-2PiE; Tue, 18 Mar 2025 10:48:12 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tuUSo-00000005afl-2Nvx for linux-rockchip@lists.infradead.org; Tue, 18 Mar 2025 10:46:28 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-438d9c391fcso44735e9.0 for ; Tue, 18 Mar 2025 03:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742294784; x=1742899584; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=h63DCl6CvrryGG5zjP56K0D+yOK//+KV6h8hTjVaIs3V9ZQxRrly30A1u4JEeOESzf vfYLNrc42VW+HEydq3YkBte5ZPNQsihQUtEG9kEEmUtBN6fwNN+5nKYDqLn964sY1fTA CSmCegkia5oOgIsV1nEJI8UEkXFpcxGhVYqkbKP+hOxD1aBA9wGSisk4e1TjHu44pTvr cFpTjK8vdMsqXOgwEpdWl58XqZG1Kh2JKD0UEPquYzd1mKu4ohct2n5yrPSIkg+4p658 50iWG66zxmWxwQ0bKSWx1XvP1w1fG5uzFddbf8mijWVyHrzZ9LGDL4p7olPZXP+Vk292 Lqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742294784; x=1742899584; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=AYKJWpHZy73HpDxbvyhREsNIGMPQGHxjRmPj52XXy9LOcr5WY6BnucO7WHCTkJmAx3 RWbZ52UlzuT6LhvUzuTFiKoS3RyzseUEkL0ccsbSVn5Vq9dU+Kc2i730rDHlx5gLma0+ xuKaIDkCXWyIcR9rU5LmMNL9v3oPT7ObUJY1OQ5VUao+htgpU3qpmCPoWJtc4psHo6QQ H8G6ISJ4p/dhfd8F+SLg+v+WU5hFdgUj3hXgN2hBFQeAIP5k6CJWwYgIjjZpuWDG2Etl FJu+raKJu72ZY5ZDbvaCZJPmQatZtJNrAzoUPexv+cRN/CoHunKRPirua8mPIG6VizdO xG8A== X-Forwarded-Encrypted: i=1; AJvYcCVSYACT2AYX5OOSNJ+bC+Ybg8woyLR1j4klSlTGoFFDEtfMYqEAEdmFWnbkf7GgoQwIZUiUEvnnSiwBpmtPmA==@lists.infradead.org X-Gm-Message-State: AOJu0YxjVWdXjwAjdJ4zl5UBZsEoJJlqZmeAQSOtH5PQU6fHvteowa9N 7sQcUOwbBjikrLe1kBtg8YGAGYgDlXPMCT1Hut2km8vmBJiJ6JKbdBn3svsEyg== X-Gm-Gg: ASbGncsur8DXPa6ntDeaCGn9rIL+AKljDfe/WXk8oV3ZHH2KzI13cj7VZpdQYyhvMyb 870Vocix3pJaSN0qq9t7O8Cca01L8wLZVJqRt1DSmMEmMr4Hvp97y34iI8Jfg73xHB8rqe1ZCpd aWY8BWmO7z1XZo6SNVD8iB6/SSsC0GRMG/d0vAVqtMxnY+RTRgI3iePcEADMqYUBF/M8nVsV3K8 wioahcpVLaWhvYkSNhas5OJnp+xAsEsBDnf+8XkP5wDXdGldAX19TmR2qsqMyFYTCcqP0NoEKo1 0Dpl1Xsl31qugmztEXYrzR2xBQo1Lt1LbQvbSUxBWZs7UIMO48wj26UTsVEQbOdcL62xoIJcN/B Wgcj1 X-Google-Smtp-Source: AGHT+IHJJJKc86lCeSfkPHpB/CtXXs0Prp3Nz9+7FXSfTlHmKZ30/6jEnzkR0iwoq3j3jwsYbn5hfA== X-Received: by 2002:a05:600c:1d20:b0:439:4a76:c246 with SMTP id 5b1f17b1804b1-43d3e14f871mr474575e9.6.1742294783884; Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Received: from google.com (88.140.78.34.bc.googleusercontent.com. [34.78.140.88]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d1ffbcf00sm129988595e9.10.2025.03.18.03.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Date: Tue, 18 Mar 2025 10:46:18 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: Alim Akhtar , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Lu Baolu , David Woodhouse , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Marek Szyprowski , Hector Martin , Palmer Dabbelt , Paul Walmsley , Robin Murphy , Samuel Holland , Suravee Suthikulpanit , Sven Peter , Thierry Reding , Tomasz Jeznach , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Bagas Sanjaya , Joerg Roedel , Pasha Tatashin , patches@lists.linux.dev, David Rientjes , Matthew Wilcox Subject: Re: [PATCH v3 20/23] iommu: Update various drivers to pass in lg2sz instead of order to iommu pages Message-ID: References: <0-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20250317133500.GC9311@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250317133500.GC9311@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250318_034626_616848_B19AFE8D X-CRM114-Status: GOOD ( 23.65 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org On Mon, Mar 17, 2025 at 10:35:00AM -0300, Jason Gunthorpe wrote: > On Wed, Mar 12, 2025 at 12:59:00PM +0000, Mostafa Saleh wrote: > > > --- a/drivers/iommu/io-pgtable-arm.c > > > +++ b/drivers/iommu/io-pgtable-arm.c > > > @@ -263,14 +263,13 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, > > > void *cookie) > > > { > > > struct device *dev = cfg->iommu_dev; > > > - int order = get_order(size); > > > dma_addr_t dma; > > > void *pages; > > > > > > if (cfg->alloc) > > > pages = cfg->alloc(cookie, size, gfp); > > > else > > > - pages = iommu_alloc_pages_node(dev_to_node(dev), gfp, order); > > > + pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, size); > > > > Although, the current implementation of iommu_alloc_pages_node_sz() would round > > the size to order, but this is not correct according to the API definition > > "The returned allocation is round_up_pow_two(size) big, and is physically aligned > > to its size." > > Yes.. The current implementation is limited to full PAGE_SIZE only, > the documentation imagines a future where it is not. Drivers should > ideally not assume the PAGE_SIZE limit during this conversion. > > > I'd say we can align the size or use min with 64 bytes before calling the > > function would be enough (or change the API to state that allocations > > are rounded to order) > > OK, like this: > > if (cfg->alloc) { > pages = cfg->alloc(cookie, size, gfp); > } else { > /* > * For very small starting-level translation tables the HW > * requires a minimum alignment of at least 64 to cover all > * cases. > */ > pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, > max(size, 64)); > } Yes, that looks good. Thanks, Mostafa > > Thanks, > Jason _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1DB3C35FF8 for ; Tue, 18 Mar 2025 10:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VN3v4HWxd/spx4/tLFvZBXfPmM+GHftKoklYeofKgAI=; b=WXHkYIv6m+BL10 PGB0QI7lVsh1/kVQc0KltwEfiwLgSe47RBNbj/oe/YwJc3Ivx2iQfKnak0KWb+ru/jxDflR78I0dG RPgmQRDq67cOTVh/EhvJPqk7qn3oVVE1Q1L2fOyH6NqydaPQm9xGct1rIGZ4wAsmNh9/LqXQbFnT3 7zafWtbZ0W+qqFvy8uEuaZg6To1U0VBvXIjuqihyJ4qQzAy7I6ADrEorjGEnkkuiw+desIkeLfKHh 8skPXYfkkiD/8fgGaD2/VDpWYSfeCeId2NWUPasDTCYObvlef0xAKKS6uTVczdqnkV5lBUvoVXWo2 y2+sIH+ROoWZo3HFBnTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuUUW-00000005ayO-3v2O; Tue, 18 Mar 2025 10:48:12 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tuUSo-00000005afk-2RoI for linux-riscv@lists.infradead.org; Tue, 18 Mar 2025 10:46:28 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-438d9c391fcso44655e9.0 for ; Tue, 18 Mar 2025 03:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1742294784; x=1742899584; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=h63DCl6CvrryGG5zjP56K0D+yOK//+KV6h8hTjVaIs3V9ZQxRrly30A1u4JEeOESzf vfYLNrc42VW+HEydq3YkBte5ZPNQsihQUtEG9kEEmUtBN6fwNN+5nKYDqLn964sY1fTA CSmCegkia5oOgIsV1nEJI8UEkXFpcxGhVYqkbKP+hOxD1aBA9wGSisk4e1TjHu44pTvr cFpTjK8vdMsqXOgwEpdWl58XqZG1Kh2JKD0UEPquYzd1mKu4ohct2n5yrPSIkg+4p658 50iWG66zxmWxwQ0bKSWx1XvP1w1fG5uzFddbf8mijWVyHrzZ9LGDL4p7olPZXP+Vk292 Lqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742294784; x=1742899584; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/+Q9jlO5xuM+dGNN5vOy/zKLThOd0aux5Q2kg9METOQ=; b=UHJ9KED6W9AZ2t1Z0EZCVpLO6eFAXaTC7lym2EQm63Snv+0JXnrQsSWCsZrIWDlMFj pxXg1jXv6vYqVnRgqE6KTuUxxD4eTZeGwAbGlfT/bsGYoo2aBNOJtqwLcLadtGBcBAdl 4RXnJHVFxq4PJEVzJnJeZ+zPSiWKVvLDJ+FJ3U2taUDJVK0IinZ6OT+hHG1NDq4ihGEs rwg51TEFw16vombGpc3+pbVfNSo3p8ISap+aQQ62sqGefvoMWd3rYEAyY0URJ+pn149i mxJQuZFl0FOGXLP7yt9SF/wFfiprjEmIDwExqZZw4smV9R6mVFadHQNhuen9QwegIwD0 eGEQ== X-Forwarded-Encrypted: i=1; AJvYcCWt229bYBg5qs0OvQy4gUI5XDKTO2xoCm9I/cirw3WtdxvHryTqVs3JtVZwM30xDtQuEfS/tUDjv6uAMg==@lists.infradead.org X-Gm-Message-State: AOJu0YzoCWDS8+Wm8i/H52Z2DLlW2DPzQjJ8vRux37l0hSrIvRkrHeQ5 RHAPGBdYRWf7bKG1+pPKmDlOSPSC6YFJrvuQbvacuVm2EC2DSz6GkGgVtb9taTJD9wd5GS6m+69 cfLpp X-Gm-Gg: ASbGncvh/6Q0KOT6EOzyVUhJch5Q/CjnBbzCctviSLbuPrwmFva74+RQ350ZG2LnEvV voaFw0O5vUsUJ8pQH09X1itqC0xEJ3d7egdSVvT+wPkqaXfgmPUhKuI8esiu4jlkxQ+uOR0RFUu 3wOdpgoAYtBF4ls/4hcLDjX7jTGdzuM29ICfWi54UzpVHKn+OzYGNQ73XQW9172q7hfHi/nNB4P aVhAl4qKgjWZBpEYLNmo9nWMFlgL0p0Js/lbab+0PbmgOsi6ldejJBFf8iC0wWUvwILyx6rABY+ QQrgQdC0vY4FkWP4HvPR6P3MgL7VlaDRSKWRtVjvs5GBkWX9QWrBmDdjwXBzm4b/HJYx3h5FrMJ I1GcA X-Google-Smtp-Source: AGHT+IHJJJKc86lCeSfkPHpB/CtXXs0Prp3Nz9+7FXSfTlHmKZ30/6jEnzkR0iwoq3j3jwsYbn5hfA== X-Received: by 2002:a05:600c:1d20:b0:439:4a76:c246 with SMTP id 5b1f17b1804b1-43d3e14f871mr474575e9.6.1742294783884; Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Received: from google.com (88.140.78.34.bc.googleusercontent.com. [34.78.140.88]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d1ffbcf00sm129988595e9.10.2025.03.18.03.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Mar 2025 03:46:23 -0700 (PDT) Date: Tue, 18 Mar 2025 10:46:18 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: Alim Akhtar , Alyssa Rosenzweig , Albert Ou , asahi@lists.linux.dev, Lu Baolu , David Woodhouse , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Marek Szyprowski , Hector Martin , Palmer Dabbelt , Paul Walmsley , Robin Murphy , Samuel Holland , Suravee Suthikulpanit , Sven Peter , Thierry Reding , Tomasz Jeznach , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Bagas Sanjaya , Joerg Roedel , Pasha Tatashin , patches@lists.linux.dev, David Rientjes , Matthew Wilcox Subject: Re: [PATCH v3 20/23] iommu: Update various drivers to pass in lg2sz instead of order to iommu pages Message-ID: References: <0-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20-v3-e797f4dc6918+93057-iommu_pages_jgg@nvidia.com> <20250317133500.GC9311@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250317133500.GC9311@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250318_034626_630600_0A15A3EB X-CRM114-Status: GOOD ( 23.43 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Mar 17, 2025 at 10:35:00AM -0300, Jason Gunthorpe wrote: > On Wed, Mar 12, 2025 at 12:59:00PM +0000, Mostafa Saleh wrote: > > > --- a/drivers/iommu/io-pgtable-arm.c > > > +++ b/drivers/iommu/io-pgtable-arm.c > > > @@ -263,14 +263,13 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, > > > void *cookie) > > > { > > > struct device *dev = cfg->iommu_dev; > > > - int order = get_order(size); > > > dma_addr_t dma; > > > void *pages; > > > > > > if (cfg->alloc) > > > pages = cfg->alloc(cookie, size, gfp); > > > else > > > - pages = iommu_alloc_pages_node(dev_to_node(dev), gfp, order); > > > + pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, size); > > > > Although, the current implementation of iommu_alloc_pages_node_sz() would round > > the size to order, but this is not correct according to the API definition > > "The returned allocation is round_up_pow_two(size) big, and is physically aligned > > to its size." > > Yes.. The current implementation is limited to full PAGE_SIZE only, > the documentation imagines a future where it is not. Drivers should > ideally not assume the PAGE_SIZE limit during this conversion. > > > I'd say we can align the size or use min with 64 bytes before calling the > > function would be enough (or change the API to state that allocations > > are rounded to order) > > OK, like this: > > if (cfg->alloc) { > pages = cfg->alloc(cookie, size, gfp); > } else { > /* > * For very small starting-level translation tables the HW > * requires a minimum alignment of at least 64 to cover all > * cases. > */ > pages = iommu_alloc_pages_node_sz(dev_to_node(dev), gfp, > max(size, 64)); > } Yes, that looks good. Thanks, Mostafa > > Thanks, > Jason _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv