[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][PATCH v10 15/20] arm/asm/setup.h: Update struct map_range_data to add rangeset.


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Fri, 25 Aug 2023 01:02:17 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xLOhd+eCdzsILcS2OSpdjdN9Er/z7fDSt3+c00KeABo=; b=PKJAFiY0PDzzDqhxfyOKTzrkVgqqOljxXLtiVr2SIpAbZIzvRXrlToN5VaDcjqRHkx31XTL2S9UR/CRR0Nv1o3gJljTIgRO+s4JWedAwqGqcbl7ht1OUFUY5xlJABMJdKo6T7plk/F3znaluSEBGoCap6Z8HTA8Gxs5s7IX9xYKpE80ibDmTZPpaTUyJ2QtuNdmaxA+u1HEsdpywDYC4GnedmHJPfAAvpORPuEeq2b1jglcfKqdxK918dqgu5hSct/H8BJSNU8XA0nDxwdtvtKJrtIrvtdryiVkvYGvFfgX50q7OAnVcsJ/oGO+J+TsBq0hv29ZswHo9wv79xaKHeQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSsOTsv5SYkcalJtf1erOn8A0zxKP7qkGcOMnuhdQEbq2fn8KSO3+B829NqxuGywbWClB/pR8l9hKRimYaqpcdO48Eg+ve+BeblvGDY4vs6WxTtKZvcJ0+odIRV/bMhu0N6liBXZRyPEHqWQ5CODZMwNiQpmvnzXu9v0RsFYcuOmke7tTtX54S3KFYiWBEMi0XUQ7DdkLZks92rpim5gqwFb8K3T0hAEUxoRaGKqkDQGQGVqC0KSaQOh18FheRm05zUzzGpSq6rQFVUQ2VrHEN2srFLVkwiYkt1+u0q344YilNcylTMqPhCDNywS9r1gz7Zun7QlugweZ5CmGsd9JA==
  • Cc: <michal.orzel@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 25 Aug 2023 08:03:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add rangesets for IRQs and IOMEMs. This was done to accommodate dynamic overlay
node addition/removal operations. With overlay operations, new IRQs and IOMEMs
are added in dt_host and routed. While removing overlay nodes, nodes are remove
from dt_host and their IRQs and IOMEMs routing is also removed. Storing IRQs and
IOMEMs in the rangeset will avoid re-parsing the device tree nodes to get the
IOMEM and IRQ ranges for overlay remove ops.

Dynamic overlay node add/remove will be introduced in follow-up patches.

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
 xen/arch/arm/device.c            | 43 +++++++++++++++++++++++++-------
 xen/arch/arm/domain_build.c      |  4 +--
 xen/arch/arm/include/asm/setup.h |  5 +++-
 3 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 857f171a27..9df37abac8 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -165,6 +165,14 @@ int map_range_to_domain(const struct dt_device_node *dev,
     dt_dprintk("  - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=%x\n",
                addr, addr + len, mr_data->p2mt);
 
+    if ( mr_data->iomem_ranges )
+    {
+        res = rangeset_add_range(mr_data->iomem_ranges, paddr_to_pfn(addr),
+                                 paddr_to_pfn(PAGE_ALIGN(addr + len - 1)));
+        if ( res )
+            return res;
+    }
+
     return 0;
 }
 
@@ -178,9 +186,10 @@ int map_range_to_domain(const struct dt_device_node *dev,
  */
 int handle_device_interrupts(struct domain *d,
                              struct dt_device_node *dev,
-                             bool need_mapping)
+                             bool need_mapping,
+                             struct rangeset *irq_ranges)
 {
-    unsigned int i, nirq;
+    unsigned int i, nirq, irq;
     int res;
     struct dt_raw_irq rirq;
 
@@ -208,17 +217,24 @@ int handle_device_interrupts(struct domain *d,
             continue;
         }
 
-        res = platform_get_irq(dev, i);
-        if ( res < 0 )
+        irq = platform_get_irq(dev, i);
+        if ( irq < 0 )
         {
             printk(XENLOG_ERR "Unable to get irq %u for %s\n",
                    i, dt_node_full_name(dev));
-            return res;
+            return irq;
         }
 
-        res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev));
+        res = map_irq_to_domain(d, irq, need_mapping, dt_node_name(dev));
         if ( res )
             return res;
+
+        if ( irq_ranges )
+        {
+            res = rangeset_add_singleton(irq_ranges, irq);
+            if ( res )
+                return res;
+        }
     }
 
     return 0;
@@ -249,6 +265,11 @@ static int map_dt_irq_to_domain(const struct 
dt_device_node *dev,
     }
 
     res = map_irq_to_domain(d, irq, !mr_data->skip_mapping, dt_node_name(dev));
+    if ( res )
+        return res;
+
+    if ( mr_data->irq_ranges )
+        res = rangeset_add_singleton(mr_data->irq_ranges, irq);
 
     return res;
 }
@@ -289,7 +310,8 @@ static int map_device_children(const struct dt_device_node 
*dev,
  *  - Assign the device to the guest if it's protected by an IOMMU
  *  - Map the IRQs and iomem regions to DOM0
  */
-int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t 
p2mt)
+int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t 
p2mt,
+                  struct rangeset *iomem_ranges, struct rangeset *irq_ranges)
 {
     unsigned int naddr;
     unsigned int i;
@@ -304,10 +326,13 @@ int handle_device(struct domain *d, struct dt_device_node 
*dev, p2m_type_t p2mt)
      *     pci_host_bridge_mappings().
      */
     struct map_range_data mr_data = {
+        .d = d,
         .p2mt = p2mt,
         .skip_mapping = !own_device ||
                         (is_pci_passthrough_enabled() &&
-                        (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE))
+                        (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE)),
+        .iomem_ranges = iomem_ranges,
+        .irq_ranges = irq_ranges
     };
 
     naddr = dt_number_of_address(dev);
@@ -341,7 +366,7 @@ int handle_device(struct domain *d, struct dt_device_node 
*dev, p2m_type_t p2mt)
         }
     }
 
-    res = handle_device_interrupts(d, dev, own_device);
+    res = handle_device_interrupts(d, dev, own_device, irq_ranges);
     if ( res < 0 )
         return res;
 
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 63ca9ea5fe..8e9dd0c373 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2401,7 +2401,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
                "WARNING: Path %s is reserved, skip the node as we may re-use 
the path.\n",
                path);
 
-    res = handle_device(d, node, p2mt);
+    res = handle_device(d, node, p2mt, NULL, NULL);
     if ( res)
         return res;
 
@@ -2744,7 +2744,7 @@ static int __init handle_passthrough_prop(struct 
kernel_info *kinfo,
         return -EINVAL;
     }
 
-    res = handle_device_interrupts(kinfo->d, node, true);
+    res = handle_device_interrupts(kinfo->d, node, true, NULL);
     if ( res < 0 )
         return res;
 
diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
index 1a052ed924..2dc6d4c1a6 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -113,6 +113,9 @@ struct map_range_data
     p2m_type_t p2mt;
     /* Set if mapping of the memory ranges must be skipped. */
     bool skip_mapping;
+    /* Rangeset to store IRQs and IOMEM for overlay nodes. */
+    struct rangeset *iomem_ranges;
+    struct rangeset *irq_ranges;
 };
 
 extern struct bootinfo bootinfo;
@@ -169,7 +172,7 @@ int handle_device(struct domain *d, struct dt_device_node 
*dev, p2m_type_t p2mt,
                   struct rangeset *iomem_ranges, struct rangeset *irq_ranges);
 
 int handle_device_interrupts(struct domain *d, struct dt_device_node *dev,
-                             bool need_mapping);
+                             bool need_mapping, struct rangeset *irq_ranges);
 
 int map_range_to_domain(const struct dt_device_node *dev,
                         uint64_t addr, uint64_t len, void *data);
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.