powerpc/mm: Move hpte encode routine to platform specific files
Subsystems (2)
PATCH 1/1 powerpc/mm: Move hpte encode routine to platform specific files
They differ between powernv and pseries. While we are at it copy a version for ps3 too. For now this is same as what we have for pSeries.
--- arch/powerpc/include/asm/book3s/64/mmu-hash.h | 61 --------------------- arch/powerpc/mm/hash_native_64.c | 74 ++++++++++++++++++++++--- arch/powerpc/platforms/ps3/htab.c | 61 +++++++++++++++++++-- arch/powerpc/platforms/pseries/lpar.c | 77 ++++++++++++++++++++++++--- 4 files changed, 194 insertions(+), 79 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu-hash.h +0 -61
@@ -296,67 +296,6 @@ extern unsigned long tce_alloc_start, tce_alloc_end;* If this is the case, mmu_ci_restrictions will be set to 1. */ extern int mmu_ci_restrictions; - -/* -* This computes the AVPN and B fields of the first dword of a HPTE, -* for use when we want to match an existing PTE. The bottom 7 bits -* of the returned value are zero. -*/ -static inline unsigned long hpte_encode_avpn (unsigned long vpn,int psize, -int ssize) -{ -unsigned long v; -/* -* The AVA field omits the low-order 23 bits of the 78 bits VA. -* These bits are not needed in the PTE, because the -* low-order b of these bits are part of the byte offset -* into the virtual page and, if b < 23, the high-order -* 23-b of these bits are always used in selecting the -* PTEGs to be searched -*/ - v = (vpn >> (23 -VPN_SHIFT )) & ~(mmu_psize_defs[psize].avpnm); - v <<=HPTE_V_AVPN_SHIFT ; -if (!cpu_has_feature (CPU_FTR_ARCH_300 )) - v |= ((unsigned long ) ssize) <<HPTE_V_SSIZE_SHIFT ; -return v; -} - -/* -* This function sets the AVPN and L fields of the HPTE appropriately -* using the base page size and actual page size. -*/ -static inline unsigned long hpte_encode_v (unsigned long vpn,int base_psize, -int actual_psize,int ssize) -{ -unsigned long v; - v =hpte_encode_avpn (vpn, base_psize, ssize); -if (actual_psize !=MMU_PAGE_4K ) - v |=HPTE_V_LARGE ; -return v; -} - -/* -* This function sets the ARPN, and LP fields of the HPTE appropriately -* for the page size. We assume the pa is already "clean" that is properly -* aligned for the requested page size -*/ -static inline unsigned long hpte_encode_r (unsigned long pa,int base_psize, -int actual_psize,int ssize) -{ - -if (cpu_has_feature (CPU_FTR_ARCH_300 )) - pa |= ((unsigned long ) ssize) <<HPTE_R_3_0_SSIZE_SHIFT ; - -/* A 4K page needs no special encoding */ -if (actual_psize ==MMU_PAGE_4K ) -return pa &HPTE_R_RPN ; -else { -unsigned int penc = mmu_psize_defs[base_psize].penc[actual_psize]; -unsigned int shift = mmu_psize_defs[actual_psize].shift; -return (pa & ~((1ul << shift) -1 )) | (penc <<LP_SHIFT ); - } -} -/* * Build a VPN_SHIFT bit shifted va given VSID, EA and segment size. */
arch/powerpc/mm/hash_native_64.c +67 -7
116 lines not on this page · raw message
arch/powerpc/platforms/ps3/htab.c +58 -3
79 lines not on this page · raw message
arch/powerpc/platforms/pseries/lpar.c +69 -8
119 lines not on this page · raw message
Signature · 1 line
2.10.2
Quoted 5 lines · Aneesh Kumar K.V
They differ between powernv and pseries. While we are at it copy a version for ps3 too. For now this is same as what we have for pSeries.
Fixes 50de596de8be6 ("powerpc/mm/hash: Add support for Power9 Hash")Signed-off-by Aneesh Kumar K.V <[email protected]>
I have not looked at the patch closely, but do we want all of this duplication. I was wondering if instead of
cpu_has_feature() we could firmware_has_feature() for now
Balbir
Quoted 6 lines · Balbir Singh
Quoted 3 lines · Aneesh Kumar K.V
They differ between powernv and pseries. While we are at it copy a version for ps3 too. For now this is same as what we have for pSeries.
Quoted 9 lines
Quoted 2 lines
Fixes 50de596de8be6 ("powerpc/mm/hash: Add support for Power9 Hash")Signed-off-by Aneesh Kumar K.V <[email protected]>I have not looked at the patch closely, but do we want all of this duplication. I was wondering if instead of
cpu_has_feature()we couldfirmware_has_feature()for now
Basically something like
arch/powerpc/include/asm/book3s/64/mmu-hash.h +4 -2
@@ -282,7 +282,8 @@ static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize,*/ v = (vpn >> (23 -VPN_SHIFT )) & ~(mmu_psize_defs[psize].avpnm); v <<=HPTE_V_AVPN_SHIFT ; -if (!cpu_has_feature (CPU_FTR_ARCH_300 )) +if (!cpu_has_feature (CPU_FTR_ARCH_300 ) || +firmware_has_feature (FW_FEATURE_LPAR )) v |= ((unsigned long ) ssize) <<HPTE_V_SSIZE_SHIFT ;return v; }
@@ -310,7 +311,8 @@ static inline unsigned long hpte_encode_r(unsigned long pa, int base_psize, int actual_psize, int ssize) { - if (cpu_has_feature(CPU_FTR_ARCH_300)) +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && + !firmware_has_feature (FW_FEATURE_LPAR )) pa |= ((unsigned long ) ssize) <<HPTE_R_3_0_SSIZE_SHIFT ;/* A 4K page needs no special encoding */
Quoted 27 lines · Balbir Singh
Quoted 6 lines · Balbir Singh
Quoted 3 lines · Aneesh Kumar K.V
They differ between powernv and pseries. While we are at it copy a version for ps3 too. For now this is same as what we have for pSeries.
Quoted 9 lines
Quoted 2 lines
Fixes 50de596de8be6 ("powerpc/mm/hash: Add support for Power9 Hash")Signed-off-by Aneesh Kumar K.V <[email protected]>I have not looked at the patch closely, but do we want all of this duplication. I was wondering if instead of
cpu_has_feature()we couldfirmware_has_feature()for nowBasically something like
Not-yet-signed-off-by Balbir Singh <[email protected]>arch/powerpc/include/asm/book3s/64/mmu-hash.h +0
-0
arch/powerpc/include/asm/book3s/64/mmu-hash.h static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize, · line 287
Quoted 7 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +2
-1@@ -282,7 +282,8 @@ static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize,*/ v = (vpn >> (23 -VPN_SHIFT )) & ~(mmu_psize_defs[psize].avpnm); v <<=HPTE_V_AVPN_SHIFT ; -if (!cpu_has_feature (CPU_FTR_ARCH_300 )) +if (!cpu_has_feature (CPU_FTR_ARCH_300 ) || +firmware_has_feature (FW_FEATURE_LPAR )) v |= ((unsigned long ) ssize) <<HPTE_V_SSIZE_SHIFT ;
I looked at this before and in the end decided to go otherwise. A large part of that patch is comment duplication. My thinking was if the encoding needs to be different, then it is better to have seperate functions to do the encoding.
arch/powerpc/include/asm/book3s/64/mmu-hash.h static inline unsigned long hpte_encode_r(unsigned long pa, int base_psize, · line 318
Quoted 12 lines
arch/powerpc/include/asm/book3s/64/mmu-hash.h +2
-1return v; }@@ -310,7 +311,8 @@ static inline unsigned long hpte_encode_r(unsigned long pa, int base_psize, int actual_psize, int ssize) { - if (cpu_has_feature(CPU_FTR_ARCH_300)) +if (cpu_has_feature (CPU_FTR_ARCH_300 ) && + !firmware_has_feature (FW_FEATURE_LPAR )) pa |= ((unsigned long ) ssize) <<HPTE_R_3_0_SSIZE_SHIFT ;/* A 4K page needs no special encoding */
-aneesh
Quoted 4 lines · Aneesh Kumar K.V
They differ between powernv and pseries. While we are at it copy a version for ps3 too. For now this is same as what we have for pSeries.
Fixes 50de596de8be6 ("powerpc/mm/hash: Add support for Power9 Hash")
This seems like a lot of churn on top of a lot of churn.
I think we should use the old format almost everywhere, and just convert at the last minute in functions such as native_hpte_insert(), native_hpte_invalidate(), etc.
Paul.