OSDN Git Service

of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / of / address.c
index cd53fe4..b3bf876 100644 (file)
@@ -260,7 +260,7 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser,
        if (!parser->range || parser->range + parser->np > parser->end)
                return NULL;
 
-       range->pci_space = parser->range[0];
+       range->pci_space = be32_to_cpup(parser->range);
        range->flags = of_bus_pci_get_flags(parser->range);
        range->pci_addr = of_read_number(parser->range + 1, ns);
        range->cpu_addr = of_translate_address(parser->node,
@@ -485,9 +485,10 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
        int rone;
        u64 offset = OF_BAD_ADDR;
 
-       /* Normally, an absence of a "ranges" property means we are
+       /*
+        * Normally, an absence of a "ranges" property means we are
         * crossing a non-translatable boundary, and thus the addresses
-        * below the current not cannot be converted to CPU physical ones.
+        * below the current cannot be converted to CPU physical ones.
         * Unfortunately, while this is very clear in the spec, it's not
         * what Apple understood, and they do have things like /uni-n or
         * /ht nodes with no "ranges" property and a lot of perfectly
@@ -1008,12 +1009,16 @@ EXPORT_SYMBOL_GPL(of_dma_get_range);
  * @np:        device node
  *
  * It returns true if "dma-coherent" property was found
- * for this device in DT.
+ * for this device in the DT, or if DMA is coherent by
+ * default for OF devices on the current platform.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
        struct device_node *node = of_node_get(np);
 
+       if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
+               return true;
+
        while (node) {
                if (of_property_read_bool(node, "dma-coherent")) {
                        of_node_put(node);