LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/mm/radix: Update Radix tree size as per ISA 3.0
@ 2016-06-16  3:21 Aneesh Kumar K.V
  2016-06-16  5:10 ` Balbir Singh
  0 siblings, 1 reply; 2+ messages in thread
From: Aneesh Kumar K.V @ 2016-06-16  3:21 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

ISA 3.0 updated it to be encoded as Radix tree size = 2^(RTS + 31). We
have it encoded as 2^(RTS + 28). Add a helper with the correct encoding
and use it instead of opencoding.

Fixes commit 2bfd65e45e87 ("powerpc/mm/radix: Add radix callbacks for
early init routine ")

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/64/radix.h | 15 +++++++++++++++
 arch/powerpc/mm/mmu_context_book3s64.c     |  2 +-
 arch/powerpc/mm/pgtable-radix.c            |  9 +++------
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
index 0d980de55c40..cdf791af8ab2 100644
--- a/arch/powerpc/include/asm/book3s/64/radix.h
+++ b/arch/powerpc/include/asm/book3s/64/radix.h
@@ -260,5 +260,20 @@ extern void radix__vmemmap_remove_mapping(unsigned long start,
 
 extern int radix__map_kernel_page(unsigned long ea, unsigned long pa,
 				 pgprot_t flags, unsigned int psz);
+
+static inline unsigned long radix__get_rts_value(void)
+{
+	unsigned long rts_field;
+	/*
+	 * we support 52 bits, hence 52-31 = 21, 0b10101
+	 * RTS encoding details
+	 * bits 0 - 3 of rts -> bits 6 - 8 unsigned long
+	 * bits 4 - 5 of rts -> bits 62 - 63 of unsigned long
+	 */
+	rts_field = (0x5UL << 5); /* 6 - 8 bits */
+	rts_field |= (0x2UL << 61);
+
+	return rts_field;
+}
 #endif /* __ASSEMBLY__ */
 #endif
diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index 78ebc3877530..d48067bf4b24 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -65,7 +65,7 @@ static int radix__init_new_context(struct mm_struct *mm, int index)
 	/*
 	 * set the process table entry,
 	 */
-	rts_field = 3ull << PPC_BITLSHIFT(2);
+	rts_field = radix__get_rts_value();
 	process_tb[index].prtb0 = cpu_to_be64(rts_field | __pa(mm->pgd) | RADIX_PGD_INDEX_SIZE);
 	return 0;
 }
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index 85da0212b276..8a25877b96bc 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -181,9 +181,8 @@ redo:
 	process_tb = early_alloc_pgtable(1UL << PRTB_SIZE_SHIFT);
 	/*
 	 * Fill in the process table.
-	 * we support 52 bits, hence 52-28 = 24, 11000
 	 */
-	rts_field = 3ull << PPC_BITLSHIFT(2);
+	rts_field = radix__get_rts_value();
 	process_tb->prtb0 = cpu_to_be64(rts_field | __pa(init_mm.pgd) | RADIX_PGD_INDEX_SIZE);
 	/*
 	 * Fill in the partition table. We are suppose to use effective address
@@ -197,10 +196,8 @@ redo:
 static void __init radix_init_partition_table(void)
 {
 	unsigned long rts_field;
-	/*
-	 * we support 52 bits, hence 52-28 = 24, 11000
-	 */
-	rts_field = 3ull << PPC_BITLSHIFT(2);
+
+	rts_field = radix__get_rts_value();
 
 	BUILD_BUG_ON_MSG((PATB_SIZE_SHIFT > 24), "Partition table size too large.");
 	partition_tb = early_alloc_pgtable(1UL << PATB_SIZE_SHIFT);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/mm/radix: Update Radix tree size as per ISA 3.0
  2016-06-16  3:21 [PATCH] powerpc/mm/radix: Update Radix tree size as per ISA 3.0 Aneesh Kumar K.V
@ 2016-06-16  5:10 ` Balbir Singh
  0 siblings, 0 replies; 2+ messages in thread
From: Balbir Singh @ 2016-06-16  5:10 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev



On 16/06/16 13:21, Aneesh Kumar K.V wrote:
> ISA 3.0 updated it to be encoded as Radix tree size = 2^(RTS + 31). We
> have it encoded as 2^(RTS + 28). Add a helper with the correct encoding
> and use it instead of opencoding.
> 
> Fixes commit 2bfd65e45e87 ("powerpc/mm/radix: Add radix callbacks for
> early init routine ")
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  arch/powerpc/include/asm/book3s/64/radix.h | 15 +++++++++++++++
>  arch/powerpc/mm/mmu_context_book3s64.c     |  2 +-
>  arch/powerpc/mm/pgtable-radix.c            |  9 +++------
>  3 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
> index 0d980de55c40..cdf791af8ab2 100644
> --- a/arch/powerpc/include/asm/book3s/64/radix.h
> +++ b/arch/powerpc/include/asm/book3s/64/radix.h
> @@ -260,5 +260,20 @@ extern void radix__vmemmap_remove_mapping(unsigned long start,
>  
>  extern int radix__map_kernel_page(unsigned long ea, unsigned long pa,
>  				 pgprot_t flags, unsigned int psz);
> +
> +static inline unsigned long radix__get_rts_value(void)

How about radix__get_tree_size()?

> +{
> +	unsigned long rts_field;
> +	/*
> +	 * we support 52 bits, hence 52-31 = 21, 0b10101
> +	 * RTS encoding details
> +	 * bits 0 - 3 of rts -> bits 6 - 8 unsigned long
> +	 * bits 4 - 5 of rts -> bits 62 - 63 of unsigned long
> +	 */
> +	rts_field = (0x5UL << 5); /* 6 - 8 bits */
> +	rts_field |= (0x2UL << 61);
> +
> +	return rts_field;
> +}


Looks good otherwise

Reviewed-by: Balbir Singh <bsingharora@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-16  5:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-16  3:21 [PATCH] powerpc/mm/radix: Update Radix tree size as per ISA 3.0 Aneesh Kumar K.V
2016-06-16  5:10 ` Balbir Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox