diff mbox

[v4,7/7] xen/arm: Map mmio-sram nodes as un-cached memory

Message ID 1474656802-24081-8-git-send-email-edgar.iglesias@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Edgar E. Iglesias Sept. 23, 2016, 6:53 p.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Map mmio-sram nodes as un-cached memory. If the node
has set the no-memory-wc property, we map it as device.

The DTS bindings for mmio-sram nodes can be found in the
Linux tree under Documentation/devicetree/bindings/sram/sram.txt.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/domain_build.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Julien Grall Sept. 27, 2016, 11:52 p.m. UTC | #1
Hi Edgar,

On 23/09/2016 11:53, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Map mmio-sram nodes as un-cached memory. If the node
> has set the no-memory-wc property, we map it as device.
>
> The DTS bindings for mmio-sram nodes can be found in the
> Linux tree under Documentation/devicetree/bindings/sram/sram.txt.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 0c30121..f1c5526 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -48,6 +48,20 @@  struct map_range_data
     p2m_type_t p2mt;
 };
 
+static const struct dt_device_match dev_map_attrs[] __initconst =
+{
+    {
+        __DT_MATCH_COMPATIBLE("mmio-sram"),
+        __DT_MATCH_PROP("no-memory-wc"),
+        .data = (void *) (uintptr_t) p2m_mmio_direct_dev,
+    },
+    {
+        __DT_MATCH_COMPATIBLE("mmio-sram"),
+        .data = (void *) (uintptr_t) p2m_mmio_direct_nc,
+    },
+    { /* sentinel */ },
+};
+
 //#define DEBUG_11_ALLOCATION
 #ifdef DEBUG_11_ALLOCATION
 # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args)
@@ -1145,6 +1159,21 @@  static int handle_device(struct domain *d, struct dt_device_node *dev,
     return 0;
 }
 
+static p2m_type_t lookup_map_attr(struct dt_device_node *node,
+                                  p2m_type_t parent_p2mt)
+{
+    const struct dt_device_match *r;
+
+    /* Search and if nothing matches, use the parent's attributes.  */
+    r = dt_match_node(dev_map_attrs, node);
+
+    /*
+     * If this node does not dictate specific mapping attributes,
+     * it inherits its parent's attributes.
+     */
+    return r ? (uintptr_t) r->data : parent_p2mt;
+}
+
 static int handle_node(struct domain *d, struct kernel_info *kinfo,
                        struct dt_device_node *node,
                        p2m_type_t p2mt)
@@ -1234,6 +1263,7 @@  static int 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);
 
+    p2mt = lookup_map_attr(node, p2mt);
     res = handle_device(d, node, p2mt);
     if ( res)
         return res;