Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1199400lqp; Fri, 22 Mar 2024 08:09:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+/OnmUd7vksb8GOH4zr3E7rLUMjODvHVTcz2y7rP1XUqZVmV3vYw83yqycbrtVK3l+HmHUiRBurlYj41VJPwBoXlFgmZ/skPrVVUtMw== X-Google-Smtp-Source: AGHT+IG3VsGWF/gPNnOtMIozJb/FPTz0Qz/mdbhr87JtANRHw1BRjPRG4OW1Vn7gBnSwNcfR6JMs X-Received: by 2002:ac8:7f49:0:b0:431:347b:b6ce with SMTP id g9-20020ac87f49000000b00431347bb6cemr1659474qtk.25.1711120194385; Fri, 22 Mar 2024 08:09:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711120194; cv=pass; d=google.com; s=arc-20160816; b=vZMnGz6oZnPlAIWQlNSr5McFd9+ARjIeH/WmNsu4wjxX2tz5ZOoMUkGxdFMM17BWr3 DO6wSpl3swjXjLPKPBkOMAUvAyGf8VPo2HETp4VRPQQnU42mxfs1OrYkR+KYchaqJ5jR t9TNfrWi+G8txJ0mJU6sB30vp3r4ne3NdsNfuIwwH1t4AEPulzw3+v6D9KWLBaEjzPvX fIMA7X9isa1EtfhDK7Q4UPIOrAYo+noWP90uCiNlGWbSLm4tYMTtPkAChpLxBXZ7gPvW beDHCF7cM3q61ih7ZW8u6ed9hvSzK7uhArYcNIeq6Ds2ECBw59vHhxokeQ134E8/aZmi 1icw== 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=oqhGj0hQH4qbf7+t/sA7N53X6whIm0K7T3d7Jvrz6XU=; fh=Ha/C7YpHv3fiBqBQ1xQW3CsHnqYsHXz7r/971VqgfO4=; b=TGHDuKc5WrILz8SxS+3CQmX3bSgx1noNO0TPB+9vZW34jXGADQDUJAQ8vcFqL+WRYc JgK6k8A9vj+Ke+WEsrpdMRBUaSylq7SIiLvuT3sKayE2xNrLczroGhotwN97eDfz0F59 K7vEnemw0KzX8QCW78uvgg65Palk2u1NvToho4yl6WsljfpjbhVzYdhCHURyOObURgLy 4LoSpo4MOosNJb6SKr+rB2Fbsl0kTkXJnoOTV858vswBThI9NVXBO/UFnVRyA1EVOm9c m6UQkd8G5o6Xi2EZQJ5gL3DJ/730CTjunQcxxJjWrSy+soiao9VfoSVK7zoMk8VTn5Rc V/ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPlLRpNd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111680-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o11-20020ac87c4b000000b00431166b9fb1si2194985qtv.88.2024.03.22.08.09.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 08:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPlLRpNd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111680-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1F0701C22562 for ; Fri, 22 Mar 2024 15:09:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42A274DA04; Fri, 22 Mar 2024 15:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VPlLRpNd" 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 67A92481B3; Fri, 22 Mar 2024 15:09:47 +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=1711120187; cv=none; b=YCk638+GQ0VIHW409/WY1U6qnjKJHPtLaujtgKaqhpOh2kl+ETVJhPDcuDUZ9uFlNWf4tbJ/LDOB9xEl1ZoKKU1dMCgEKyD5ANyXGiizMjxGGQSryQ1wiKY+s48JpQISMaAOSBQUa8x/j5FRI1wjcvvsD7yXhCLzww8leY3MGL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711120187; c=relaxed/simple; bh=UXgPa4p5wBn1d97FInWzLgeWdHJZdB/ycE6abVVuEHE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BeMeWAnVUGKB9Cl6n4d/zBIJ5/7Y0U+w9SSQXj9XiQa9sObGXFF/NMzy/jG6/EmOgpRE+pcMuTWLp+wsBBjLw9EOEw2UiLypPP2jgUKoVv4lv8hPO8+WQ3i80M1x88Sl7rLlqKehQX0P20+g2hS6mt7fgVCoEBhjKQ+bvAHifII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VPlLRpNd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DD70C433F1; Fri, 22 Mar 2024 15:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711120187; bh=UXgPa4p5wBn1d97FInWzLgeWdHJZdB/ycE6abVVuEHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VPlLRpNdS0FHw4DD9EZneTwobhZblVezN/Y/Y5CiXqGdaxw4FLFxImpc4d2HP/RgC ZxPntCPNxSokHzmY+inIKJlDcfRR4ldf1ugOGXa8ymSMVizhTL5WxdKOI2FoyjI/bm IXvjvB+JROneBphP6GvK4+3fwFQqnawdTrWzKIvGCSk7bLXbFVATkEsTIVhZ2YGML/ IiOPbS3Za+YsVysbG+t96OHjLmyG+sGkXdzJSfSJOaO0WFegSZJ59z7siq0zr/ehIa 5g7e++IWf253Io63or2ImSQ127kTbhSZyn4JtO6yk+IfNLkKFnecTd+0RCZjNai8Kr uTOAqNF1rftag== Date: Fri, 22 Mar 2024 15:09:41 +0000 From: Will Deacon To: Petr Tesarik Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Michael Kelley , open list , "open list:DMA MAPPING HELPERS" , Roberto Sassu , Petr Tesarik Subject: Re: [PATCH v3 0/2] swiotlb: allocate padding slots if necessary Message-ID: <20240322150941.GA5634@willie-the-truck> References: <20240321171902.85-1-petrtesarik@huaweicloud.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: <20240321171902.85-1-petrtesarik@huaweicloud.com> User-Agent: Mutt/1.10.1 (2018-07-13) Hi Petr, On Thu, Mar 21, 2024 at 06:19:00PM +0100, Petr Tesarik wrote: > From: Petr Tesarik > > If the allocation alignment is bigger than IO_TLB_SIZE and min_align_mask > covers some bits in the original address between IO_TLB_SIZE and > alloc_align_mask, preserve these bits by allocating additional padding > slots before the actual swiotlb buffer. Thanks for fixing this! I was out at a conference last week, so I didn't get very far with it myself, but I ended up in a pickle trying to avoid extending 'struct io_tlb_slot'. Your solution is much better than the crazy avenue I started going down... With your changes, can we now simplify swiotlb_align_offset() to ignore dma_get_min_align_mask() altogether and just: return addr & (IO_TLB_SIZE - 1); ? Will