direct-io.hg

changeset 9652:5c477ad95dba

Clean up grant_mapping_t. Increase its size from 4bytes to 8bytes and
removed tight encoding of flag and ref. This change is xen-internal
so this shouldn't affect domain api.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 14 14:40:30 2006 +0100 (2006-04-14)
parents 2ae003c45ffe
children b055716f89c0
files xen/common/grant_table.c xen/include/xen/grant_table.h
line diff
     1.1 --- a/xen/common/grant_table.c	Fri Apr 14 14:37:19 2006 +0100
     1.2 +++ b/xen/common/grant_table.c	Fri Apr 14 14:40:30 2006 +0100
     1.3 @@ -46,7 +46,7 @@ get_maptrack_handle(
     1.4      unsigned int h;
     1.5      if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
     1.6          return -1;
     1.7 -    t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
     1.8 +    t->maptrack_head = t->maptrack[h].ref;
     1.9      t->map_count++;
    1.10      return h;
    1.11  }
    1.12 @@ -55,7 +55,7 @@ static inline void
    1.13  put_maptrack_handle(
    1.14      grant_table_t *t, int handle)
    1.15  {
    1.16 -    t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
    1.17 +    t->maptrack[handle].ref = t->maptrack_head;
    1.18      t->maptrack_head = handle;
    1.19      t->map_count--;
    1.20  }
    1.21 @@ -147,7 +147,7 @@ static void
    1.22  
    1.23          memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
    1.24          for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
    1.25 -            new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
    1.26 +            new_mt[i].ref = i+1;
    1.27  
    1.28          free_xenheap_pages(lgt->maptrack, lgt->maptrack_order);
    1.29          lgt->maptrack          = new_mt;
    1.30 @@ -265,8 +265,8 @@ static void
    1.31      TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, op->dom);
    1.32  
    1.33      ld->grant_table->maptrack[handle].domid         = op->dom;
    1.34 -    ld->grant_table->maptrack[handle].ref_and_flags =
    1.35 -        (op->ref << MAPTRACK_REF_SHIFT) |
    1.36 +    ld->grant_table->maptrack[handle].ref = op->ref;
    1.37 +    ld->grant_table->maptrack[handle].flags =
    1.38          (op->flags & MAPTRACK_GNTMAP_MASK);
    1.39  
    1.40      op->dev_bus_addr = (u64)frame << PAGE_SHIFT;
    1.41 @@ -340,7 +340,7 @@ static void
    1.42      map = &ld->grant_table->maptrack[op->handle];
    1.43  
    1.44      if ( unlikely(op->handle >= ld->grant_table->maptrack_limit) ||
    1.45 -         unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
    1.46 +         unlikely(!map->flags) )
    1.47      {
    1.48          DPRINTK("Bad handle (%d).\n", op->handle);
    1.49          op->status = GNTST_bad_handle;
    1.50 @@ -348,8 +348,8 @@ static void
    1.51      }
    1.52  
    1.53      dom   = map->domid;
    1.54 -    ref   = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
    1.55 -    flags = map->ref_and_flags & MAPTRACK_GNTMAP_MASK;
    1.56 +    ref   = map->ref;
    1.57 +    flags = map->flags;
    1.58  
    1.59      if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
    1.60           unlikely(ld == rd) )
    1.61 @@ -380,7 +380,7 @@ static void
    1.62          if ( flags & GNTMAP_device_map )
    1.63          {
    1.64              ASSERT(act->pin & (GNTPIN_devw_mask | GNTPIN_devr_mask));
    1.65 -            map->ref_and_flags &= ~GNTMAP_device_map;
    1.66 +            map->flags &= ~GNTMAP_device_map;
    1.67              if ( flags & GNTMAP_readonly )
    1.68              {
    1.69                  act->pin -= GNTPIN_devr_inc;
    1.70 @@ -401,7 +401,7 @@ static void
    1.71              goto unmap_out;
    1.72  
    1.73          ASSERT(act->pin & (GNTPIN_hstw_mask | GNTPIN_hstr_mask));
    1.74 -        map->ref_and_flags &= ~GNTMAP_host_map;
    1.75 +        map->flags &= ~GNTMAP_host_map;
    1.76          if ( flags & GNTMAP_readonly )
    1.77          {
    1.78              act->pin -= GNTPIN_hstr_inc;
    1.79 @@ -414,9 +414,9 @@ static void
    1.80          }
    1.81      }
    1.82  
    1.83 -    if ( (map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
    1.84 +    if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
    1.85      {
    1.86 -        map->ref_and_flags = 0;
    1.87 +        map->flags = 0;
    1.88          put_maptrack_handle(ld->grant_table, op->handle);
    1.89      }
    1.90  
    1.91 @@ -778,6 +778,7 @@ grant_table_create(
    1.92      grant_table_t *t;
    1.93      int            i;
    1.94  
    1.95 +    BUG_ON(MAPTRACK_MAX_ENTRIES < NR_GRANT_ENTRIES);
    1.96      if ( (t = xmalloc(grant_table_t)) == NULL )
    1.97          goto no_mem;
    1.98  
    1.99 @@ -798,7 +799,7 @@ grant_table_create(
   1.100      t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
   1.101      memset(t->maptrack, 0, PAGE_SIZE);
   1.102      for ( i = 0; i < t->maptrack_limit; i++ )
   1.103 -        t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
   1.104 +        t->maptrack[i].ref = i+1;
   1.105  
   1.106      /* Shared grant table. */
   1.107      t->shared = alloc_xenheap_pages(ORDER_GRANT_FRAMES);
   1.108 @@ -841,14 +842,13 @@ gnttab_release_mappings(
   1.109      for ( handle = 0; handle < gt->maptrack_limit; handle++ )
   1.110      {
   1.111          map = &gt->maptrack[handle];
   1.112 -        if ( !(map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) )
   1.113 +        if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) )
   1.114              continue;
   1.115  
   1.116 -        ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
   1.117 +        ref = map->ref;
   1.118  
   1.119          DPRINTK("Grant release (%hu) ref:(%hu) flags:(%x) dom:(%hu)\n",
   1.120 -                handle, ref, map->ref_and_flags & MAPTRACK_GNTMAP_MASK,
   1.121 -                map->domid);
   1.122 +                handle, ref, map->flags, map->domid);
   1.123  
   1.124          rd = find_domain_by_id(map->domid);
   1.125          BUG_ON(rd == NULL);
   1.126 @@ -858,16 +858,16 @@ gnttab_release_mappings(
   1.127          act = &rd->grant_table->active[ref];
   1.128          sha = &rd->grant_table->shared[ref];
   1.129  
   1.130 -        if ( map->ref_and_flags & GNTMAP_readonly )
   1.131 +        if ( map->flags & GNTMAP_readonly )
   1.132          {
   1.133 -            if ( map->ref_and_flags & GNTMAP_device_map )
   1.134 +            if ( map->flags & GNTMAP_device_map )
   1.135              {
   1.136                  BUG_ON(!(act->pin & GNTPIN_devr_mask));
   1.137                  act->pin -= GNTPIN_devr_inc;
   1.138                  put_page(mfn_to_page(act->frame));
   1.139              }
   1.140  
   1.141 -            if ( map->ref_and_flags & GNTMAP_host_map )
   1.142 +            if ( map->flags & GNTMAP_host_map )
   1.143              {
   1.144                  BUG_ON(!(act->pin & GNTPIN_hstr_mask));
   1.145                  act->pin -= GNTPIN_hstr_inc;
   1.146 @@ -877,14 +877,14 @@ gnttab_release_mappings(
   1.147          }
   1.148          else
   1.149          {
   1.150 -            if ( map->ref_and_flags & GNTMAP_device_map )
   1.151 +            if ( map->flags & GNTMAP_device_map )
   1.152              {
   1.153                  BUG_ON(!(act->pin & GNTPIN_devw_mask));
   1.154                  act->pin -= GNTPIN_devw_inc;
   1.155                  put_page_and_type(mfn_to_page(act->frame));
   1.156              }
   1.157  
   1.158 -            if ( map->ref_and_flags & GNTMAP_host_map )
   1.159 +            if ( map->flags & GNTMAP_host_map )
   1.160              {
   1.161                  BUG_ON(!(act->pin & GNTPIN_hstw_mask));
   1.162                  act->pin -= GNTPIN_hstw_inc;
   1.163 @@ -903,7 +903,7 @@ gnttab_release_mappings(
   1.164  
   1.165          put_domain(rd);
   1.166  
   1.167 -        map->ref_and_flags = 0;
   1.168 +        map->flags = 0;
   1.169      }
   1.170  }
   1.171  
     2.1 --- a/xen/include/xen/grant_table.h	Fri Apr 14 14:37:19 2006 +0100
     2.2 +++ b/xen/include/xen/grant_table.h	Fri Apr 14 14:40:30 2006 +0100
     2.3 @@ -61,12 +61,12 @@ typedef struct {
     2.4   * table of these, indexes into which are returned as a 'mapping handle'.
     2.5   */
     2.6  typedef struct {
     2.7 -    u16      ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
     2.8 +    u32      ref;           /* grant ref */
     2.9 +    u16      flags;         /* 0-4: GNTMAP_* ; 5-15: unused */
    2.10      domid_t  domid;         /* granting domain */
    2.11  } grant_mapping_t;
    2.12  #define MAPTRACK_GNTMAP_MASK  0x1f
    2.13 -#define MAPTRACK_REF_SHIFT    5
    2.14 -#define MAPTRACK_MAX_ENTRIES  (1 << (16 - MAPTRACK_REF_SHIFT))
    2.15 +#define MAPTRACK_MAX_ENTRIES  (~((u32)0))
    2.16  
    2.17  /* Per-domain grant information. */
    2.18  typedef struct {