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: 13628396 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 860BBC04FF9 for ; Sat, 13 Apr 2024 00:25:42 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=54fxzYbT8kYO5CLQ74QJJqa+/c5uXwdeN0tSJ6tewuU=; b=wjo4I2iL1p7SZu QHoo/GTk7EVH4v43rY9sk0cTWEVtD8JxuQ2S2SHesSGnmLTIG8VZxCe/8wkwPZMAH44krGbV2/Mxd HTsk1Otoo6YFK47vSvZmcqzhU2VyjotAkRguElCanKLtl+d+KlgpjdwTexhXFa06yhYfVVh9VywKu MeUlFlvHd2c5A+HMwaQQlwlb62oYbPvxtlpwcSnhk8+60WoeoOGrDHzaeBdvMix4MY+zDIyd16vhK 5YGEt9JQ5xikWIo6NAzcHK+3HX0hU+/wGdWKFFZ/OuvyWPe30QqBfgkeDbp+bv5PhGpHWSqjfhr1A uf/3MM1N2zL+1GvjL2nA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvRD2-00000001nld-3GbW; Sat, 13 Apr 2024 00:25:33 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvRCy-00000001nhj-2BVa for linux-rockchip@lists.infradead.org; Sat, 13 Apr 2024 00:25:30 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78d57bd5781so91680885a.3 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=lists.infradead.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=ZBy/YZKNVAjTewzKTT+rQ0lJ38A9Pw5QEwM/4Lz4Q2YK8ZOnHW4da59eaY1bhAjCeQ NsyhcILZZ/O1Ro5jKUczr2vfI9iUE0iLe656wJ2a0UPX654Fs3BH9lrECeOl8DILoRHh RoWi5wHoPlUH819IVlHIVUVBEDsYYB7HYXmo07r7nZcNUbg9JQyXuCyaffDoHai6IEAb P7R+37vhgZ7jza+9eEm1v2fbu15Qv2eCRbY/kHyahhiJ6Js7QR9b9wRHa92mVP4ISUJv cr2VBtZhdSbK9KeOkmDS4w/hnHTt9wTHB2bIrcFXSKBYLv2dP5H6i925WxIKrdyQqdaJ B11A== 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=l5AVCicw3eimIZMm5uZuWrUE4Ajx7tC0+Ge0+x0mtGJd1liUri4d6cU2nnwGMr+SdT D6sktVo2luCI+KqCDQfwcpssmu1Ll8Ftjvu3CRfJ4YkHEbdUiM9TWrZpfle2WY0Onltq I1ntQy9JlHLCQFSQPAfvczak6GXVDAzTmHzjLAHHFFNpmpt4iujbbeZmzHZBtGKc9php N3klTRXTyyGhlV+pazpLi6iqzL6SOYBVAmM+dL2cNSTp0K3NVOf5zUBPU7bbTi8deNMD 72nESNDOl2+tR0g9OU388FQKBMLHQkD7ppy8ibJE8l/zD1lEZzVObCCaBdl0X6sCykq+ Q4hg== X-Forwarded-Encrypted: i=1; AJvYcCULNP7ItflEZOlFGAaAB/clKRloSlwKof/Bh+/GicFR+KiGCN+znhNgQlygbUgIrNI4/4o2HI96wiNdyrVirAafkGaUAjDX7WDNC+rvOmddnoSG X-Gm-Message-State: AOJu0Yx45QPIgyimSeXZlbnEuQwZASWH7vXsIr0nVYKwRozAKR1lAqYG C8x0tPVc1vJWcIo9S+doYiY0D7khUjiCgaXRTEZnnPqox/7UBHKsDQmn16sLRWs= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_172529_333382_9EA9A2C1 X-CRM114-Status: UNSURE ( 9.07 ) X-CRM114-Notice: Please train this message. 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: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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);