Linux IOMMU Development
 help / color / mirror / Atom feed
From: Sam Protsenko <semen.protsenko@linaro.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Janghyuck Kim <janghyuck.kim@samsung.com>,
	Cho KyongHo <pullip.cho@samsung.com>,
	Daniel Mentz <danielmentz@google.com>,
	David Virag <virag.david003@gmail.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/7] iommu/exynos: Reuse SysMMU constants for page size and order
Date: Mon, 11 Jul 2022 02:05:57 +0300	[thread overview]
Message-ID: <20220710230603.13526-2-semen.protsenko@linaro.org> (raw)
In-Reply-To: <20220710230603.13526-1-semen.protsenko@linaro.org>

Using SZ_4K in context of SysMMU driver is better than using PAGE_SIZE,
as PAGE_SIZE might have different value on different platforms. Though
it would be even better to use more specific constants, already existing
in SysMMU driver. Make the code more strict by using SPAGE_ORDER and
SPAGE_SIZE constants.

It also makes sense, as __sysmmu_tlb_invalidate_entry() also uses
SPAGE_* constants for further calculations with num_inv param, so it's
logical that num_inv should be previously calculated using also SPAGE_*
values.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
  - (none) This patch is new and added in v2

 drivers/iommu/exynos-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 79729892eb48..8f80aaa35092 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -340,7 +340,7 @@ static void __sysmmu_set_ptbase(struct sysmmu_drvdata *data, phys_addr_t pgd)
 	if (MMU_MAJ_VER(data->version) < 5)
 		writel(pgd, data->sfrbase + REG_PT_BASE_ADDR);
 	else
-		writel(pgd / SZ_4K, data->sfrbase + REG_V5_PT_BASE_PFN);
+		writel(pgd >> SPAGE_ORDER, data->sfrbase + REG_V5_PT_BASE_PFN);
 
 	__sysmmu_tlb_invalidate(data);
 }
@@ -550,7 +550,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
 		 * 64KB page can be one of 16 consecutive sets.
 		 */
 		if (MMU_MAJ_VER(data->version) == 2)
-			num_inv = min_t(unsigned int, size / SZ_4K, 64);
+			num_inv = min_t(unsigned int, size / SPAGE_SIZE, 64);
 
 		if (sysmmu_block(data)) {
 			__sysmmu_tlb_invalidate_entry(data, iova, num_inv);
-- 
2.30.2


  reply	other threads:[~2022-07-10 23:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-10 23:05 [PATCH v2 0/7] iommu/exynos: Add basic support for SysMMU v7 Sam Protsenko
2022-07-10 23:05 ` Sam Protsenko [this message]
2022-07-12 15:39   ` [PATCH v2 1/7] iommu/exynos: Reuse SysMMU constants for page size and order Marek Szyprowski
2022-07-12 16:19   ` Krzysztof Kozlowski
2022-07-10 23:05 ` [PATCH v2 2/7] iommu/exynos: Handle failed IOMMU device registration properly Sam Protsenko
2022-07-12 15:40   ` Marek Szyprowski
2022-07-12 16:20   ` Krzysztof Kozlowski
2022-07-10 23:05 ` [PATCH v2 3/7] iommu/exynos: Set correct dma mask for SysMMU v5+ Sam Protsenko
2022-07-12 16:21   ` Krzysztof Kozlowski
2022-07-10 23:06 ` [PATCH v2 4/7] iommu/exynos: Use lookup based approach to access registers Sam Protsenko
2022-07-12 15:43   ` Marek Szyprowski
2022-07-12 16:24   ` Robin Murphy
2022-07-14 13:11     ` Sam Protsenko
2022-07-12 16:52   ` Krzysztof Kozlowski
2022-07-14 13:15     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 5/7] iommu/exynos: Check if SysMMU v7 has VM registers Sam Protsenko
2022-07-12 15:47   ` Marek Szyprowski
2022-07-14 13:25     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 6/7] iommu/exynos: Add SysMMU v7 register sets Sam Protsenko
2022-07-12 17:00   ` Robin Murphy
2022-07-14 13:57     ` Sam Protsenko
2022-07-10 23:06 ` [PATCH v2 7/7] iommu/exynos: Enable default VM instance on SysMMU v7 Sam Protsenko
2022-07-12 15:53   ` Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220710230603.13526-2-semen.protsenko@linaro.org \
    --to=semen.protsenko@linaro.org \
    --cc=danielmentz@google.com \
    --cc=iommu@lists.linux.dev \
    --cc=janghyuck.kim@samsung.com \
    --cc=joro@8bytes.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=pullip.cho@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=sumit.semwal@linaro.org \
    --cc=virag.david003@gmail.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox