Changeset 1065603e in mainline for arch/ia64/src/mm/tlb.c


Ignore:
Timestamp:
2006-03-14T20:09:27Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5f62ef9
Parents:
e4ddfa8
Message:

Fix bug in switch to userspace on ia64: ensure start in bank 1.
Fix bug in tlb_invalidate_all() that cause interrupts to be unconditionally enabled.
Optimize context switching by discarding packed attribute of context structures.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia64/src/mm/tlb.c

    re4ddfa8 r1065603e  
    4343#include <typedefs.h>
    4444#include <panic.h>
     45#include <print.h>
    4546#include <arch.h>
    46 
    47 
    4847
    4948/** Invalidate all TLB entries. */
    5049void tlb_invalidate_all(void)
    5150{
     51                ipl_t ipl;
    5252                __address adr;
    53                 __u32 count1,count2,stride1,stride2;
     53                __u32 count1, count2, stride1, stride2;
    5454               
    5555                int i,j;
    5656               
    57                 adr=PAL_PTCE_INFO_BASE();
    58                 count1=PAL_PTCE_INFO_COUNT1();
    59                 count2=PAL_PTCE_INFO_COUNT2();
    60                 stride1=PAL_PTCE_INFO_STRIDE1();
    61                 stride2=PAL_PTCE_INFO_STRIDE2();
     57                adr = PAL_PTCE_INFO_BASE();
     58                count1 = PAL_PTCE_INFO_COUNT1();
     59                count2 = PAL_PTCE_INFO_COUNT2();
     60                stride1 = PAL_PTCE_INFO_STRIDE1();
     61                stride2 = PAL_PTCE_INFO_STRIDE2();
    6262               
    63                 interrupts_disable();
    64 
    65                 for(i=0;i<count1;i++)
    66                 {
    67                         for(j=0;j<count2;j++)
    68                         {
    69                                 asm volatile
    70                                 (
    71                                         "ptc.e %0;;"
     63                ipl = interrupts_disable();
     64
     65                for(i = 0; i < count1; i++) {
     66                        for(j = 0; j < count2; j++) {
     67                                __asm__ volatile (
     68                                        "ptc.e %0 ;;"
    7269                                        :
    73                                         :"r" (adr)
     70                                        : "r" (adr)
    7471                                );
    75                                 adr+=stride2;
     72                                adr += stride2;
    7673                        }
    77                         adr+=stride1;
     74                        adr += stride1;
    7875                }
    7976
    80                 interrupts_enable();
     77                interrupts_restore(ipl);
    8178
    8279                srlz_d();
     
    9087void tlb_invalidate_asid(asid_t asid)
    9188{
    92         /* TODO */
    9389        tlb_invalidate_all();
    9490}
     
    9793void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt)
    9894{
    99 
    100 
    10195        region_register rr;
    10296        bool restore_rr = false;
    103         int b=0;
    104         int c=cnt;
     97        int b = 0;
     98        int c = cnt;
    10599
    106100        __address va;
    107         va=page;
     101        va = page;
    108102
    109103        rr.word = rr_read(VA2VRN(va));
     
    122116        }
    123117       
    124         while(c>>=1)    b++;
    125         b>>=1;
     118        while(c >>= 1)
     119                b++;
     120        b >>= 1;
    126121        __u64 ps;
    127122       
    128         switch(b)
    129         {
     123        switch (b) {
    130124                case 0: /*cnt 1-3*/
    131                 {
    132                         ps=PAGE_WIDTH;
    133                         break;
    134                 }
     125                        ps = PAGE_WIDTH;
     126                        break;
    135127                case 1: /*cnt 4-15*/
    136                 {
    137128                        /*cnt=((cnt-1)/4)+1;*/
    138                         ps=PAGE_WIDTH+2;
    139                         va&=~((1<<ps)-1);
    140                         break;
    141                 }
     129                        ps = PAGE_WIDTH+2;
     130                        va &= ~((1<<ps)-1);
     131                        break;
    142132                case 2: /*cnt 16-63*/
    143                 {
    144133                        /*cnt=((cnt-1)/16)+1;*/
    145                         ps=PAGE_WIDTH+4;
    146                         va&=~((1<<ps)-1);
    147                         break;
    148                 }
     134                        ps = PAGE_WIDTH+4;
     135                        va &= ~((1<<ps)-1);
     136                        break;
    149137                case 3: /*cnt 64-255*/
    150                 {
    151138                        /*cnt=((cnt-1)/64)+1;*/
    152                         ps=PAGE_WIDTH+6;
    153                         va&=~((1<<ps)-1);
    154                         break;
    155                 }
     139                        ps = PAGE_WIDTH+6;
     140                        va &= ~((1<<ps)-1);
     141                        break;
    156142                case 4: /*cnt 256-1023*/
    157                 {
    158143                        /*cnt=((cnt-1)/256)+1;*/
    159                         ps=PAGE_WIDTH+8;
    160                         va&=~((1<<ps)-1);
    161                         break;
    162                 }
     144                        ps = PAGE_WIDTH+8;
     145                        va &= ~((1<<ps)-1);
     146                        break;
    163147                case 5: /*cnt 1024-4095*/
    164                 {
    165148                        /*cnt=((cnt-1)/1024)+1;*/
    166                         ps=PAGE_WIDTH+10;
    167                         va&=~((1<<ps)-1);
    168                         break;
    169                 }
     149                        ps = PAGE_WIDTH+10;
     150                        va &= ~((1<<ps)-1);
     151                        break;
    170152                case 6: /*cnt 4096-16383*/
    171                 {
    172153                        /*cnt=((cnt-1)/4096)+1;*/
    173                         ps=PAGE_WIDTH+12;
    174                         va&=~((1<<ps)-1);
    175                         break;
    176                 }
     154                        ps = PAGE_WIDTH+12;
     155                        va &= ~((1<<ps)-1);
     156                        break;
    177157                case 7: /*cnt 16384-65535*/
    178158                case 8: /*cnt 65536-(256K-1)*/
    179                 {
    180159                        /*cnt=((cnt-1)/16384)+1;*/
    181                         ps=PAGE_WIDTH+14;
    182                         va&=~((1<<ps)-1);
    183                         break;
    184                 }
     160                        ps = PAGE_WIDTH+14;
     161                        va &= ~((1<<ps)-1);
     162                        break;
    185163                default:
    186                 {
    187164                        /*cnt=((cnt-1)/(16384*16))+1;*/
    188165                        ps=PAGE_WIDTH+18;
    189166                        va&=~((1<<ps)-1);
    190167                        break;
    191                 }
    192168        }
    193169        /*cnt+=(page!=va);*/
    194         for(;va<(page+cnt*(PAGE_SIZE));va+=(1<<ps))     {
    195                 __asm__ volatile
    196                 (
     170        for(; va<(page+cnt*(PAGE_SIZE)); va += (1<<ps)) {
     171                __asm__ volatile (
    197172                        "ptc.l %0,%1;;"
    198173                        :
    199                         : "r"(va), "r"(ps<<2)
     174                        : "r" (va), "r" (ps<<2)
    200175                );
    201176        }
     
    203178        srlz_i();
    204179       
    205        
    206180        if (restore_rr) {
    207181                rr_write(VA2VRN(va), rr.word);
     
    209183                srlz_i();
    210184        }
    211 
    212 
    213185}
    214186
     
    507479                 */
    508480                if (!as_page_fault(va)) {
    509                         panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid);
     481                        panic("%s: va=%P, rid=%d, iip=%P\n", __FUNCTION__, va, rid, istate->cr_iip);
    510482                }
    511483        }
     
    613585        } else {
    614586                if (!as_page_fault(va)) {
    615                         panic("%s: va=%P, rid=%d\n", __FUNCTION__, istate->cr_ifa, rr.map.rid);
     587                        panic("%s: va=%P, rid=%d\n", __FUNCTION__, va, rr.map.rid);
    616588                }
    617589        }
Note: See TracChangeset for help on using the changeset viewer.