From patchwork Thu Feb 22 17:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13567705 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 C4DA2C54791 for ; Thu, 22 Feb 2024 17:40:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E4796B0093; Thu, 22 Feb 2024 12:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0920D6B0098; Thu, 22 Feb 2024 12:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E24896B0095; Thu, 22 Feb 2024 12:39:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D16496B0092 for ; Thu, 22 Feb 2024 12:39:56 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A9429140EB7 for ; Thu, 22 Feb 2024 17:39:56 +0000 (UTC) X-FDA: 81820152792.14.49D90FB Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf01.hostedemail.com (Postfix) with ESMTP id 1921E4001F for ; Thu, 22 Feb 2024 17:39:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=lw2AtJZm; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.169 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=1708623595; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=P4zFIHQ/E1EymEpMG13MmyyJgNxMAfAql8+8N38pte89kr++3SF+BZk/GfmfcivDvS9i5l W//jnTZQVL40mlvFLvZq3oNxn1O7k/DakQwT3cgjGRz/N2HNfTq4A/jXgPA222S5uca0uq dPdEBNFCODd4zN0peTNu+4FoVyQadPk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=lw2AtJZm; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708623595; a=rsa-sha256; cv=none; b=d62m0vDbP6wCKO352ysQb+jSJBVCh1zoS/q6kJypFSqx1GZpiZb2n7cPjwoBaGigMjyKRY AZfX4d/S4oTIqKI4iyOCLN4AFoWT7WslbC6H5ZaHCZp++56i/8ILpZs2XvfdJXQegrDw5V 1Z8q9DcT+CVcj+NBiR7ocBPCfWxP9qY= Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-42a029c8e62so14482631cf.1 for ; Thu, 22 Feb 2024 09:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1708623594; x=1709228394; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=lw2AtJZmk3VplTnUzXXZ6cDVtf+nAxIie8P8G6Oxm11uBz/GHUY0leRMsM4RO46tQ/ FVnyhhc0fFM/yI6iNdQYmyvW4F++3SkQU6mAuB5X6HPG+4ZOlBhc3mQ5v7eR7Q3dfZuJ U1ByNlRgq5bZIZX44gJerXzQijVGMKVGkiW7/iE/QeasrdxJDAVQlmdYvyHaN8+M3e7D sGAuRFkdNhsx9k3A4MkIWmGn6/hJaDgu4GPmOJNQYr7MzNN4G49JBvSNzoKvxCtC91KP VJWZ5XEDP06oqKWIDSf+UzpL4ljA7aQezDD49UOlOgUbxFgdD45tvIQx0hT/Gqaqk1vw tPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708623594; x=1709228394; 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=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; b=HYM3pE1lCQ0jyDhD8QR++bC7/gGr6VigJ7gzklu/cVMjX5sndsH7pbl6Z5A+EF747V 5R1St40P6kKhoF1+euvjHpa/mxb1Tk1XP3zQvv6NYGTvn6Xb3DLzDmhmnOUZJf3JJMDc SpDYvyeDWiTSh6ckl37xG0L0GP2OYfxNJG8Y6k+snhcfizYW53GPT1gUfIAV6/HXvevV sM1rhfHVKclPgtelEa6uLrF2hALq8oAytIQuICnAj8ToYmWGcz/TS/Zy5tjuuHtpR1lb wRmiF1oEoG/AeFq57JIaipjNAQvb7/WiiY2PumGD/dQkM7KBomILXJPLVOj4MkOA5tUZ WqxA== X-Forwarded-Encrypted: i=1; AJvYcCXeeOV6/esrnj8aB9gN2Rrtk7EAlvouou1t41WosvFVhMkt/lI0jLSyx428V8HepSYSqwPD52HxGoEeAF4t+Tj7QPQ= X-Gm-Message-State: AOJu0Yx6QDkhyufbZWTThISwjsJQK7gukDh3ieDx0kUK0sFuE5Lzy6Lu oY68UvcErYknrqkA2YrN+7QGO3DflsgvSoo1yAq481RDyTCKEyMXqG6MsY0MwL8= X-Google-Smtp-Source: AGHT+IE+Akg5+Cr9C5q9XoLFcnfSS9pk8lVxXF1AmEM7lT1XFT68HyiX2ha271XqH9ioEWyp0Wi6uw== X-Received: by 2002:a05:622a:148e:b0:42e:1d1a:d414 with SMTP id t14-20020a05622a148e00b0042e1d1ad414mr12238355qtx.15.1708623594202; Thu, 22 Feb 2024 09:39:54 -0800 (PST) Received: from soleen.c.googlers.com.com (249.240.85.34.bc.googleusercontent.com. [34.85.240.249]) by smtp.gmail.com with ESMTPSA id f17-20020ac86ed1000000b0042e5ab6f24fsm259682qtv.7.2024.02.22.09.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:39:53 -0800 (PST) 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 v5 09/11] iommu/tegra-smmu: use page allocation function provided by iommu-pages.h Date: Thu, 22 Feb 2024 17:39:35 +0000 Message-ID: <20240222173942.1481394-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240222173942.1481394-1-pasha.tatashin@soleen.com> References: <20240222173942.1481394-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1921E4001F X-Stat-Signature: 3nqxhtu7idumscan1b99qo6pfxnfuyft X-HE-Tag: 1708623594-456475 X-HE-Meta: U2FsdGVkX197M1rArrLchHm0woH4OFKbbr0n77bwsr5lfRAG0s9MP7oOy45EquiUhWnomboo7vZLRo03hUjFKSyXkBBrjyphVyEnbBtAV4gohJUijNG5CFuvgoDAErJFqLCTjMEG4Xa3k3xf7cRtULimvDvIJLZzibEjJwu1HFc8+efizMGQjADd36iZtm+3QgFe1Qtt9lK/oq3c5IMO/4tLYJYg3QlljYCBGbvbEUL2RwNlKJQ6nLJNLmpbi6BWIMpMt2WJmzXhMDNz/xdhcyLlfL2Y2OT14ZxOaiIHX7bhijc5kYMTlO+DpeO21NidI7B8wpvTZpQrca+DJF6EoL4IULvDarZP47zZ4SCYpSsuK2qAAPj/hy4TftkiWSsPV6Ut7VJlyGrE68Hp9ndX/daeBn9jRmdDHC6D5Ra1fHxHu7h8Y7scIpSolr0Cmc1KQ7SYcy2XuLqwDKW7uniiKmStbRRZ/IRRdUibGsVX7y+DqWJL1p9O05YHSG7xxuUie7L+itkpGaQm0zX1vW5LYevlnVg9BCWudjKZe+iaE3/gpDXyBTWrwituJEeOr1Ed0hitweEZ2IMYAWUcjTibqmOA3KfRrhNBkP4iYPuHk5GBDzNcbP64lJyk4qc9fN5/PX2prCavwGiPxq4VZTJXZre42kx1pb2Rqos3gtpOxskuw7xqlfW4l3Tf1WKnOqBsCBYWMsOlu/V2A61hkn/a3X6cEkKL0RF1rgSni+sqiVxTDnttOgCWaLhLWzphCM7jvKNt7JJx//7Ep/hgkUl6HiYuU7Lajau8Eg/smw/y5vXngK5e1d8WToUkfBjlCLFoywvpFaEW5JW3t00XFZQECaVf5j01YCEEQG7SXF+C50R9frLrjW8jxFGEyLYFr9x/U0fq3zlGiMGYyGDC+t9MatkIYhiaInH9Wyw1fNYP9fleDLOPX58sDjmD1ue8mFxQTuo4/DipqEwEkqsxScA GXS4hHhI dawuOmWLV2pCcVKuX9DFkgj6I+nqyb9TfI71wrdfQUQegBkCMTC8vrw9TSuNYBoLzY5WRMil0FBvb5wRlu2TpDyWKrAxQJxQyMVZXENhGscCigY7BU5VCSu2UwGBLH3is3+bMhspWghqPUmy6pxORgRFuXQkDjQyqMh4r6j2/IOgFEMilEDy3aaOEQUxl6vFObjfsevCu+P8L+ev8urUHOkBlMEkT00RWUWKaOId2HS8oiCcos7TJ7Oq1IA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert iommu/tegra-smmu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes Acked-by: Thierry Reding Tested-by: Bagas Sanjaya --- drivers/iommu/tegra-smmu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 310871728ab4..8be74d472f21 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -19,6 +19,8 @@ #include #include +#include "iommu-pages.h" + struct tegra_smmu_group { struct list_head list; struct tegra_smmu *smmu; @@ -282,7 +284,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE; - as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO); + as->pd = __iommu_alloc_pages(GFP_KERNEL | __GFP_DMA, 0); if (!as->pd) { kfree(as); return NULL; @@ -290,7 +292,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL); if (!as->count) { - __free_page(as->pd); + __iommu_free_pages(as->pd, 0); kfree(as); return NULL; } @@ -298,7 +300,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev) as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL); if (!as->pts) { kfree(as->count); - __free_page(as->pd); + __iommu_free_pages(as->pd, 0); kfree(as); return NULL; } @@ -599,14 +601,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT, DMA_TO_DEVICE); if (dma_mapping_error(smmu->dev, dma)) { - __free_page(page); + __iommu_free_pages(page, 0); return NULL; } if (!smmu_dma_addr_valid(smmu, dma)) { dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_pages(page, 0); return NULL; } @@ -649,7 +651,7 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) tegra_smmu_set_pde(as, iova, 0); dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE); - __free_page(page); + __iommu_free_pages(page, 0); as->pts[pde] = NULL; } } @@ -688,7 +690,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, if (gfpflags_allow_blocking(gfp)) spin_unlock_irqrestore(&as->lock, *flags); - page = alloc_page(gfp | __GFP_DMA | __GFP_ZERO); + page = __iommu_alloc_pages(gfp | __GFP_DMA, 0); if (gfpflags_allow_blocking(gfp)) spin_lock_irqsave(&as->lock, *flags); @@ -700,7 +702,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as, */ if (as->pts[pde]) { if (page) - __free_page(page); + __iommu_free_pages(page, 0); page = as->pts[pde]; }