Message ID | 20240205190127.20685-1-will@kernel.org |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-53273-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1079917dyb; Mon, 5 Feb 2024 11:03:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGz5Br9+t7ScegPqjrWzh3wGL/7oDiVhgiNghyr8jS4QQlfyQ+7ZYUObrFnuZagn0XZOuBd X-Received: by 2002:adf:e40f:0:b0:33a:fdc3:a61c with SMTP id g15-20020adfe40f000000b0033afdc3a61cmr318311wrm.31.1707159784669; Mon, 05 Feb 2024 11:03:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707159784; cv=pass; d=google.com; s=arc-20160816; b=RmzUk9Jrlz8rmIf4j9kpV4KtDUnjEa7gWx8PWzqeIGavoq9P6hn4/SuCCg7yh48vqd w2O0Y54yqhAj0pe3jIopuCSlRzkZokyBb9TOVJ9675YibjTT6yEdyhqNYCMQ6+JF3IQc B0GSJwsOyQ3tZ4IT5bO/ASDipSDMHHeDygHuq0392eIkuQAwap+nU6t9SoOinDDkUcHt I5ZSF3+o6/DLyHZlfTCZ0/mIhUfiKta51Y416UB2O0MIgbBdEwbkS5YYp1O/UiVu3Fre wGbQRzSWVVzq6jB55CDUPq6EjRn2rcg2YReWGqgWRWIdE1qNGD8JSZjkueCDz8uS2x6Q pSeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=FD6oLrKscGRSmiILd3uaPXw/1sJQqmBuWEEbw2qP52w=; fh=9eVflyQ/Z9eDILsc5xO1KQg43qBgq4cKmcNoV2Ea+eA=; b=I70YLGpk9sO7rm2D77ZVK7UmCpfFqPUJOpEoGXZ5T9UNnafv87OHB4KyujMF4c8is0 hH/Co9YHP7eRvzFcJPYXWsqE1kYAWqIVpVHnDhHKXp/3nOWs12NsYKO4goXlvVYZyYgs Oo02nzh1yiNU88Bsqdb9kNJLyW8dRvbp2gTp+K6jwXW3d/vPggqJCqq0Agss13g55PNG v9x9XUGVHUhOaFQMGfhSToNrF+yYj6KoE+pAAVNQHmuvFVuN9VxPFiOCzoa1k0caDJum UonKWkSkjtC9ovOHX3526t7UUuY2badBFtzrWT/M97fGY/dWOCvHfO39RMBeG2AzmP9S +5BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AEtdUvhm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53273-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53273-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCW8z2/QUyfYhdIUBOz9Lc2g4QAyMvHhtOZm/KwqqmGgV/i/GkAKqEg+P9shFfkt0tkzfUC2PlxLqK726JYZTZ9gu6O0Rg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b22-20020aa7cd16000000b0055a3694a0bdsi176623edw.522.2024.02.05.11.03.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 11:03:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53273-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AEtdUvhm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53273-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53273-ouuuleilei=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 9F9821F2320F for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 19:02:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D23664A99F; Mon, 5 Feb 2024 19:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AEtdUvhm" 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 1548A48CC1; Mon, 5 Feb 2024 19:01:36 +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=1707159697; cv=none; b=V5ygstYHT5PElL75cOVOoNEvuebOX6VqLCQhLiIVn79FnCRD09QHwtnsIsiaG/jY+aXHADOjSdcZV4MK3vq+sERVSiaLcYFzVbDftxyjuXbtXr+ibm5o10jsDDG3O+ly0AAarWfKTmYpTqogz8J+7N3c3izDDxJd6b1S/awEjeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707159697; c=relaxed/simple; bh=qXT6n/Xz8TGqf2KpHYW4visUF18bBDgbINzKQ8xLz0s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=teUpLMaG8odHKBDXA8rfRhIhnXo8/2kYNTC8Zrog6Ys6MsEPEliD2gzwqVABAR5laelnu+qC6mXs0Rd7HbDRXq39QdhM+fcAJFQ0q5U7oPTatSHcNnOA+Lt9qqiWySWjRL34raQI66EITgxueo+beLEkD+2WwSeVeSIP7Jts28k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AEtdUvhm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA939C4166B; Mon, 5 Feb 2024 19:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707159696; bh=qXT6n/Xz8TGqf2KpHYW4visUF18bBDgbINzKQ8xLz0s=; h=From:To:Cc:Subject:Date:From; b=AEtdUvhmlT6Q4z2ceE1S+VpZHbA1rQEw8LO+Bf9ETCZgbd5ufIs6vM741g/Q1erY3 iMGw6ItvBEer3EgK3/IjPwBqeUyC0wFxJKJi0BEDpfeCs7dT2SMFjBkmzKcYwnUthQ WhFfz5iTvetNX+ZxtVlfj7t4egZ8PyHbQmkHyLVeII7nobppWisVcBQOZMDByw/Jkb qPLCTlbjBlSBSTy4ss5xYgKC3b5E0kaXBuKNu5cwCBpZKrs4crm/8AR/BZQl4XTORR p7Sxw9/iybUH35eJgPdaYL+6/igMauYf/6XDG8mUy/tmLL8nCpYXoYbE3WM8+Id2o6 MaepARhHxl+og== From: Will Deacon <will@kernel.org> To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Will Deacon <will@kernel.org>, iommu@lists.linux.dev, Christoph Hellwig <hch@lst.de>, Marek Szyprowski <m.szyprowski@samsung.com>, Robin Murphy <robin.murphy@arm.com>, Petr Tesarik <petr.tesarik1@huawei-partners.com>, Dexuan Cui <decui@microsoft.com> Subject: [PATCH v3 0/3] Fix double allocation in swiotlb_alloc() Date: Mon, 5 Feb 2024 19:01:24 +0000 Message-Id: <20240205190127.20685-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790086778201433810 X-GMAIL-MSGID: 1790086778201433810 |
Series | Fix double allocation in swiotlb_alloc() | |
Message
Will Deacon
Feb. 5, 2024, 7:01 p.m. UTC
Hi all, This is version three of the patches I posted recently: v1: https://lore.kernel.org/r/20240126151956.10014-1-will@kernel.org v2: https://lore.kernel.org/r/20240131122543.14791-1-will@kernel.org Thanks to Robin for the comments on the most recent version. Changes since v2 include: - Restore missing 'continue' statement that got accidentally dropped while addressing the initial round of review feedback. - Reword the commit message in patch #1 - Add a Fixes: tag to the last patch Cheers, Will Cc: iommu@lists.linux.dev Cc: Christoph Hellwig <hch@lst.de> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Petr Tesarik <petr.tesarik1@huawei-partners.com> Cc: Dexuan Cui <decui@microsoft.com> --->8 Will Deacon (3): swiotlb: Fix double-allocation of slots due to broken alignment handling swiotlb: Enforce page alignment in swiotlb_alloc() swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc() kernel/dma/swiotlb.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-)
Comments
Robin and Petr, does this looks good to you now? On Mon, Feb 05, 2024 at 07:01:24PM +0000, Will Deacon wrote: > Hi all, > > This is version three of the patches I posted recently: > > v1: https://lore.kernel.org/r/20240126151956.10014-1-will@kernel.org > v2: https://lore.kernel.org/r/20240131122543.14791-1-will@kernel.org > > Thanks to Robin for the comments on the most recent version. > > Changes since v2 include: > > - Restore missing 'continue' statement that got accidentally dropped > while addressing the initial round of review feedback. > > - Reword the commit message in patch #1 > > - Add a Fixes: tag to the last patch > > Cheers, > > Will > > Cc: iommu@lists.linux.dev > Cc: Christoph Hellwig <hch@lst.de> > Cc: Marek Szyprowski <m.szyprowski@samsung.com> > Cc: Robin Murphy <robin.murphy@arm.com> > Cc: Petr Tesarik <petr.tesarik1@huawei-partners.com> > Cc: Dexuan Cui <decui@microsoft.com> > > --->8 > > Will Deacon (3): > swiotlb: Fix double-allocation of slots due to broken alignment > handling > swiotlb: Enforce page alignment in swiotlb_alloc() > swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc() > > kernel/dma/swiotlb.c | 38 ++++++++++++++++++++++++-------------- > 1 file changed, 24 insertions(+), 14 deletions(-) > > -- > 2.43.0.594.gd9cf4e227d-goog ---end quoted text---
Hey Christoph,
On Mon, Feb 19, 2024 at 07:35:27AM +0100, Christoph Hellwig wrote:
> Robin and Petr, does this looks good to you now?
FWIW, I'm likely to send a v4 addressing another issue reported by
Nicolin with NVME and 64k pages [1], so you may as well wait for that.
Cheers,
Will
[1] https://lkml.kernel.org/r/cover.1707851466.git.nicolinc@nvidia.com
On Mon, 19 Feb 2024 09:24:39 +0000 Will Deacon <will@kernel.org> wrote: > Hey Christoph, > > On Mon, Feb 19, 2024 at 07:35:27AM +0100, Christoph Hellwig wrote: > > Robin and Petr, does this looks good to you now? It looks good to me for the boot-time swiotlb pool. Dynamic allocation of transient swiotlb pools does not take these additional alignment constraints into account, so when allocation may fail. OTOH the underlying allocator(s) do not provide a suitable API, so I don't think it's worth fixing. In the worst case, a DMA buffer will fail to map, which may already happen today. > FWIW, I'm likely to send a v4 addressing another issue reported by > Nicolin with NVME and 64k pages [1], so you may as well wait for that. I'm interested. The code look quite OK to me as it is, but I assume it again uncovers something when the difference between PAGE_SHIFT and IOTLB_SHIFT is more than one (which was motivation for my initial fix, which in the end broke more than it fixed). Petr T