From patchwork Tue Dec 26 20:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13505031 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 DC500C46CD3 for ; Tue, 26 Dec 2023 20:02:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15AB86B007E; Tue, 26 Dec 2023 15:02:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E38C6B0080; Tue, 26 Dec 2023 15:02:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78D76B0081; Tue, 26 Dec 2023 15:02:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D13BE6B007E for ; Tue, 26 Dec 2023 15:02:16 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1763A04DF for ; Tue, 26 Dec 2023 20:02:16 +0000 (UTC) X-FDA: 81610041072.25.9CDD65E Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by imf27.hostedemail.com (Postfix) with ESMTP id D679740020 for ; Tue, 26 Dec 2023 20:02:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="QDz/MeLJ"; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.47 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=1703620934; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=OpP59d2/r4DEkNgRI2Ow2HSX1J0JOwspz9FHB6qZxEUnLBtYqs3R2PiCFA/WCBZzTul/q8 hz8ZegrWQ+0lC5dYKf5bw2vzCgtB42xpqe/VH4t91/kydBULwdF/IB8dhs5d6LIWIOO7yx TPeOZgClw5FgsEJh6BVFbwSoHziRkbM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="QDz/MeLJ"; dmarc=none; spf=pass (imf27.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703620934; a=rsa-sha256; cv=none; b=A23nLiGozyiNau1DQR53Lg1SgTRbSFXHp9mMEb0ZCKDcB+rJSJOY6enouF3Ny8hpm0XRJh Vgj5YmInDCfnO49ND3CZL7emt6XwEI7Z1KmduRyP0XoIV0RdnMkC9VlK6dWoWO2BUI5Isb XxjkbWuFnF0Zxu3p3CERrUlZDAXvzCQ= Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-594cac3cbaeso188055eaf.1 for ; Tue, 26 Dec 2023 12:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703620934; x=1704225734; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=QDz/MeLJGSrAjeEHRSQibXupM5yfTDHfxRp2yLZtoJhHZ8XFIBWP+Q47kbxs8QuWUZ zOV6loiZk5p/nOeHI6Pbun5kx1zhe8YmFx5Ducie9ZwklUdLXQlkFv7Gv2c7iC41enB6 H5gAeb/9cdN5wGmAKmOjINWm+zhtvVkRhbVYUhU1jzbp1d8W2KL0EWsHiAUYxbcj/fyZ h5PKiMupTFtSkDbn1vuR10a0lhvx0HQ8nU49suum/YALiBv0yJGDoqGiLhXCpXT5RUDf V4kOCvk8JszSEKiSzoIfYv1AgVz7+sRK5pUtdHLLZnw/M53G3WvYQBp9lCIP5gSuR0Nu YBxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703620934; x=1704225734; 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=4Px5z3jJNMJ+cqkQJ8fykFQGitjbal7TFA82XDDTiIs=; b=jrOi5Qev4WEL1Lvxi0m3FCUVx2OW+ZbyPYvDN8QMMidgGG4lVSzHBOi10xbrDrr4gI w7Bzx6Z4fb4QSOpJobv89rkMBlr1J7NvBkQ2o3ajkJ+LLHhhlON5e3C6U+1qBtr4Zucn sAC3itJAAcaJGsZLMQQ+3C49i4DnmJkyDdezdJ6cp9PPBh30CZg0s7UA932aP83S0sz8 /mH23VDSvd/XPdfxv4GLR6g8LE5g3rC2iVf0K54lVD0ougp0Jj3vzJKWbHBI+YZJ6aB+ ywAoAnZuRSemAx1mfZhxwxvKl/8+MhoPwWyroW5VbBDV2nTARTXr2oQB7gosgJGquP8E TZgw== X-Gm-Message-State: AOJu0YzMDAWC0NuU011nc+gJ3ZdP3yY9EtNIoymLvcJlh1XRgbzZJRv4 iA1oSRb4wDVYX20Uut/R0w/48EbkAoC7Cw== X-Google-Smtp-Source: AGHT+IGuyxzVTrkGD7GeRYCWL+kwqdfuJTNbDB34T0ltwnMiuh8TxVV6prFt2lzUE/2C05msUhTBCA== X-Received: by 2002:a05:6358:70c4:b0:174:edbf:a9a2 with SMTP id h4-20020a05635870c400b00174edbfa9a2mr2577495rwh.48.1703620933708; Tue, 26 Dec 2023 12:02:13 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id t5-20020a0cf985000000b0067f696f412esm4894539qvn.112.2023.12.26.12.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:02:13 -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 Subject: [PATCH v3 06/10] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Tue, 26 Dec 2023 20:02:01 +0000 Message-ID: <20231226200205.562565-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226200205.562565-1-pasha.tatashin@soleen.com> References: <20231226200205.562565-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D679740020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fidwwh9xqtttjygxsk16j9b4mxzz1ekm X-HE-Tag: 1703620934-395810 X-HE-Meta: U2FsdGVkX192/JCSQz7cQnsan0a6550jUjJS8BHJEH0f0t74Zx+C3Eh5O3ZhiA3hn1nnr/OBiwQ2LQ5SI7cXngiWAEdGeBjNEqqridwFRYBGQSa5nMEutltHQ1c00p5pe78PZgJ1DV8IKzJBO0/ifL6tb2BYZsYDTrqDejRuL5RLNYmeJFp2PZ7mUga429wgADv8fhY8xIPP0LR/Rv80LSwPSclnZ2RC2aDgaNmp2D6qqojH6UIYNju+ujLud0O7/V3tQB7YXWk35VypLoMAuEX1wjhb+knOiv0byu6MPYMe66SRXRzbW+D/KyEnKYT+2zlvYFj3OYT0UsNY4H5GUZCCU044ZcESO60noTWWojFqZ4frt1phc0fg72EfU59HDQ1+9qY68cYSSAKpANU8OkRiwCLVEdgcH+KrMgWM1bADgffXJar6MCnRTGo6XYyicPoApQCGvFj9i8PXwkoj7PWmWjD+17pNZVSXuvCF3lJ5Q9BZw1f86K6zRxYI+qq9b6yB93V6Kot6otrxsxAzXGfGw4lE9Q6VCCTgyLzsh2c8NniBtW0Cy+v9/DcebwI6wwEx03jFBaos3chHLyiFvwhNGPV2HFV9DaEDG4OUvH0soPT0uEoiiUHFw7Mpmzhn1e3uDvdtFDVKSq8x94rgbt8KIdZy237Lgpa0PUXXvNb2/z4dH2SHR+G64zlI1XC37ZeoepMer9ElgGu3zEQ9R5Zi8v+JDke61Q0PHH69o4988akHjAvCH2AxkAHELy6NBNvruuwWDiMGrD/heoiTg83VejfyjTyDgST9kNA3xJ1JTwoaTv6vjZrvxBJg7OugOPiB6W7pY+K/WMl7AY9v40xKKNGKQ3WslJCHWAQ+ofu0T31cc1FTB9oDsQTtcFi4X73Ft7GU439gpzx9U0hXVloM8TC3xC5aL+XHM3vJgj560wpeD2pssAr1CDaC8KYsez96krRabMFBMxqiVrP nQo89kSg kNOEgMgpa0MO6tJi7P0z1+omNK5AEOhFilpxAsI+00ElHuYhTERQOAkxCR3uS+spz/W+g+hKxoBVxc7FzDFAealDRlD6Wpm7OLEOO/lAyH4F83Jnv8TFFnSWzJx1VdKBzNXhxtDP2GxbHR9fHkkU7FLLzrZ3JtFz1ISCnoe5Cbb7tZjNggzCK3aYhBzpwvEqbhUdw6WRv0CylQbyqjpdsXxtW+98pmjg5ec0aagijurqzOM2Q0oB7APc8aj2X07tLXQj5tclfSTxoQj2OuEl5FEFjkCSGjErxg/6Zp7ITY2In9eCYdCib+wcKUT8rhG0QS9+WlGesebURdfSGO2OGWR/kjo0mBZ5RfMUEo7qtBguBr4gA8eMbChhZEWyIgsDt4MTK73Wc9HPzdmSr2WFkqkNC2QID+c6Fjf8dyceTnHuAB2d8hMfV2MF0XypR9TE9sQQ956BhALZU6vdkF2E3RGCQ0w== 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/rockchip-iommu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin Acked-by: David Rientjes --- drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 2685861c0a12..e04f22d481d0 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -26,6 +26,8 @@ #include #include +#include "iommu-pages.h" + /** MMU register offsets */ #define RK_MMU_DTE_ADDR 0x00 /* Directory table address */ #define RK_MMU_STATUS 0x04 @@ -727,14 +729,14 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain, if (rk_dte_is_pt_valid(dte)) goto done; - page_table = (u32 *)get_zeroed_page(GFP_ATOMIC | rk_ops->gfp_flags); + page_table = iommu_alloc_page(GFP_ATOMIC | rk_ops->gfp_flags); if (!page_table) return ERR_PTR(-ENOMEM); pt_dma = dma_map_single(dma_dev, page_table, SPAGE_SIZE, DMA_TO_DEVICE); if (dma_mapping_error(dma_dev, pt_dma)) { dev_err(dma_dev, "DMA mapping error while allocating page table\n"); - free_page((unsigned long)page_table); + iommu_free_page(page_table); return ERR_PTR(-ENOMEM); } @@ -1061,7 +1063,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) * Each level1 (dt) and level2 (pt) table has 1024 4-byte entries. * Allocate one 4 KiB page for each table. */ - rk_domain->dt = (u32 *)get_zeroed_page(GFP_KERNEL | rk_ops->gfp_flags); + rk_domain->dt = iommu_alloc_page(GFP_KERNEL | rk_ops->gfp_flags); if (!rk_domain->dt) goto err_free_domain; @@ -1083,7 +1085,7 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev) return &rk_domain->domain; err_free_dt: - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); err_free_domain: kfree(rk_domain); @@ -1104,13 +1106,13 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) u32 *page_table = phys_to_virt(pt_phys); dma_unmap_single(dma_dev, pt_phys, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)page_table); + iommu_free_page(page_table); } } dma_unmap_single(dma_dev, rk_domain->dt_dma, SPAGE_SIZE, DMA_TO_DEVICE); - free_page((unsigned long)rk_domain->dt); + iommu_free_page(rk_domain->dt); kfree(rk_domain); }