Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp145051rdb; Thu, 1 Feb 2024 04:52:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA1VwjjrNUHoJlU3JI1+l7E+cgJTYr/CJsgjlIlyBBndKtktJ7k8LaLEu93WcErhnKi8XN X-Received: by 2002:aa7:d508:0:b0:55e:f51c:8cde with SMTP id y8-20020aa7d508000000b0055ef51c8cdemr3522287edq.39.1706791974760; Thu, 01 Feb 2024 04:52:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706791974; cv=pass; d=google.com; s=arc-20160816; b=uZNtuhmpwpVj5EWVSyJTbu70gq1peXYjkh/CJZiWsxTMm+JAkUIyHrInU0ughPVJ6f oivnneeh2LInKzG08wcomCiWiFF/FYPvEjiu3pdh14Q0RowOPdGiZ2+rqXqLAHh96mbV xcvelw8zRkN90J67vFCOSBoZGhjK72fQxpLkgDnbUuQE3/fWNDSzsD9Rb/SvyLOiyA9+ NKSf+QDgu753o8F7U8x6HDdD1guCug9prsl7kRgxo1kWDtiBNMQ/4XRESSeg7XzBJFnN pNChjXhk4YC6iNIQRBB4WoAzvt/hlD9M1q4NtpjesP53byfr7bJC6M+JjxMIOXXu309G YZLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=R46iay1l2XLgScXwRfq7b0MjOB9qNuE/cG9zNT3mmGE=; fh=ti/4BzW1RLXZB6Jl3CY9w1JH4l/rAZGmgEwmBbR7hOU=; b=eD8H+iZUTMH3JjP0BEIAhR29y+LVJBCb07FZ8VE4wVQSVRSanqvw+Z9k/XOSNGeDNG p1Fu48g6vmsNVoldShiFps9mUk9FzqyYAaOirh0Q0m+1JMruKEA2+HaiQRxAPRBe3W01 IJ2+VsJ66q1LfRmcBwYJuDzM7UeOVRHX/+e/uvz5Y1KtyuNpz8lPvJRVT4wHb2y0j2Di TwBSDT7Z15wZ4oGarNFsGaMS60CRoihQtmG7lUntNVXzT1320xDSwdSloyGlOe6uiwvQ 2coH1z02fPo6Mgj4YJD241v1Z9rxL/1hhqIKiX920qjIxUdCvgCqQ1aTv6P4M7hkNmiv Hu1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VcjptXF1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48165-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUXyQxzDJwqyJE6cgCFPyyQZPVHxLbfv/xLr8cEYDGB+0tVqBBbmX0tAmXUXcMtu1YpHkP/N2I/3L4S4oc+npvH/lcHC79pkAPtu0LCKw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n22-20020a05640205d600b0055f92d02d14si1545052edx.598.2024.02.01.04.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VcjptXF1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48165-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48165-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 73A031F234CF for ; Thu, 1 Feb 2024 12:52:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFAA18665E; Thu, 1 Feb 2024 12:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VcjptXF1" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DB81786641; Thu, 1 Feb 2024 12:52:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706791946; cv=none; b=VKPU3Vx3XZDY2/7dzzSMz365eAXLTghneBlvz78i/mUzd/HWLjx1v8H1H8kbMiBh0K8hUXz/cCa3LqYg0KjE9N0qoi7TZzxnO75B9TUsM3TAyYbI6XNZLJpllC60e2DTJYxVjnVGvdJQpeRs3jMvityp3y3gtuXlc2weTeVbwVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706791946; c=relaxed/simple; bh=PCBo8l5F3VLXTikLYeqFp207iISLAQXi1tVpHtgpl4A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TR7RW7lXUAediqcDkQBzT7syS7UTC84zoQq4CDiLrOSeJYrEbp5jbYyupo3pk78hMt8AotwlgVzxgEiupu8saqvb0mgxMZajiguEzjsRSnVxTnbX4o0z1QHueKb1JHSzuhwaRuYWsUjWIGfUXogbvLYtNL0yJ/jiZUeXkjcv6Tc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VcjptXF1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD8E0C433F1; Thu, 1 Feb 2024 12:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706791945; bh=PCBo8l5F3VLXTikLYeqFp207iISLAQXi1tVpHtgpl4A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VcjptXF1UAnvERTZWUHBsEOtU0j6iy7F+XE6eC/vzvN4GnSUAFa8VIxbbJsZ4A4Lb 1eoNUYKKPJSgnW/NNZuATH0U1oLjfQFy2CIbwhSrMXCxt5szXZVWG+v9Uhp2zNDBfI BTyka3w7JFP/oKGObj+wiOyMbxgx1UiGi9Mn3KtvGfvbxRqrQWYAOGFdwIpJ1b3oFm 67LTnN2zLrFMUzVSoktmR95JnHgnQMKjr5sHfHN9MvurigL9FT5hfDDp36sRAaShxW GB3LxVA3KwkyKWt5Of18/iGugfmoAdrzniozTZxUD20nTEBfVsH2XmGOVn5f6P8IRU SuFbpAVq7DuGw== Date: Thu, 1 Feb 2024 12:52:20 +0000 From: Will Deacon To: Robin Murphy Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Petr Tesarik , Dexuan Cui Subject: Re: [PATCH v2 3/3] swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc() Message-ID: <20240201125219.GC15707@willie-the-truck> References: <20240131122543.14791-1-will@kernel.org> <20240131122543.14791-4-will@kernel.org> <82f03af0-6505-4c1a-8002-272fa5a7a7d5@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <82f03af0-6505-4c1a-8002-272fa5a7a7d5@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Wed, Jan 31, 2024 at 04:03:38PM +0000, Robin Murphy wrote: > On 31/01/2024 12:25 pm, Will Deacon wrote: > > core-api/dma-api-howto.rst states the following properties of > > dma_alloc_coherent(): > > > > | The CPU virtual address and the DMA address are both guaranteed to > > | be aligned to the smallest PAGE_SIZE order which is greater than or > > | equal to the requested size. > > > > However, swiotlb_alloc() passes zero for the 'alloc_align_mask' > > parameter of swiotlb_find_slots() and so this property is not upheld. > > Instead, allocations larger than a page are aligned to PAGE_SIZE, > > > > Calculate the mask corresponding to the page order suitable for holding > > the allocation and pass that to swiotlb_find_slots(). > > I guess this goes back to at least e81e99bacc9f ("swiotlb: Support aligned > swiotlb buffers") when the explicit argument was added - not sure what we do > about 5.15 LTS though (unless the answer is to not care...) Thanks. I'll add the Fixes: tag but, to be honest, if we backport the first patch then I'm not hugely fussed about this one in -stable kernels simply because I spotted it my inspection rather than an real failure. > As before, though, how much of patch #1 is needed if this comes first? See my reply over there, but I think we need all of this. Will