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: 204928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp117274dyb; Thu, 22 Feb 2024 10:10:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUc4h4TLwm76Urf22SJVU0HF2inIWU8/1I/EBAm/LponCZpG4kuxMRaGpQtehDn6dkPFtyiVHnBUVKdQmtl8tQ2sz0L/w== X-Google-Smtp-Source: AGHT+IHKSRl9rRCy65z9OzgJzdMyUDUVDgJIBMN/B8pGwaM9sTAft1ybqZDebrYOl48sYDGWZr4I X-Received: by 2002:a17:902:930c:b0:1d8:e4b8:95e5 with SMTP id bc12-20020a170902930c00b001d8e4b895e5mr20441343plb.32.1708625423371; Thu, 22 Feb 2024 10:10:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708625423; cv=pass; d=google.com; s=arc-20160816; b=DQAnF4LvmJzSmdNZO5WBhXT5xNSK8O4YguR7mHFIxWklVex7uNqs8Z/0ZLujPCfv63 J0FeXy+xybgllgCAYkSUkhrkcNWVmLEWBYC2865+yeehn6+hJA1en4qWwEWAOLNUlkvQ FK0CXpt49nfmtHj9Gd2q9Iji0NGAxndaoQQls2Kz6eCwFbHuHSNPbRNZspyiRq8YiY9Y CXkOuuHQtVMf3Nwu3v63SuEqQhUUgG35IG6xCqG8q5GHpU+9Kni+H0Vy/wSSHCVmaKhp PV3dHvlFBOfta7G+VcSftczvCrEHNEO0fvtMuVheFpz8WJ09O0uw0Bonr+E4TWcPcUJC xawQ== 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:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=uv35HUKrFfNdue1C7Aw2CpDwCbY0H46wtzckiJmEetQ=; fh=NGJCtTiuqqPhJt9IyXTh+6kvoBMGNKltH0RueZvgPdw=; b=ctwBdJb+pkfrdKkIkPwvV7pT1A+dagr4HUDhGoKN6c/jHhL9/stlN6dT5Hj5Fdy0YM KoWE6T8QpUmox9nuRSVdYAj1VxuMqSTyb1vsj0/c3ebriubd67o4MVLzNjW4SxhuXwdl jXDaIWVjig41qjFGZNWaZTqB6aa6pmaE8Kmg183b0thCDx46F7SInL5fxz5D2VxaV/JC NxS9Ew41hBm5DBNf3Drc9zFnNXJsSF0LbfrX4NY9/qbD2Wo5Bw3ObOr2tDG46PVo6jZk U2N9fWpbc49og0GyJ40DhgJmFljvvd7Fe3CFRSze5vdEI0SYlc9DBv0GwOOC9v5J2w8V KEXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=hfymSNRZ; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-76996-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76996-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p12-20020a170902ebcc00b001dc64940da7si260997plg.326.2024.02.22.10.10.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76996-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=hfymSNRZ; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-76996-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76996-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0CDCF28AE3D for ; Thu, 22 Feb 2024 17:43:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDD3D15CD6D; Thu, 22 Feb 2024 17:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="hfymSNRZ" Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F1441586E5 for ; Thu, 22 Feb 2024 17:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708623603; cv=none; b=J+Y5SrYHnzIOjqlAzV2rhbFb+zbYA9YpAt6e8c/bXerxNOwhwDf4B+1/LCvfPwjwLf+Cz9/jqz0uiEstRwZgUo7bS4dgQJGaelQvQjbU3q1Aelmspv3XKInAOxpUOjwOs5/gIMPz+R4a9OTuPgJYxCWegF6pFGpBpZNuxZLroac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708623603; c=relaxed/simple; bh=pCPGI7sXGSKUAtLTTEysb8+tbDwRnVhJivy4g3n1bag=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ff/pUsXIxQuNSWkUuq7wvtbNlIlQQ9Tu/sY8Qj/foqQAEqeCMMfdFsb3W1WFdin+jTSrEnd1ZRRmnXC74zUhDLHp163r4UlFu/bK6KONMNwuIioAS0vF/drXORf5g4PvZ8wTZ/L2vSKaI4zMg7ALvwPfOs0HQdogYsmGVChQtJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=hfymSNRZ; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-42a029c8e62so14482581cf.1 for ; Thu, 22 Feb 2024 09:39:55 -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=vger.kernel.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=hfymSNRZA3Ne1a/+gqFdShU4SZPXJ5qqNBBMZ266cNVcKXmvjAXKKxyv/uXEEfs3m7 KQCZWDMZSI0xAKYjl6KyhpzavmZODUHzv2FTD6MKrZtyj1x03HpZIyuh4jTwqZnhNX3A cTMyegsYOaqJpajUd5GqPTGhcG9WwX2sR3Fwnf15so7JZMpXbWRqKTg93wJi3GyuQmDv Qa1ljvP7iisAVroC0PwsFnJbk4KhypWd8rrEMdFkgGtY7YhMDOLjBa4zjdUK0EhqBM91 YFZ0U7KR2uebIM5I8ykciD+EoR6lpTO2+dqV2uyjNBQ/kVphaypHKz2D9JSablYMAkhw E2ZA== 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=dkoaKW2uRkeE3P6PeuPtvc3mHYmjVe6h5cvBnk9hfqXVrICpOfeFofwLwMbMDEHQbN AA/iREq24dCM4gVfwYBQiOBWmrmGGf1S+dJim/WXYF5SU4nx9r1+btUdSXKpAkDudfji ziQj7mIoPnRlW4U8eK7uArZIgs1YjbQed1wAG9l4H4OYi7muPg7WPdwzsjWAQJeNGMo9 uMRfBaQ+FmB4VxIp30+wXbNZNTJCW+y+HpYevYB5NH+WbpShXX64BczkVew112s6ERiX 8M6uuiHfVhMB/9QQKEmDx4uwrdsi1ngg9OUc+G1I+tkMmfCF5I7mEZnV7uFeUWXdKRAh VOtg== X-Forwarded-Encrypted: i=1; AJvYcCVHxucJhjynSuhOzXsrzA2Q1IPOcgyqwRvQZQI1AUYSKZdUqIeGsykNoLlOEog0bRWtxUWs8gju8sbKd2wHmfC0d9A/3K7JKJTWmiMY X-Gm-Message-State: AOJu0Yz8vceVYpLqYAWzlFaGknJ7k0qnmIuDGATJS2yJHtXwXDMvt/kd /DrcFTVQA/Tl40G3ta/L/dIxc+cqw9RgRvv3g4kwSA6+URcVvw35pNzYGmqbNjs= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791623612393160846 X-GMAIL-MSGID: 1791623612393160846 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]; }