ia64/xen-unstable

changeset 6354:1d86fcb11b59

Grant table updates for block device changes.
- add gnttab_free_grant_reference
- make gnttab_free_grant_references interface consistent with other gnttab
functions
- add support for callback when references are freed
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Aug 22 20:52:38 2005 +0000 (2005-08-22)
parents 317db130cbbf
children 6078dc5f7ea1
files linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c linux-2.6-xen-sparse/include/asm-xen/gnttab.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Mon Aug 22 14:22:59 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Mon Aug 22 20:52:38 2005 +0000
     1.3 @@ -50,6 +50,8 @@ static grant_ref_t gnttab_free_head;
     1.4  
     1.5  static grant_entry_t *shared;
     1.6  
     1.7 +static struct gnttab_free_callback *gnttab_free_callback_list = NULL;
     1.8 +
     1.9  /*
    1.10   * Lock-free grant-entry allocator
    1.11   */
    1.12 @@ -65,6 +67,16 @@ get_free_entry(
    1.13      return fh;
    1.14  }
    1.15  
    1.16 +static void do_free_callbacks(void)
    1.17 +{
    1.18 +    struct gnttab_free_callback *callback = gnttab_free_callback_list;
    1.19 +    gnttab_free_callback_list = NULL;
    1.20 +    while (callback) {
    1.21 +	schedule_work(callback->work);
    1.22 +	callback = callback->next;
    1.23 +    }
    1.24 +}
    1.25 +
    1.26  static inline void
    1.27  put_free_entry(
    1.28      grant_ref_t ref)
    1.29 @@ -72,6 +84,8 @@ put_free_entry(
    1.30      grant_ref_t fh, nfh = gnttab_free_head;
    1.31      do { gnttab_free_list[ref] = fh = nfh; wmb(); }
    1.32      while ( unlikely((nfh = cmpxchg(&gnttab_free_head, fh, ref)) != fh) );
    1.33 +    if ( unlikely(gnttab_free_callback_list) )
    1.34 +	do_free_callbacks();
    1.35  }
    1.36  
    1.37  /*
    1.38 @@ -189,17 +203,23 @@ gnttab_end_foreign_transfer(
    1.39  }
    1.40  
    1.41  void
    1.42 -gnttab_free_grant_references( u16 count, grant_ref_t head )
    1.43 +gnttab_free_grant_reference( grant_ref_t ref )
    1.44 +{
    1.45 +
    1.46 +    put_free_entry(ref);
    1.47 +}
    1.48 +
    1.49 +void
    1.50 +gnttab_free_grant_references( grant_ref_t *head,
    1.51 +                              grant_ref_t terminal )
    1.52  {
    1.53      /* TODO: O(N)...? */
    1.54 -    grant_ref_t to_die = 0, next = head;
    1.55 -    int i;
    1.56 +    grant_ref_t ref;
    1.57  
    1.58 -    for ( i = 0; i < count; i++ )
    1.59 -    {
    1.60 -        to_die = next;
    1.61 -        next = gnttab_free_list[next];
    1.62 -        put_free_entry( to_die );
    1.63 +    while (*head != terminal) {
    1.64 +	ref = *head;
    1.65 +	*head = gnttab_free_list[*head];
    1.66 +	put_free_entry(ref);
    1.67      }
    1.68  }
    1.69  
    1.70 @@ -244,6 +264,15 @@ gnttab_release_grant_reference( grant_re
    1.71      *private_head = release;
    1.72  }
    1.73  
    1.74 +void
    1.75 +gnttab_request_free_callback(struct gnttab_free_callback *callback,
    1.76 +			     struct work_struct *work)
    1.77 +{
    1.78 +    callback->work = work;
    1.79 +    callback->next = gnttab_free_callback_list;
    1.80 +    gnttab_free_callback_list = callback;
    1.81 +}
    1.82 +
    1.83  /*
    1.84   * ProcFS operations
    1.85   */
     2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Mon Aug 22 14:22:59 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Mon Aug 22 20:52:38 2005 +0000
     2.3 @@ -21,6 +21,13 @@
     2.4  #define NR_GRANT_FRAMES 4
     2.5  #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
     2.6  
     2.7 +struct work_struct;
     2.8 +
     2.9 +struct gnttab_free_callback {
    2.10 +    struct gnttab_free_callback *next;
    2.11 +    struct work_struct *work;
    2.12 +};
    2.13 +
    2.14  int
    2.15  gnttab_grant_foreign_access(
    2.16      domid_t domid, unsigned long frame, int readonly);
    2.17 @@ -49,8 +56,12 @@ gnttab_alloc_grant_references(
    2.18      u16 count, grant_ref_t *pprivate_head, grant_ref_t *private_terminal );
    2.19  
    2.20  void
    2.21 +gnttab_free_grant_reference(
    2.22 +    grant_ref_t ref );
    2.23 +
    2.24 +void
    2.25  gnttab_free_grant_references(
    2.26 -    u16 count, grant_ref_t private_head );
    2.27 +    grant_ref_t *head, grant_ref_t terminal );
    2.28  
    2.29  int
    2.30  gnttab_claim_grant_reference( grant_ref_t *pprivate_head, grant_ref_t terminal
    2.31 @@ -61,6 +72,10 @@ gnttab_release_grant_reference(
    2.32      grant_ref_t *private_head, grant_ref_t release );
    2.33  
    2.34  void
    2.35 +gnttab_request_free_callback(
    2.36 +    struct gnttab_free_callback *callback, struct work_struct *work );
    2.37 +
    2.38 +void
    2.39  gnttab_grant_foreign_access_ref(
    2.40      grant_ref_t ref, domid_t domid, unsigned long frame, int readonly);
    2.41