Skip to content

Commit c177091

Browse files
committed
parisc: Optimize tmpalias function calls
Instead of converting the physical address of the tmpalias mapping to the tlb insert format inside all the various tmpalias functions, move this conversion over to the DTLB miss handler. The physical address is already in %r26 (or will be calculated into %r23), so there are no additional steps needed in the functions themselves. Additionally use the dep_safe() and depi_safe() macros to avoid differentiating between 32- and 64-bit builds and as such make the code much more readable. The check if "ldil L%(TMPALIAS_MAP_START)" will sign extend into the upper 32 bits can be dropped, because we added a compile time check in an earlier patch. Signed-off-by: Helge Deller <deller@gmx.de>
1 parent cdd00fe commit c177091

2 files changed

Lines changed: 17 additions & 85 deletions

File tree

arch/parisc/kernel/entry.S

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,6 @@
566566
.macro do_alias spc,tmp,tmp1,va,pte,prot,fault,patype
567567
cmpib,COND(<>),n 0,\spc,\fault
568568
ldil L%(TMPALIAS_MAP_START),\tmp
569-
#if defined(CONFIG_64BIT) && (TMPALIAS_MAP_START >= 0x80000000)
570-
/* on LP64, ldi will sign extend into the upper 32 bits,
571-
* which is behaviour we don't want */
572-
depdi 0,31,32,\tmp
573-
#endif
574569
copy \va,\tmp1
575570
depi_safe 0,31,TMPALIAS_SIZE_BITS+1,\tmp1
576571
cmpb,COND(<>),n \tmp,\tmp1,\fault
@@ -605,13 +600,13 @@
605600
* OK, it is in the temp alias region, check whether "from" or "to".
606601
* Check "subtle" note in pacache.S re: r23/r26.
607602
*/
608-
#ifdef CONFIG_64BIT
609-
extrd,u,*= \va,63-TMPALIAS_SIZE_BITS,1,%r0
610-
#else
611603
extrw,u,= \va,31-TMPALIAS_SIZE_BITS,1,%r0
612-
#endif
613604
or,COND(tr) %r23,%r0,\pte
614605
or %r26,%r0,\pte
606+
607+
/* convert phys addr in \pte (from r23 or r26) to tlb insert format */
608+
SHRREG \pte,PAGE_SHIFT+PAGE_ADD_SHIFT-5, \pte
609+
depi_safe _PAGE_SIZE_ENCODING_DEFAULT, 31,5, \pte
615610
.endm
616611

617612

arch/parisc/kernel/pacache.S

Lines changed: 13 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -500,19 +500,10 @@ ENDPROC_CFI(copy_page_asm)
500500
* miss on the translation, the dtlb miss handler inserts the
501501
* translation into the tlb using these values:
502502
*
503-
* %r26 physical page (shifted for tlb insert) of "to" translation
504-
* %r23 physical page (shifted for tlb insert) of "from" translation
503+
* %r26 physical address of "to" translation
504+
* %r23 physical address of "from" translation
505505
*/
506506

507-
/* Drop prot bits and convert to page addr for iitlbt and idtlbt */
508-
#define PAGE_ADD_SHIFT (PAGE_SHIFT-12)
509-
.macro convert_phys_for_tlb_insert20 phys
510-
extrd,u \phys, 56-PAGE_ADD_SHIFT, 32-PAGE_ADD_SHIFT, \phys
511-
#if _PAGE_SIZE_ENCODING_DEFAULT
512-
depdi _PAGE_SIZE_ENCODING_DEFAULT, 63, (63-58), \phys
513-
#endif
514-
.endm
515-
516507
/*
517508
* copy_user_page_asm() performs a page copy using mappings
518509
* equivalent to the user page mappings. It can be used to
@@ -541,24 +532,10 @@ ENTRY_CFI(copy_user_page_asm)
541532
sub %r25, %r1, %r23
542533

543534
ldil L%(TMPALIAS_MAP_START), %r28
544-
#ifdef CONFIG_64BIT
545-
#if (TMPALIAS_MAP_START >= 0x80000000)
546-
depdi 0, 31,32, %r28 /* clear any sign extension */
547-
#endif
548-
convert_phys_for_tlb_insert20 %r26 /* convert phys addr to tlb insert format */
549-
convert_phys_for_tlb_insert20 %r23 /* convert phys addr to tlb insert format */
550-
depd %r24,63,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
551-
depdi 0, 63,PAGE_SHIFT, %r28 /* Clear any offset bits */
552-
copy %r28, %r29
553-
depdi 1, 63-TMPALIAS_SIZE_BITS,1, %r29 /* Form aliased virtual address 'from' */
554-
#else
555-
extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
556-
extrw,u %r23, 24,25, %r23 /* convert phys addr to tlb insert format */
557-
depw %r24, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
558-
depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
535+
dep_safe %r24, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
536+
depi_safe 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
559537
copy %r28, %r29
560-
depwi 1, 31-TMPALIAS_SIZE_BITS,1, %r29 /* Form aliased virtual address 'from' */
561-
#endif
538+
depi_safe 1, 31-TMPALIAS_SIZE_BITS,1, %r29 /* Form aliased virtual address 'from' */
562539

563540
/* Purge any old translations */
564541

@@ -688,18 +665,8 @@ ENTRY_CFI(clear_user_page_asm)
688665
tophys_r1 %r26
689666

690667
ldil L%(TMPALIAS_MAP_START), %r28
691-
#ifdef CONFIG_64BIT
692-
#if (TMPALIAS_MAP_START >= 0x80000000)
693-
depdi 0, 31,32, %r28 /* clear any sign extension */
694-
#endif
695-
convert_phys_for_tlb_insert20 %r26 /* convert phys addr to tlb insert format */
696-
depd %r25, 63,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
697-
depdi 0, 63,PAGE_SHIFT, %r28 /* Clear any offset bits */
698-
#else
699-
extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
700-
depw %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
701-
depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
702-
#endif
668+
dep_safe %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
669+
depi_safe 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
703670

704671
/* Purge any old translation */
705672

@@ -764,18 +731,8 @@ ENDPROC_CFI(clear_user_page_asm)
764731

765732
ENTRY_CFI(flush_dcache_page_asm)
766733
ldil L%(TMPALIAS_MAP_START), %r28
767-
#ifdef CONFIG_64BIT
768-
#if (TMPALIAS_MAP_START >= 0x80000000)
769-
depdi 0, 31,32, %r28 /* clear any sign extension */
770-
#endif
771-
convert_phys_for_tlb_insert20 %r26 /* convert phys addr to tlb insert format */
772-
depd %r25, 63,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
773-
depdi 0, 63,PAGE_SHIFT, %r28 /* Clear any offset bits */
774-
#else
775-
extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
776-
depw %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
777-
depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
778-
#endif
734+
dep_safe %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
735+
depi_safe 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
779736

780737
/* Purge any old translation */
781738

@@ -823,18 +780,8 @@ ENDPROC_CFI(flush_dcache_page_asm)
823780

824781
ENTRY_CFI(purge_dcache_page_asm)
825782
ldil L%(TMPALIAS_MAP_START), %r28
826-
#ifdef CONFIG_64BIT
827-
#if (TMPALIAS_MAP_START >= 0x80000000)
828-
depdi 0, 31,32, %r28 /* clear any sign extension */
829-
#endif
830-
convert_phys_for_tlb_insert20 %r26 /* convert phys addr to tlb insert format */
831-
depd %r25, 63,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
832-
depdi 0, 63,PAGE_SHIFT, %r28 /* Clear any offset bits */
833-
#else
834-
extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
835-
depw %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
836-
depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
837-
#endif
783+
dep_safe %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
784+
depi_safe 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
838785

839786
/* Purge any old translation */
840787

@@ -882,18 +829,8 @@ ENDPROC_CFI(purge_dcache_page_asm)
882829

883830
ENTRY_CFI(flush_icache_page_asm)
884831
ldil L%(TMPALIAS_MAP_START), %r28
885-
#ifdef CONFIG_64BIT
886-
#if (TMPALIAS_MAP_START >= 0x80000000)
887-
depdi 0, 31,32, %r28 /* clear any sign extension */
888-
#endif
889-
convert_phys_for_tlb_insert20 %r26 /* convert phys addr to tlb insert format */
890-
depd %r25, 63,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
891-
depdi 0, 63,PAGE_SHIFT, %r28 /* Clear any offset bits */
892-
#else
893-
extrw,u %r26, 24,25, %r26 /* convert phys addr to tlb insert format */
894-
depw %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
895-
depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
896-
#endif
832+
dep_safe %r25, 31,TMPALIAS_SIZE_BITS, %r28 /* Form aliased virtual address 'to' */
833+
depi_safe 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
897834

898835
/* Purge any old translation. Note that the FIC instruction
899836
* may use either the instruction or data TLB. Given that we

0 commit comments

Comments
 (0)