All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: [PATCH 04/10] iommu/ipmmu-vmsa: Add light version of Linux's ipmmu_features
Date: Sat, 27 Nov 2021 19:51:39 +0200	[thread overview]
Message-ID: <1638035505-16931-5-git-send-email-olekstysh@gmail.com> (raw)
In-Reply-To: <1638035505-16931-1-git-send-email-olekstysh@gmail.com>

From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

This is a prereq work needed to add support for S4 series easily
in the future.

We don't need to pull the whole struct and all instances as Xen
driver doesn't support old Arm32 based Gen2 SoCs, so there is no
point in keeping all differences between Gen2 and Gen3 here.
All what we need is a minimal support to be able to operate with
Gen3 and new S4.

Add Gen3 specific info with only two fields (number_of_contexts and
num_utlbs) for now, the subsequent patches will add remaining bits.

No change in behavior.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
 xen/drivers/passthrough/arm/ipmmu-vmsa.c | 54 +++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
index 1b94af2..369be4c 100644
--- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
+++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
@@ -71,9 +71,9 @@
  * R-Car Gen3 SoCs make use of up to 8 IPMMU contexts (sets of page table) and
  * these can be managed independently. Each context is mapped to one Xen domain.
  */
-#define IPMMU_CTX_MAX     8
+#define IPMMU_CTX_MAX     8U
 /* R-Car Gen3 SoCs make use of up to 48 micro-TLBs per IPMMU device. */
-#define IPMMU_UTLB_MAX    48
+#define IPMMU_UTLB_MAX    48U
 
 /* IPMMU context supports IPA size up to 40 bit. */
 #define IPMMU_MAX_P2M_IPA_BITS    40
@@ -106,17 +106,22 @@ struct ipmmu_vmsa_xen_device {
     struct ipmmu_vmsa_device *mmu;
 };
 
+struct ipmmu_features {
+    unsigned int number_of_contexts;
+    unsigned int num_utlbs;
+};
+
 /* Root/Cache IPMMU device's information */
 struct ipmmu_vmsa_device {
     struct device *dev;
     void __iomem *base;
     struct ipmmu_vmsa_device *root;
     struct list_head list;
-    unsigned int num_utlbs;
     unsigned int num_ctx;
     spinlock_t lock;    /* Protects ctx and domains[] */
     DECLARE_BITMAP(ctx, IPMMU_CTX_MAX);
     struct ipmmu_vmsa_domain *domains[IPMMU_CTX_MAX];
+    const struct ipmmu_features *features;
 };
 
 /*
@@ -727,6 +732,11 @@ static int ipmmu_init_platform_device(struct device *dev,
     return 0;
 }
 
+static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
+    .number_of_contexts = 8,
+    .num_utlbs = 48,
+};
+
 static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu)
 {
     unsigned int i;
@@ -798,6 +808,27 @@ static __init bool ipmmu_stage2_supported(void)
     return stage2_supported;
 }
 
+static const struct dt_device_match ipmmu_dt_match[] __initconst =
+{
+    {
+        .compatible = "renesas,ipmmu-r8a7795",
+        .data = &ipmmu_features_rcar_gen3,
+    },
+    {
+        .compatible = "renesas,ipmmu-r8a77965",
+        .data = &ipmmu_features_rcar_gen3,
+    },
+    {
+        .compatible = "renesas,ipmmu-r8a7796",
+        .data = &ipmmu_features_rcar_gen3,
+    },
+    {
+        .compatible = "renesas,ipmmu-r8a77961",
+        .data = &ipmmu_features_rcar_gen3,
+    },
+    { /* sentinel */ },
+};
+
 /*
  * This function relies on the fact that Root IPMMU device is being probed
  * the first. If not the case, it denies further Cache IPMMU device probes
@@ -806,6 +837,7 @@ static __init bool ipmmu_stage2_supported(void)
  */
 static int ipmmu_probe(struct dt_device_node *node)
 {
+    const struct dt_device_match *match;
     struct ipmmu_vmsa_device *mmu;
     uint64_t addr, size;
     int irq, ret;
@@ -817,9 +849,12 @@ static int ipmmu_probe(struct dt_device_node *node)
         return -ENOMEM;
     }
 
+    match = dt_match_node(ipmmu_dt_match, node);
+    ASSERT(match);
+    mmu->features = match->data;
+
     mmu->dev = &node->dev;
-    mmu->num_utlbs = IPMMU_UTLB_MAX;
-    mmu->num_ctx = IPMMU_CTX_MAX;
+    mmu->num_ctx = min(IPMMU_CTX_MAX, mmu->features->number_of_contexts);
     spin_lock_init(&mmu->lock);
     bitmap_zero(mmu->ctx, IPMMU_CTX_MAX);
 
@@ -1296,15 +1331,6 @@ static const struct iommu_ops ipmmu_iommu_ops =
     .add_device      = ipmmu_add_device,
 };
 
-static const struct dt_device_match ipmmu_dt_match[] __initconst =
-{
-    DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a7795"),
-    DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a77965"),
-    DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a7796"),
-    DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a77961"),
-    { /* sentinel */ },
-};
-
 static __init int ipmmu_init(struct dt_device_node *node, const void *data)
 {
     int ret;
-- 
2.7.4



  parent reply	other threads:[~2021-11-27 17:52 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-27 17:51 [PATCH 00/10] Add support for Renesas R-Car S4 IPMMU and other misc changes Oleksandr Tyshchenko
2021-11-27 17:51 ` [PATCH 01/10] iommu/ipmmu-vmsa: Remove all unused register definitions Oleksandr Tyshchenko
2021-12-14 12:05   ` Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 02/10] iommu/ipmmu-vmsa: Add helper functions for MMU "context" registers Oleksandr Tyshchenko
2021-12-14 12:05   ` Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 03/10] iommu/ipmmu-vmsa: Add helper functions for "uTLB" registers Oleksandr Tyshchenko
2021-12-14 12:05   ` Yoshihiro Shimoda
2021-11-27 17:51 ` Oleksandr Tyshchenko [this message]
2021-12-14 12:05   ` [PATCH 04/10] iommu/ipmmu-vmsa: Add light version of Linux's ipmmu_features Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 05/10] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro Oleksandr Tyshchenko
2021-12-14 12:06   ` Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 06/10] iommu/ipmmu-vmsa: Add utlb_offset_base Oleksandr Tyshchenko
2021-12-14 12:07   ` Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 07/10] iommu/ipmmu-vmsa: Add Renesas R8A779F0 (R-Car S4) support Oleksandr Tyshchenko
2021-12-14 12:10   ` Yoshihiro Shimoda
2021-12-14 12:38     ` Oleksandr
2021-11-27 17:51 ` [PATCH 08/10] iommu/ipmmu-vmsa: Set IPMMU bit IMSCTLR_USE_SECGRP to 0 Oleksandr Tyshchenko
2021-12-15  2:44   ` Volodymyr Babchuk
2021-12-16 12:48   ` Yoshihiro Shimoda
2021-12-16 16:45     ` Oleksandr
2021-11-27 17:51 ` [PATCH 09/10] iommu/ipmmu-vmsa: Use refcount for the micro-TLBs Oleksandr Tyshchenko
2021-12-15  2:58   ` Volodymyr Babchuk
2021-12-15 13:41     ` Oleksandr
2021-12-16 13:20   ` Yoshihiro Shimoda
2021-11-27 17:51 ` [PATCH 10/10] iommu/arm: Remove code duplication in all IOMMU drivers Oleksandr Tyshchenko
2021-12-15  3:03   ` Volodymyr Babchuk
2021-12-16 13:22   ` Yoshihiro Shimoda
2021-12-13 10:05 ` [PATCH 00/10] Add support for Renesas R-Car S4 IPMMU and other misc changes Oleksandr
2021-12-13 10:11   ` Julien Grall
2021-12-13 11:38     ` Oleksandr
2022-01-26 16:20 ` Julien Grall
2022-01-26 16:28   ` Oleksandr Tyshchenko
2022-01-26 16:30     ` Julien Grall

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=1638035505-16931-5-git-send-email-olekstysh@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.