From patchwork Tue Nov 28 20:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13471792 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 815E7C4167B for ; Tue, 28 Nov 2023 20:50:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3FA96B035D; Tue, 28 Nov 2023 15:49:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6D36B035E; Tue, 28 Nov 2023 15:49:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A3886B035F; Tue, 28 Nov 2023 15:49:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 747E26B035D for ; Tue, 28 Nov 2023 15:49:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 42BFFA03CB for ; Tue, 28 Nov 2023 20:49:53 +0000 (UTC) X-FDA: 81508554666.23.F57FE55 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf06.hostedemail.com (Postfix) with ESMTP id 8271A18001B for ; Tue, 28 Nov 2023 20:49:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=BgiQHTC5; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.50 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=1701204591; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=MGz1L6H3cbY3yH5lWEDniy6PaJ8Y/CvzHQs9Q/9jAQ+w3eDOZFqLk2HT8T0pCquubktaSQ M0JYnw4sGhQ2PMdM3S3ZI+ixo4c0MO68/dK3hIZ6NMys+AW6almyOiFDD7crLhGySsy002 NRsFwfPvocqLNUHkDO/a97ZCp9UpOyI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=BgiQHTC5; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701204591; a=rsa-sha256; cv=none; b=c2DlpkPi6ijz+24477EQ3eZUEIpcQ+wnrI7Un+Jszta/Jxb+OH08aio7P+OEiE/d/AQr9V V52vppw7h/fs2MdPVnqrMXEN6VY511tGuzoIBgLZc3oVCu1Y5tJ4OxxM0gCWOTVRYZpWdu bjBo7ci/AZjuwpfMaKSca6RnzjlqYjg= Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-67a34fbaf12so18842966d6.3 for ; Tue, 28 Nov 2023 12:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701204590; x=1701809390; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=BgiQHTC5KFQycKeh0AoM7KHBurTNY1spIN9wS+dSGuDvLWi6M5GKQjMaSVayaYxqiI YvgibEpGjY09sVXoszbNdusknjnOFCJpg3mxQqs3EnGJMT5xIWdVa05DYeYxFya09/KX 7guta/cCjaxM8hzAnhQGfZHF8ctglSoCpweu00mLxqhm7NyXOxjnUFOXtGPDwKxhmPN/ GGsM9e9s+xD+tSmvD53cZ2jGYGGIlerFPIfI3QkhrbFEooYCqEVTrLeSNgbURJZgxv1I DQGVF4jdz8S7mZ8IQDawxTKealRa9yvHy//L7zBetrSUTmh0/AqAq/aR7OZoF/E5ebAk MGXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701204590; x=1701809390; 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=ETdhPmFEsQhEIbzNxRgoLUCae/wd+Ix3V20Xa0Oz0Bc=; b=f3jF/UAL5sX2ek/R6QaruSUqpKckj9wrZneWbqonZA31BF50SAEC0EUeaW+5cz/CVk ztKpeqxxx2oouV7Fjk6xIwPv/jbjacjOnRrjYkF1OKX7L/qRvnpWyO7x5+FSGXPuD/RH 2maq7ltSNvGy1ltMfSH8g2aXmSuvA3hb+K9svLFQeBVPnSzmE0icCs2Hhexe5YwOJIoY tH5cJCeZ18D9f7VVx2KVkb3hSR+v6G+b4oOwNWeO504FaGb24RU3/flsX24Cyh21MJkv LiOYZzAP0V2UBxYsbPujIdVX3xt/UjgFkT6wF2CUCNX7L7MTkbdm+Ddyk07bEZfbaxud OtmQ== X-Gm-Message-State: AOJu0YwZkM5BbJpWMty34ikQKbJB20cY5fwAz11T5JSDmO5XamT1T2gH yfmu1/2RZXmvHqvVfSdREWsHPw== X-Google-Smtp-Source: AGHT+IF20t0VWjgac0dRIZCA1JkcXVtwNJBGTcAuMHzFzEm0RhGR7NzU38i0clAtj6I8+ULrxoVFmw== X-Received: by 2002:a0c:ebc3:0:b0:67a:2129:c05a with SMTP id k3-20020a0cebc3000000b0067a2129c05amr14629363qvq.53.1701204590697; Tue, 28 Nov 2023 12:49:50 -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 d11-20020a0cfe8b000000b0067a56b6adfesm1056863qvs.71.2023.11.28.12.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:49:50 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, alex.williamson@redhat.com, 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, jasowang@redhat.com, jernej.skrabec@gmail.com, jgg@ziepe.ca, jonathanh@nvidia.com, joro@8bytes.org, kevin.tian@intel.com, krzysztof.kozlowski@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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, mst@redhat.com, m.szyprowski@samsung.com, netdev@vger.kernel.org, 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, virtualization@lists.linux.dev, wens@csie.org, will@kernel.org, yu-cheng.yu@intel.com Subject: [PATCH 10/16] iommu/rockchip: use page allocation function provided by iommu-pages.h Date: Tue, 28 Nov 2023 20:49:32 +0000 Message-ID: <20231128204938.1453583-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231128204938.1453583-1-pasha.tatashin@soleen.com> References: <20231128204938.1453583-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8271A18001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wmkrc8jak35etn4s5omywef961jebnxz X-HE-Tag: 1701204591-824692 X-HE-Meta: U2FsdGVkX19eFLaBI4CV7jPpcQY3nh1iWn48buuDDG6QrCtYDmu90D+FJPtHJUPj64D5PiE8hIdjd+9VZ5bpcklvnWIBpvb8QlT1luXbHBR+GAcmp/OgFBSmrDtanIATi37fsKRBPZeS6h+TbG2r4ApQ/5V8jzEgE8yJ/YQt+HB2EMB3p7nH6FjInAh2LIBSi2U/jMjtKIzTBjwVg7xXtmBTqirTTMSzCT/Ghc+B22bwSNn8DbW1sdj7nOrh8ESJp6cP4oO6AMMvyC8rUaAtM/SiZ8q47x0AQgfJr9a9HnTU1IwJP/B0sW3yRgtpwRCy5zo+NYCwFbobHCONolQOQLH4NrxKJRIBj+pN/suJWUe7KMfHjflkAiBZCz2d85bvr6Zy/vumlweQxSJqtx6MbDH7yV3oVHZ1LGqBKaatbhUQWC6CiSWbRK2mvlvsNIUo3OxP3ZVac03ZTiL0RILi4dHpM4lyPr4FH+9hw/iLzTbRZvkKzrEPlbXRNT603AGs3PvunI/Y6R8qymzkp6snOf6WcFYRRasZIVxTsoUFex/Caz1FwIrupF18ITP6NIwP64P+sgD0XqDsLCydQcIYpmbYUihFzC7le+L2A3dKNhsVIETt3Wu+VJO/QmzxbNe4vK10hSWIWop+cBXonF1HhjZ2GUaymWBOISvnucJNWiTPanGHxCPIgRfxojZN9bWcQMHUT2eZ8TvbSB17W3qUz+nl/u9t+rMiIKIT4kHP0utc4TE0Vz/4GEPSqHHfA9ZFnIgi2V2W4ZZoOPVfxLnE6B+UVQJ3QtgLXtl/nzFsPiyvlnIhg3KCTUkp6RUcyBXoJPJKVUI9oWGBDIFbJPSWUq6xFHNa9YZMT6D+x0HpydboLTiOfErkrKiwj8oqy7vLlDB7I+aClTSOwt4n6P5P8MZRFDdSRUhywg0gOTkYnDTFmupxl+1dNNnTngXStzaNBUBkdQ2yb8yKIh7WSA2 W0pbz9cb wCQ+PM72E7Z9AJk7Bf45sN20FYl5D2MPYwTWY7+eyE45vdzaFpyS7eudzCJ0iR8WAyCfWZMu8Mq2aweJoMCAM7i0/kFhvErHL8MUx9icU1CQX+A/x8AQd7tdEQnwrzGEdQMU7oCIOyodGbvsfiFA2uHTmf2CywWdPhTecLdo5RBlQDEke15SgOFVuStBLZ5vIZolUtDHoDAYp7nqHC26lD494RglS+gKSA9GiJFURzTA41nvyjuZMjCCTB2sGVc1/VSnVRVsQWOGz9z8kFGSPtKmYsaf1fRDJ107poxy9mARJfXhi/7V6dbvb1yqSs/VKx0tC3Mc/r/472IVvMI+sx1i47usJS9OPXHqUw1XCPKafdKih3BBmuffG4FFdpcdEhFlIT//f8u1V2pUqzrD2/8qhznTjMk+Hfspe/rqmutnE21tMwPkdSNDFhmfhbSW+grc6tkzUwHC6Km0YzNWUy0OqdUrl5gytOm0W 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 --- drivers/iommu/iommufd/iova_bitmap.c | 2 ++ drivers/iommu/rockchip-iommu.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c index 6b8575b93f17..4d5d1be807fe 100644 --- a/drivers/iommu/iommufd/iova_bitmap.c +++ b/drivers/iommu/iommufd/iova_bitmap.c @@ -8,6 +8,8 @@ #include #include +#include "../iommu-pages.h" + #define BITS_PER_PAGE (PAGE_SIZE * BITS_PER_BYTE) /* 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); }