diff mbox

[RFC,for-4.8,v2,6/7] xen/device-tree: Add an mmio-sram bus

Message ID 1464960552-6645-7-git-send-email-edgar.iglesias@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Edgar E. Iglesias June 3, 2016, 1:29 p.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Add an mmio-sram bus that prevents sram sub areas from
being re-mapped. These sub-areas describe allocations and
not mappings.

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

Comments

Julien Grall June 6, 2016, 6:05 p.m. UTC | #1
Hi Edgar,

On 03/06/16 14:29, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Add an mmio-sram bus that prevents sram sub areas from
> being re-mapped. These sub-areas describe allocations and
> not mappings.

mmio-sram is not a bus and the region below should point to a valid 
physical address.

So why do you want that?

Regards,
Edgar E. Iglesias June 8, 2016, 12:21 a.m. UTC | #2
On Mon, Jun 06, 2016 at 07:05:20PM +0100, Julien Grall wrote:
> Hi Edgar,
> 
> On 03/06/16 14:29, Edgar E. Iglesias wrote:
> >From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> >
> >Add an mmio-sram bus that prevents sram sub areas from
> >being re-mapped. These sub-areas describe allocations and
> >not mappings.
> 
> mmio-sram is not a bus and the region below should point to a valid physical
> address.
> 
> So why do you want that?

Hi,

Yes, I briefly mentioned this in the cover letter. It's a hack
to avoid the mapping of sub allocations. The regions under mmio-sram
point to valid addresses but they point into the same space that
the outer mmio-sram node maps in. They also don't need to be page
aligned. AFAICT, Xen should ignore these sub-regions allthough I
think things work anyway (at least with my dts).

Maybe I should just drop this until we have a real problem or
come up with a nicer way of dealing with this.

Cheers,
Edgar





> 
> Regards,
> 
> -- 
> Julien Grall
Julien Grall June 8, 2016, 8:52 a.m. UTC | #3
Hi Edgar,

On 08/06/2016 01:21, Edgar E. Iglesias wrote:
> On Mon, Jun 06, 2016 at 07:05:20PM +0100, Julien Grall wrote:
>> Hi Edgar,
>>
>> On 03/06/16 14:29, Edgar E. Iglesias wrote:
>>> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>>>
>>> Add an mmio-sram bus that prevents sram sub areas from
>>> being re-mapped. These sub-areas describe allocations and
>>> not mappings.
>>
>> mmio-sram is not a bus and the region below should point to a valid physical
>> address.
>>
>> So why do you want that?
>
> Hi,
>
> Yes, I briefly mentioned this in the cover letter. It's a hack
> to avoid the mapping of sub allocations. The regions under mmio-sram
> point to valid addresses but they point into the same space that
> the outer mmio-sram node maps in. They also don't need to be page
> aligned. AFAICT, Xen should ignore these sub-regions allthough I
> think things work anyway (at least with my dts).

Sorry I haven't fully read the cover letter. I agree that going through 
those sub-regions are pointless because it already mapped by the parent.

However, it is harmless as they should be part of the parent MMIO. It 
also makes the code simpler.

>
> Maybe I should just drop this until we have a real problem or
> come up with a nicer way of dealing with this.

Sounds good to me.

Regards,
diff mbox

Patch

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index fbee354..698d4da 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -616,10 +616,47 @@  static int dt_bus_pci_translate(__be32 *addr, u64 offset, int na)
 }
 
 /*
+ * MMIO-SRAM bus specific translator
+ */
+
+static bool_t dt_bus_mmio_sram_match(const struct dt_device_node *np)
+{
+    static const struct dt_device_match match[] __initconst =
+    {
+        DT_MATCH_COMPATIBLE("mmio-sram"),
+        { /* sentinel */ },
+    };
+
+    return dt_match_node(match, np) != NULL;
+}
+
+static void dt_bus_mmio_sram_count_cells(const struct dt_device_node *np,
+					 int *addrc, int *sizec)
+{
+    /*
+     * Child areas describe allocations, not mappings. Don't map anything.
+     */
+    if (addrc)
+        *addrc = 0;
+    if (sizec)
+        *sizec = 0;
+}
+
+/*
  * Array of bus specific translators
  */
 static const struct dt_bus dt_busses[] =
 {
+    /* MMIO-SRAM */
+    {
+        .name = "mmio-sram",
+        .addresses = "reg",
+        .match = dt_bus_mmio_sram_match,
+        .count_cells = dt_bus_mmio_sram_count_cells,
+        .map = dt_bus_default_map,
+        .translate = dt_bus_default_translate,
+        .get_flags = dt_bus_default_get_flags,
+    },
     /* PCI */
     {
         .name = "pci",