| .. | .. |
|---|
| 97 | 97 | * access has been ended, free the given page too. Access will be ended |
|---|
| 98 | 98 | * immediately iff the grant entry is not in use, otherwise it will happen |
|---|
| 99 | 99 | * some time later. page may be 0, in which case no freeing will occur. |
|---|
| 100 | + * Note that the granted page might still be accessed (read or write) by the |
|---|
| 101 | + * other side after gnttab_end_foreign_access() returns, so even if page was |
|---|
| 102 | + * specified as 0 it is not allowed to just reuse the page for other |
|---|
| 103 | + * purposes immediately. gnttab_end_foreign_access() will take an additional |
|---|
| 104 | + * reference to the granted page in this case, which is dropped only after |
|---|
| 105 | + * the grant is no longer in use. |
|---|
| 106 | + * This requires that multi page allocations for areas subject to |
|---|
| 107 | + * gnttab_end_foreign_access() are done via alloc_pages_exact() (and freeing |
|---|
| 108 | + * via free_pages_exact()) in order to avoid high order pages. |
|---|
| 100 | 109 | */ |
|---|
| 101 | 110 | void gnttab_end_foreign_access(grant_ref_t ref, int readonly, |
|---|
| 102 | 111 | unsigned long page); |
|---|
| 112 | + |
|---|
| 113 | +/* |
|---|
| 114 | + * End access through the given grant reference, iff the grant entry is |
|---|
| 115 | + * no longer in use. In case of success ending foreign access, the |
|---|
| 116 | + * grant reference is deallocated. |
|---|
| 117 | + * Return 1 if the grant entry was freed, 0 if it is still in use. |
|---|
| 118 | + */ |
|---|
| 119 | +int gnttab_try_end_foreign_access(grant_ref_t ref); |
|---|
| 103 | 120 | |
|---|
| 104 | 121 | int gnttab_grant_foreign_transfer(domid_t domid, unsigned long pfn); |
|---|
| 105 | 122 | |
|---|
| 106 | 123 | unsigned long gnttab_end_foreign_transfer_ref(grant_ref_t ref); |
|---|
| 107 | 124 | unsigned long gnttab_end_foreign_transfer(grant_ref_t ref); |
|---|
| 108 | | - |
|---|
| 109 | | -int gnttab_query_foreign_access(grant_ref_t ref); |
|---|
| 110 | 125 | |
|---|
| 111 | 126 | /* |
|---|
| 112 | 127 | * operations on reserved batches of grant references |
|---|
| .. | .. |
|---|
| 199 | 214 | int gnttab_alloc_pages(int nr_pages, struct page **pages); |
|---|
| 200 | 215 | void gnttab_free_pages(int nr_pages, struct page **pages); |
|---|
| 201 | 216 | |
|---|
| 217 | +struct gnttab_page_cache { |
|---|
| 218 | + spinlock_t lock; |
|---|
| 219 | +#ifdef CONFIG_XEN_UNPOPULATED_ALLOC |
|---|
| 220 | + struct page *pages; |
|---|
| 221 | +#else |
|---|
| 222 | + struct list_head pages; |
|---|
| 223 | +#endif |
|---|
| 224 | + unsigned int num_pages; |
|---|
| 225 | +}; |
|---|
| 226 | + |
|---|
| 227 | +void gnttab_page_cache_init(struct gnttab_page_cache *cache); |
|---|
| 228 | +int gnttab_page_cache_get(struct gnttab_page_cache *cache, struct page **page); |
|---|
| 229 | +void gnttab_page_cache_put(struct gnttab_page_cache *cache, struct page **page, |
|---|
| 230 | + unsigned int num); |
|---|
| 231 | +void gnttab_page_cache_shrink(struct gnttab_page_cache *cache, |
|---|
| 232 | + unsigned int num); |
|---|
| 233 | + |
|---|
| 202 | 234 | #ifdef CONFIG_XEN_GRANT_DMA_ALLOC |
|---|
| 203 | 235 | struct gnttab_dma_alloc_args { |
|---|
| 204 | 236 | /* Device for which DMA memory will be/was allocated. */ |
|---|