[RAMEN9610-12171] android: ion: add 'ion,hpa_limit' to dts
authorCho KyongHo <pullip.cho@samsung.com>
Mon, 15 Oct 2018 12:21:25 +0000 (21:21 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:16 +0000 (20:23 +0300)
'ion,hpa_limit' property in 'ion-hpa-heap' node specifies the largest
address plus one that HPA can allocate. Therefore ion_hpa_heap should
not allocate pages from the physical address specified by
'ion,hpa_limit' to the end of possible physical address
(0xFFFF_FFFF_FFFF_FFFF).

Change-Id: I0c2cfdca1adbbf1c6602ebb3b68cc0cd5036854e
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/staging/android/ion/ion_fdt_exynos.c

index f4120684a37429fa4cb8318c10bf1691b2fce7ea..b53d6c110d5cc71dd76e529025bdf00b66a4e7b2 100644 (file)
@@ -171,42 +171,53 @@ static bool __init exynos_ion_register_hpa_heaps(unsigned int prot_id_map)
        bool secure = false;
 
        for_each_node_by_name(np, "ion-hpa-heap") {
-               const __be32 *range;
+               int naddr = of_n_addr_cells(np);
+               int nsize = of_n_size_cells(np);
+               phys_addr_t base, size;
+               const __be32 *prop;
                int len;
+               int i;
+
+               /*
+                * If 'ion-hpa-heap' node defines its own range properties,
+                * override the range properties defined by its parent.
+                */
+               prop = of_get_property(np, "#address-cells", NULL);
+               if (prop)
+                       naddr = be32_to_cpup(prop);
+
+               prop = of_get_property(np, "#size-cells", NULL);
+               if (prop)
+                       nsize = be32_to_cpup(prop);
+
+               prop = of_get_property(np, "ion,hpa_limit", &len);
+               if (prop && len > 0 &&
+                   hpa_num_exception_areas < MAX_HPA_EXCEPTION_AREAS) {
+                       base = (phys_addr_t)of_read_number(prop, naddr);
+
+                       i = hpa_num_exception_areas++;
+                       hpa_alloc_exceptions[i][0] = base;
+                       hpa_alloc_exceptions[i][1] = -1;
+               }
+
+               prop = of_get_property(np, "ion,hpa_alloc_exception", &len);
+               if (prop && len > 0) {
+                       int n_area = len / (sizeof(*prop) * (nsize + naddr));
+
+                       n_area += hpa_num_exception_areas;
+                       n_area = min(n_area, MAX_HPA_EXCEPTION_AREAS);
 
-               range = of_get_property(np, "ion,hpa_alloc_exception", &len);
-               if (range && (len > 0)) {
-                       int n_addr = of_n_addr_cells(np);
-                       int n_size = of_n_size_cells(np);
-                       int n_area = len / (sizeof(*range) * (n_size + n_addr));
-                       const void *prop;
-                       phys_addr_t base, size;
-                       int i;
-
-                       /*
-                        * If 'ion-hpa-heap' node defines its own range properties,
-                        * override the range properties defined by its parent.
-                        */
-                       prop = of_get_property(np, "#address-cells", NULL);
-                       if (prop)
-                               n_addr = be32_to_cpup(prop);
-
-                       prop = of_get_property(np, "#size-cells", NULL);
-                       if (prop)
-                               n_size = be32_to_cpup(prop);
-
-                       for (i = hpa_num_exception_areas;
-                            i < min(n_area, MAX_HPA_EXCEPTION_AREAS) ; i++) {
-                               base = (phys_addr_t)of_read_number(range, n_addr);
-                               range += n_addr;
-                               size = (phys_addr_t)of_read_number(range, n_size);
-                               range += n_size;
+                       for (i = hpa_num_exception_areas; i < n_area ; i++) {
+                               base = (phys_addr_t)of_read_number(prop, naddr);
+                               prop += naddr;
+                               size = (phys_addr_t)of_read_number(prop, nsize);
+                               prop += nsize;
 
                                hpa_alloc_exceptions[i][0] = base;
                                hpa_alloc_exceptions[i][1] = base + size - 1;
                        }
 
-                       hpa_num_exception_areas = i;
+                       hpa_num_exception_areas = n_area;
                }
 
                for_each_child_of_node(np, child)