diff mbox series

[1/3] powerpc/mm: Initialize the HPTE encoding values

Message ID 20190830120712.22971-2-ldufour@linux.ibm.com (mailing list archive)
State Changes Requested
Headers show
Series powerpc/mm: Conditionally call H_BLOCK_REMOVE | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (6ed37b3ef6aef8647b8dad925affa92c4c8cc8a3)
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked

Commit Message

Laurent Dufour Aug. 30, 2019, 12:07 p.m. UTC
Before reading the HPTE encoding values we initialize all of them to -1 (an
invalid value) to later being able to detect the initialized ones.

Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
---
 arch/powerpc/mm/book3s64/hash_utils.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Aneesh Kumar K V Sept. 12, 2019, 1:32 p.m. UTC | #1
Laurent Dufour <ldufour@linux.ibm.com> writes:

> Before reading the HPTE encoding values we initialize all of them to -1 (an
> invalid value) to later being able to detect the initialized ones.
>
> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>

We already do this in mmu_psize_set_default_penc() ?

> ---
>  arch/powerpc/mm/book3s64/hash_utils.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
> index c3bfef08dcf8..2039bc315459 100644
> --- a/arch/powerpc/mm/book3s64/hash_utils.c
> +++ b/arch/powerpc/mm/book3s64/hash_utils.c
> @@ -408,7 +408,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>  {
>  	const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
>  	const __be32 *prop;
> -	int size = 0;
> +	int size = 0, idx, base_idx;
>  
>  	/* We are scanning "cpu" nodes only */
>  	if (type == NULL || strcmp(type, "cpu") != 0)
> @@ -418,6 +418,11 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>  	if (!prop)
>  		return 0;
>  
> +	/* Set all the penc values to invalid */
> +	for (base_idx = 0; base_idx < MMU_PAGE_COUNT; base_idx++)
> +		for (idx = 0; idx < MMU_PAGE_COUNT; idx++)
> +			mmu_psize_defs[base_idx].penc[idx] = -1;
> +
>  	pr_info("Page sizes from device-tree:\n");
>  	size /= 4;
>  	cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
> @@ -426,7 +431,6 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>  		unsigned int slbenc = be32_to_cpu(prop[1]);
>  		unsigned int lpnum = be32_to_cpu(prop[2]);
>  		struct mmu_psize_def *def;
> -		int idx, base_idx;
>  
>  		size -= 3; prop += 3;
>  		base_idx = get_idx_from_shift(base_shift);
> -- 
> 2.23.0
Aneesh Kumar K V Sept. 12, 2019, 1:37 p.m. UTC | #2
On 8/30/19 5:37 PM, Laurent Dufour wrote:
> Before reading the HPTE encoding values we initialize all of them to -1 (an
> invalid value) to later being able to detect the initialized ones.
> 
> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
> ---
>   arch/powerpc/mm/book3s64/hash_utils.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
> index c3bfef08dcf8..2039bc315459 100644
> --- a/arch/powerpc/mm/book3s64/hash_utils.c
> +++ b/arch/powerpc/mm/book3s64/hash_utils.c
> @@ -408,7 +408,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>   {
>   	const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
>   	const __be32 *prop;
> -	int size = 0;
> +	int size = 0, idx, base_idx;
>   
>   	/* We are scanning "cpu" nodes only */
>   	if (type == NULL || strcmp(type, "cpu") != 0)
> @@ -418,6 +418,11 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>   	if (!prop)
>   		return 0;
>   
> +	/* Set all the penc values to invalid */
> +	for (base_idx = 0; base_idx < MMU_PAGE_COUNT; base_idx++)
> +		for (idx = 0; idx < MMU_PAGE_COUNT; idx++)
> +			mmu_psize_defs[base_idx].penc[idx] = -1;
> +
>   	pr_info("Page sizes from device-tree:\n");
>   	size /= 4;
>   	cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
> @@ -426,7 +431,6 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
>   		unsigned int slbenc = be32_to_cpu(prop[1]);
>   		unsigned int lpnum = be32_to_cpu(prop[2]);
>   		struct mmu_psize_def *def;
> -		int idx, base_idx;
>   
>   		size -= 3; prop += 3;
>   		base_idx = get_idx_from_shift(base_shift);
> 

We already do this in mmu_psize_set_default_penc() ?

-aneesh
Laurent Dufour Sept. 13, 2019, 10:56 a.m. UTC | #3
Le 12/09/2019 à 15:37, Aneesh Kumar K.V a écrit :
> On 8/30/19 5:37 PM, Laurent Dufour wrote:
>> Before reading the HPTE encoding values we initialize all of them to -1 (an
>> invalid value) to later being able to detect the initialized ones.
>>
>> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
>> ---
>>   arch/powerpc/mm/book3s64/hash_utils.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/book3s64/hash_utils.c 
>> b/arch/powerpc/mm/book3s64/hash_utils.c
>> index c3bfef08dcf8..2039bc315459 100644
>> --- a/arch/powerpc/mm/book3s64/hash_utils.c
>> +++ b/arch/powerpc/mm/book3s64/hash_utils.c
>> @@ -408,7 +408,7 @@ static int __init htab_dt_scan_page_sizes(unsigned 
>> long node,
>>   {
>>       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
>>       const __be32 *prop;
>> -    int size = 0;
>> +    int size = 0, idx, base_idx;
>>       /* We are scanning "cpu" nodes only */
>>       if (type == NULL || strcmp(type, "cpu") != 0)
>> @@ -418,6 +418,11 @@ static int __init htab_dt_scan_page_sizes(unsigned 
>> long node,
>>       if (!prop)
>>           return 0;
>> +    /* Set all the penc values to invalid */
>> +    for (base_idx = 0; base_idx < MMU_PAGE_COUNT; base_idx++)
>> +        for (idx = 0; idx < MMU_PAGE_COUNT; idx++)
>> +            mmu_psize_defs[base_idx].penc[idx] = -1;
>> +
>>       pr_info("Page sizes from device-tree:\n");
>>       size /= 4;
>>       cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
>> @@ -426,7 +431,6 @@ static int __init htab_dt_scan_page_sizes(unsigned 
>> long node,
>>           unsigned int slbenc = be32_to_cpu(prop[1]);
>>           unsigned int lpnum = be32_to_cpu(prop[2]);
>>           struct mmu_psize_def *def;
>> -        int idx, base_idx;
>>           size -= 3; prop += 3;
>>           base_idx = get_idx_from_shift(base_shift);
>>
> 
> We already do this in mmu_psize_set_default_penc() ?

Correct, I missed that, then this patch is no more needed.
diff mbox series

Patch

diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index c3bfef08dcf8..2039bc315459 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -408,7 +408,7 @@  static int __init htab_dt_scan_page_sizes(unsigned long node,
 {
 	const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
 	const __be32 *prop;
-	int size = 0;
+	int size = 0, idx, base_idx;
 
 	/* We are scanning "cpu" nodes only */
 	if (type == NULL || strcmp(type, "cpu") != 0)
@@ -418,6 +418,11 @@  static int __init htab_dt_scan_page_sizes(unsigned long node,
 	if (!prop)
 		return 0;
 
+	/* Set all the penc values to invalid */
+	for (base_idx = 0; base_idx < MMU_PAGE_COUNT; base_idx++)
+		for (idx = 0; idx < MMU_PAGE_COUNT; idx++)
+			mmu_psize_defs[base_idx].penc[idx] = -1;
+
 	pr_info("Page sizes from device-tree:\n");
 	size /= 4;
 	cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
@@ -426,7 +431,6 @@  static int __init htab_dt_scan_page_sizes(unsigned long node,
 		unsigned int slbenc = be32_to_cpu(prop[1]);
 		unsigned int lpnum = be32_to_cpu(prop[2]);
 		struct mmu_psize_def *def;
-		int idx, base_idx;
 
 		size -= 3; prop += 3;
 		base_idx = get_idx_from_shift(base_shift);