ia64/xen-unstable

changeset 6701:c2705e74efba

Cleanups, and fix allocating DMA memory via
HYPERVISOR_memory_op().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Sep 08 15:22:01 2005 +0000 (2005-09-08)
parents 12ff9c954ace
children e3fd0fa58364 1f4863861d18
files xen/common/memory.c xen/common/page_alloc.c
line diff
     1.1 --- a/xen/common/memory.c	Thu Sep 08 01:07:15 2005 +0000
     1.2 +++ b/xen/common/memory.c	Thu Sep 08 15:22:01 2005 +0000
     1.3 @@ -31,8 +31,8 @@ increase_reservation(
     1.4      struct pfn_info *page;
     1.5      unsigned long    i;
     1.6  
     1.7 -    if ( (extent_list != NULL)
     1.8 -         && !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) )
     1.9 +    if ( (extent_list != NULL) &&
    1.10 +         !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) )
    1.11          return 0;
    1.12  
    1.13      if ( (extent_order != 0) && !IS_CAPABLE_PHYSDEV(current->domain) )
    1.14 @@ -52,13 +52,14 @@ increase_reservation(
    1.15          if ( unlikely((page = alloc_domheap_pages(
    1.16              d, extent_order, flags)) == NULL) )
    1.17          {
    1.18 -            DPRINTK("Could not allocate a frame id=%d %d flags=%x\n", d->domain_id, extent_order, flags);
    1.19 +            DPRINTK("Could not allocate order=%d extent: id=%d flags=%x\n",
    1.20 +                    extent_order, d->domain_id, flags);
    1.21              return i;
    1.22          }
    1.23  
    1.24          /* Inform the domain of the new page's machine address. */ 
    1.25 -        if ( (extent_list != NULL)
    1.26 -             && (__put_user(page_to_pfn(page), &extent_list[i]) != 0) )
    1.27 +        if ( (extent_list != NULL) &&
    1.28 +             (__put_user(page_to_pfn(page), &extent_list[i]) != 0) )
    1.29              return i;
    1.30      }
    1.31  
    1.32 @@ -152,8 +153,8 @@ long do_memory_op(int cmd, void *arg)
    1.33              reservation.extent_start += start_extent;
    1.34          reservation.nr_extents -= start_extent;
    1.35  
    1.36 -        if ( unlikely(reservation.address_bits != 0)
    1.37 -             && (reservation.address_bits > (get_order(max_page)+PAGE_SHIFT)) )
    1.38 +        if ( (reservation.address_bits != 0) &&
    1.39 +             (reservation.address_bits < (get_order(max_page) + PAGE_SHIFT)) )
    1.40          {
    1.41              if ( reservation.address_bits < 31 )
    1.42                  return -ENOMEM;
     2.1 --- a/xen/common/page_alloc.c	Thu Sep 08 01:07:15 2005 +0000
     2.2 +++ b/xen/common/page_alloc.c	Thu Sep 08 15:22:01 2005 +0000
     2.3 @@ -216,7 +216,7 @@ unsigned long alloc_boot_pages(unsigned 
     2.4  #define NR_ZONES    3
     2.5  
     2.6  
     2.7 -#define MAX_DMADOM_PFN 0x7FFFF /* 31 addressable bits */
     2.8 +#define MAX_DMADOM_PFN 0x7FFFFUL /* 31 addressable bits */
     2.9  #define pfn_dom_zone_type(_pfn)                                 \
    2.10      (((_pfn) <= MAX_DMADOM_PFN) ? MEMZONE_DMADOM : MEMZONE_DOM)
    2.11  
    2.12 @@ -485,43 +485,40 @@ void free_xenheap_pages(void *v, unsigne
    2.13  
    2.14  void init_domheap_pages(physaddr_t ps, physaddr_t pe)
    2.15  {
    2.16 +    unsigned long s_tot, e_tot, s_dma, e_dma, s_nrm, e_nrm;
    2.17 +
    2.18      ASSERT(!in_irq());
    2.19  
    2.20 -    ps = round_pgup(ps) >> PAGE_SHIFT;
    2.21 -    pe = round_pgdown(pe) >> PAGE_SHIFT;
    2.22 -    if ( pe <= ps )
    2.23 -        return;
    2.24 +    s_tot = round_pgup(ps) >> PAGE_SHIFT;
    2.25 +    e_tot = round_pgdown(pe) >> PAGE_SHIFT;
    2.26  
    2.27 -    if ( (ps < MAX_DMADOM_PFN) && (pe > MAX_DMADOM_PFN) )
    2.28 -    {
    2.29 -        init_heap_pages(
    2.30 -            MEMZONE_DMADOM, pfn_to_page(ps), MAX_DMADOM_PFN - ps);
    2.31 -        init_heap_pages(
    2.32 -            MEMZONE_DOM, pfn_to_page(MAX_DMADOM_PFN), pe - MAX_DMADOM_PFN);
    2.33 -    }
    2.34 -    else
    2.35 -    {
    2.36 -        init_heap_pages(pfn_dom_zone_type(ps), pfn_to_page(ps), pe - ps);
    2.37 -    }
    2.38 +    s_dma = min(s_tot, MAX_DMADOM_PFN + 1);
    2.39 +    e_dma = min(e_tot, MAX_DMADOM_PFN + 1);
    2.40 +    if ( s_dma < e_dma )
    2.41 +        init_heap_pages(MEMZONE_DMADOM, pfn_to_page(s_dma), e_dma - s_dma);
    2.42 +
    2.43 +    s_nrm = max(s_tot, MAX_DMADOM_PFN + 1);
    2.44 +    e_nrm = max(e_tot, MAX_DMADOM_PFN + 1);
    2.45 +    if ( s_nrm < e_nrm )
    2.46 +        init_heap_pages(MEMZONE_DOM, pfn_to_page(s_nrm), e_nrm - s_nrm);
    2.47  }
    2.48  
    2.49  
    2.50  struct pfn_info *alloc_domheap_pages(
    2.51      struct domain *d, unsigned int order, unsigned int flags)
    2.52  {
    2.53 -    struct pfn_info *pg;
    2.54 +    struct pfn_info *pg = NULL;
    2.55      cpumask_t mask;
    2.56      int i;
    2.57  
    2.58      ASSERT(!in_irq());
    2.59  
    2.60 -    pg = NULL;
    2.61 -    if (! (flags & ALLOC_DOM_DMA))
    2.62 +    if ( !(flags & ALLOC_DOM_DMA) )
    2.63          pg = alloc_heap_pages(MEMZONE_DOM, order);
    2.64 -    if (pg == NULL) {
    2.65 -        if ( unlikely((pg = alloc_heap_pages(MEMZONE_DMADOM, order)) == NULL) )
    2.66 +
    2.67 +    if ( pg == NULL )
    2.68 +        if ( (pg = alloc_heap_pages(MEMZONE_DMADOM, order)) == NULL )
    2.69              return NULL;
    2.70 -    }
    2.71  
    2.72      mask = pg->u.free.cpumask;
    2.73      tlbflush_filter(mask, pg->tlbflush_timestamp);