From patchwork Sat Apr 13 00:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13628390 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 904B2C4345F for ; Sat, 13 Apr 2024 00:25:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6648C6B0092; Fri, 12 Apr 2024 20:25:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 614CD6B0093; Fri, 12 Apr 2024 20:25:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4674E6B0095; Fri, 12 Apr 2024 20:25:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 273BC6B0092 for ; Fri, 12 Apr 2024 20:25:30 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F05BC40BF7 for ; Sat, 13 Apr 2024 00:25:29 +0000 (UTC) X-FDA: 82002614778.20.9DC3D2F Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf07.hostedemail.com (Postfix) with ESMTP id 42E9140003 for ; Sat, 13 Apr 2024 00:25:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ncdzX76i; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712967928; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pZlpX3txUE4TJWo1dAHShmrFptGg2d9oY1hNAoNGiuE=; b=xvfJFvDncYjMhoriBgBX5UinMpOAY7uqndDgWqUfuP3iCrL7KL8LGFGKDqulkC7lujG/nK /V19DG8u4iayngosCaqW5vwM0ygVnsKmodyhyeHGXYB67keuhiQAl5hLhb0SsrZi0emO42 bMi8qPxA5fZMzqhjO/EHHeKJMusKWhE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ncdzX76i; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf07.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712967928; a=rsa-sha256; cv=none; b=RK7KwGicV2LA/rFNHJLEcMzpePjRrDGRv9zwJeEBH/i7gOus/kkqwDKi3MRt/WD+yG5+fG EvSIllA65prpRnoHuickHCVj0xoNyWFNFpVawrCUzn7JL0cZM+0qBkU9H3YqzMTdFFIDsj inmvV9yT1Ir50uaWZg/d7r+qkRpFDlw= Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-78d6021e2e3so80255785a.1 for ; Fri, 12 Apr 2024 17:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1712967927; x=1713572727; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pZlpX3txUE4TJWo1dAHShmrFptGg2d9oY1hNAoNGiuE=; b=ncdzX76iCu2XtUDDs/uJeDIFmau/XFCFnhexpeW1PlDFHqSzxCj1FxU9vL4/fIZik4 m/9BlizlKHH7PIZ2LdXGHEy7MQUfbHvPS6F55+Zz8FEUNCZCQIQLqp8Nut8bXh1cMy3m zL+8LKkbKaSNlCfS+xLFUSMccMYAjT06ATNsk2cSWrFmah83JU29ie+l9dCKQssL4l94 1A20wZS/fZTlcs/MltYI3uXlIOvt4lWJRS33kcjj4kiegSJ9nswx+qyoY9WRglsBH+u7 uzVmyNin1YDn1ra4gKO6mMXMNs6TALE4iFbZtfoZY/PfWIiX3BEUBps6vj3QJk2Io50T 5MxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712967927; x=1713572727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pZlpX3txUE4TJWo1dAHShmrFptGg2d9oY1hNAoNGiuE=; b=D6gOfIS8F4arMEkN2B3BDWfPS4Kx8xkF+4WtBcFqEli97sRHqKhN7Xrc5yrjWrY7QA ZtjvnIeEH/9lElIOOiFRFAxbXSYh2Izarhhwueb4RNirRtmhqbzD4pQ2zit8x4X2NM0U McPC9q+L+E5IIgFViPUH9BK0kB/pUbK435vanvbzo1wp7V8FnWdgBy88fB27eYiWTe8d f5JIKB1O2NlLCRsIB97rwPUYqyPr1KD5thaJFgdsIHHtWZShOlxmu6gLuttmATERiad2 GDAMovCxzIjGEuD4LoY7v1hUtPy7zLijL2gmRtW3YJDc7E+0/JIizSQb2Gg/9EXXP9+q 5PkA== X-Forwarded-Encrypted: i=1; AJvYcCWx3zBnnX8c1L7LEXpTDyOGNUBh6CWqkh+oR/EMTZpPDfbjpRJnUwgvScw8nCioigytV9dHihbF+6kMchyN5xc44Uw= X-Gm-Message-State: AOJu0YzZYkvf4vzLtnO4+SBdxaQH7mOll2r+Oe5+O21BvprAQFRoaPyb hVTlQ7N2v6u/suBGOAjg92AykfR7Xe8TtG3WyEDqKT5V0bg4eH9WO8urJ+EqKEY= X-Google-Smtp-Source: AGHT+IHnFRJRktafMl8iFWoPD2wZry7L4eUZEKmr/HQPmjiBtsCGzy14Fj8Nir/jZCpUWrNk2ovbMw== X-Received: by 2002:a05:620a:56a:b0:78a:f5b:ed05 with SMTP id p10-20020a05620a056a00b0078a0f5bed05mr3835236qkp.22.1712967927419; Fri, 12 Apr 2024 17:25:27 -0700 (PDT) Received: from soleen.c.googlers.com.com (128.174.85.34.bc.googleusercontent.com. [34.85.174.128]) by smtp.gmail.com with ESMTPSA id wl25-20020a05620a57d900b0078d5fece9a6sm3053490qkn.101.2024.04.12.17.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 17:25:26 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, alim.akhtar@samsung.com, alyssa@rosenzweig.io, asahi@lists.linux.dev, baolu.lu@linux.intel.com, bhelgaas@google.com, cgroups@vger.kernel.org, corbet@lwn.net, david@redhat.com, dwmw2@infradead.org, hannes@cmpxchg.org, heiko@sntech.de, iommu@lists.linux.dev, jernej.skrabec@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, krzysztof.kozlowski@linaro.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, lizefan.x@bytedance.com, marcan@marcan.st, mhiramat@kernel.org, m.szyprowski@samsung.com, pasha.tatashin@soleen.com, paulmck@kernel.org, rdunlap@infradead.org, robin.murphy@arm.com, samuel@sholland.org, suravee.suthikulpanit@amd.com, sven@svenpeter.dev, thierry.reding@gmail.com, tj@kernel.org, tomas.mudrunka@gmail.com, vdumpa@nvidia.com, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com, rientjes@google.com, bagasdotme@gmail.com, mkoutny@suse.com Subject: [PATCH v6 02/11] iommu/dma: use iommu_put_pages_list() to releae freelist Date: Sat, 13 Apr 2024 00:25:13 +0000 Message-ID: <20240413002522.1101315-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.683.g7961c838ac-goog In-Reply-To: <20240413002522.1101315-1-pasha.tatashin@soleen.com> References: <20240413002522.1101315-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 42E9140003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: eaa6ab41p9k1bz7z8rhw1ejcygfix74n X-HE-Tag: 1712967928-934949 X-HE-Meta: U2FsdGVkX1/uQHMbNNDN1k+TkhuLBWCgenaDwus8FBe3XVz3qlNLI5+xDYann8yTfWf+sT1IPhp9P8CsgVcYefiCu9TAuHZGk1SiWtoSyjqEFdiBr4dlwpoktokZn4QcCnlbjyu7rINLxA2djlilGMAE0HiJdIVfwyEZTiUInCt5IDNM6N5/LVjtsAJUX6M10bofF9DAx2xrcT6X3nVqpTJSZ+mQQ/v1mc0J85ZxHQdAXmBIc92pyMiMGelLtV3UL2bSVZwup/7Hu0sYrgAJjLFXnNguZzH9bAr5UBd9NxF/ItXMzrWXNIC35/PBDWO2VYeaEZJ3rY9R5gKPWisBmhGgHdoinC7gIdTiZKYJe3+SDBIwwvLcx5fp8sCe3n7dVOQ30H+dJW5vrJ8fzrnO6Cl4FdTfqF1G1LUNPzt6CbVzVgvCU//ZCGAmVr5YiSU8X5HItQ4EBCiNpljGEU7oLzrAQNUlEjtE228l7B84p7ayUGQ0UW86B2Uj2C1LLVRt5Un5ERZuBsoIcej79NkyzW9ky7FdGHzojqkdjO/3Dy3HDzaSaaCk+hVL75bSpwd2h5PJvFqIVbk+d1cl+sTtjTmW3j1FlZjGPjxRyHUXVjMSjzmoU5Ksw/oVSQLN/TsGtBBaTE0nf+d0Q7Gwn3pLBPQpZC8yMQ2iAs5yReC0lzvzb6k6GtIc76gdG6arX2jokjVE4FDI6BNzzvjdiijRg7z0CC7hF+3A4raS2gpDWLg7eDxXjma2Lg3eYvhjUj2pk7vYgiUP0b9nCoQD6vKHxnvIjvJPwvkgEdgz2OPlylsqb2nFWW5fXVBYkz0VZ1dcrRpmwAPfA3Tv25VcurT8kInq/IutE61okCiJcan0ksdtGtCZo5pE+q148aAcOoXCsLRdZHrSu8sjdMFxJKnZNTgrkhzrWC5Yq9E3jPVRymZ4okyhzY4p33LwLwrAiHuCmAFrX4+cToRKVFW904a jz40FE90 lI+TIw6UWSnC9iwQAfbK2Dq+SjMsVvtDTcur6mgPXzp7/mm2XB89DAPNFF6i8CTDPBrClDEVYP/2pLtqcybaEMmmT3I6o/0nNQztbUQy6akbqrL+QMLjn8sosGSdRROnBzdmTXF/CYvjcyY9ADqBfchkZPXv1Fzs9AyPYOaOhEYK2is1nn+swTPiHvXuQLQDVKFINrgkGmGU6AkRu7u6dofQCPI/zs3iNwrEkI/4KQDSaXVkMCFx/Gn8HVOcX8S+Mi5yrzSvvUT46Vqf5YuA1FXa3bSKysVtdRlxROsIAOcmkmpOo5SvGeeDAucclIeXQON6ztP7qn3kVEcuv1EKT34rTzgLcl03gTjgX/XcnvUP72tEduq6BwozyrQp4efykEAWL5qMy9MjFQo4vcXrPkMhFzMQ7ltEeDwyC6I8PgObqT+q5HrOVGMnSdEfkDkuyo2xzl4MdGRkZvfoRqPj+Xv3TyHaR70f0OD7OufaR6u1m/cm+GXo5xKYaqhmzZaFIpCfcysGAu14Zu5yZtUYi9hscxoy3+Q9NEPWV98+33afpxYfyCMqGDBYe+7KRBtDpdbdpHzFSEpWSLod3FoUoo0GBImqD1jRRA/FJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000036, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Free the IOMMU page tables via iommu_put_pages_list(). The page tables were allocated via iommu_alloc_* functions in architecture specific places, but are released in dma-iommu if the freelist is gathered during map/unmap operations into iommu_iotlb_gather data structure. Currently, only iommu/intel that does that. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/dma-iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index e4cb26f6a943..16a7c4a4f3db 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -32,6 +32,7 @@ #include #include "dma-iommu.h" +#include "iommu-pages.h" struct iommu_dma_msi_page { struct list_head list; @@ -156,7 +157,7 @@ static void fq_ring_free_locked(struct iommu_dma_cookie *cookie, struct iova_fq if (fq->entries[idx].counter >= counter) break; - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); free_iova_fast(&cookie->iovad, fq->entries[idx].iova_pfn, fq->entries[idx].pages); @@ -254,7 +255,7 @@ static void iommu_dma_free_fq_single(struct iova_fq *fq) int idx; fq_ring_for_each(idx, fq) - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); vfree(fq); } @@ -267,7 +268,7 @@ static void iommu_dma_free_fq_percpu(struct iova_fq __percpu *percpu_fq) struct iova_fq *fq = per_cpu_ptr(percpu_fq, cpu); fq_ring_for_each(idx, fq) - put_pages_list(&fq->entries[idx].freelist); + iommu_put_pages_list(&fq->entries[idx].freelist); } free_percpu(percpu_fq);