--- zzzz-none-000/linux-3.10.107/arch/powerpc/platforms/ps3/mm.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/powerpc/platforms/ps3/mm.c 2021-02-04 17:41:59.000000000 +0000 @@ -223,6 +223,44 @@ } } +static int ps3_mm_get_repository_highmem(struct mem_region *r) +{ + int result; + + /* Assume a single highmem region. */ + + result = ps3_repository_read_highmem_info(0, &r->base, &r->size); + + if (result) + goto zero_region; + + if (!r->base || !r->size) { + result = -1; + goto zero_region; + } + + r->offset = r->base - map.rm.size; + + DBG("%s:%d: Found high region in repository: %llxh %llxh\n", + __func__, __LINE__, r->base, r->size); + + return 0; + +zero_region: + DBG("%s:%d: No high region in repository.\n", __func__, __LINE__); + + r->size = r->base = r->offset = 0; + return result; +} + +static int ps3_mm_set_repository_highmem(const struct mem_region *r) +{ + /* Assume a single highmem region. */ + + return r ? ps3_repository_write_highmem_info(0, r->base, r->size) : + ps3_repository_write_highmem_info(0, 0, 0); +} + /** * ps3_mm_region_create - create a memory region in the vas * @r: pointer to a struct mem_region to accept initialized values @@ -291,36 +329,7 @@ r->size = r->base = r->offset = 0; map.total = map.rm.size; } -} - -static int ps3_mm_get_repository_highmem(struct mem_region *r) -{ - int result; - - /* Assume a single highmem region. */ - - result = ps3_repository_read_highmem_info(0, &r->base, &r->size); - - if (result) - goto zero_region; - - if (!r->base || !r->size) { - result = -1; - goto zero_region; - } - - r->offset = r->base - map.rm.size; - - DBG("%s:%d: Found high region in repository: %llxh %llxh\n", - __func__, __LINE__, r->base, r->size); - - return 0; - -zero_region: - DBG("%s:%d: No high region in repository.\n", __func__, __LINE__); - - r->size = r->base = r->offset = 0; - return result; + ps3_mm_set_repository_highmem(NULL); } /*============================================================================*/ @@ -1210,8 +1219,12 @@ /* Check if we got the highmem region from an earlier boot step */ - if (ps3_mm_get_repository_highmem(&map.r1)) - ps3_mm_region_create(&map.r1, map.total - map.rm.size); + if (ps3_mm_get_repository_highmem(&map.r1)) { + result = ps3_mm_region_create(&map.r1, map.total - map.rm.size); + + if (!result) + ps3_mm_set_repository_highmem(&map.r1); + } /* correct map.total for the real total amount of memory we use */ map.total = map.rm.size + map.r1.size;