diff options
Diffstat (limited to 'drivers/xen/tmem.c')
-rw-r--r-- | drivers/xen/tmem.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c index 239738f944ba..945fc4327201 100644 --- a/drivers/xen/tmem.c +++ b/drivers/xen/tmem.c | |||
@@ -129,21 +129,17 @@ static int xen_tmem_new_pool(struct tmem_pool_uuid uuid, | |||
129 | /* xen generic tmem ops */ | 129 | /* xen generic tmem ops */ |
130 | 130 | ||
131 | static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid, | 131 | static int xen_tmem_put_page(u32 pool_id, struct tmem_oid oid, |
132 | u32 index, unsigned long pfn) | 132 | u32 index, struct page *page) |
133 | { | 133 | { |
134 | unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn; | ||
135 | |||
136 | return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index, | 134 | return xen_tmem_op(TMEM_PUT_PAGE, pool_id, oid, index, |
137 | gmfn, 0, 0, 0); | 135 | xen_page_to_gfn(page), 0, 0, 0); |
138 | } | 136 | } |
139 | 137 | ||
140 | static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid, | 138 | static int xen_tmem_get_page(u32 pool_id, struct tmem_oid oid, |
141 | u32 index, unsigned long pfn) | 139 | u32 index, struct page *page) |
142 | { | 140 | { |
143 | unsigned long gmfn = xen_pv_domain() ? pfn_to_mfn(pfn) : pfn; | ||
144 | |||
145 | return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index, | 141 | return xen_tmem_op(TMEM_GET_PAGE, pool_id, oid, index, |
146 | gmfn, 0, 0, 0); | 142 | xen_page_to_gfn(page), 0, 0, 0); |
147 | } | 143 | } |
148 | 144 | ||
149 | static int xen_tmem_flush_page(u32 pool_id, struct tmem_oid oid, u32 index) | 145 | static int xen_tmem_flush_page(u32 pool_id, struct tmem_oid oid, u32 index) |
@@ -173,14 +169,13 @@ static void tmem_cleancache_put_page(int pool, struct cleancache_filekey key, | |||
173 | { | 169 | { |
174 | u32 ind = (u32) index; | 170 | u32 ind = (u32) index; |
175 | struct tmem_oid oid = *(struct tmem_oid *)&key; | 171 | struct tmem_oid oid = *(struct tmem_oid *)&key; |
176 | unsigned long pfn = page_to_pfn(page); | ||
177 | 172 | ||
178 | if (pool < 0) | 173 | if (pool < 0) |
179 | return; | 174 | return; |
180 | if (ind != index) | 175 | if (ind != index) |
181 | return; | 176 | return; |
182 | mb(); /* ensure page is quiescent; tmem may address it with an alias */ | 177 | mb(); /* ensure page is quiescent; tmem may address it with an alias */ |
183 | (void)xen_tmem_put_page((u32)pool, oid, ind, pfn); | 178 | (void)xen_tmem_put_page((u32)pool, oid, ind, page); |
184 | } | 179 | } |
185 | 180 | ||
186 | static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, | 181 | static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, |
@@ -188,7 +183,6 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, | |||
188 | { | 183 | { |
189 | u32 ind = (u32) index; | 184 | u32 ind = (u32) index; |
190 | struct tmem_oid oid = *(struct tmem_oid *)&key; | 185 | struct tmem_oid oid = *(struct tmem_oid *)&key; |
191 | unsigned long pfn = page_to_pfn(page); | ||
192 | int ret; | 186 | int ret; |
193 | 187 | ||
194 | /* translate return values to linux semantics */ | 188 | /* translate return values to linux semantics */ |
@@ -196,7 +190,7 @@ static int tmem_cleancache_get_page(int pool, struct cleancache_filekey key, | |||
196 | return -1; | 190 | return -1; |
197 | if (ind != index) | 191 | if (ind != index) |
198 | return -1; | 192 | return -1; |
199 | ret = xen_tmem_get_page((u32)pool, oid, ind, pfn); | 193 | ret = xen_tmem_get_page((u32)pool, oid, ind, page); |
200 | if (ret == 1) | 194 | if (ret == 1) |
201 | return 0; | 195 | return 0; |
202 | else | 196 | else |
@@ -287,7 +281,6 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset, | |||
287 | { | 281 | { |
288 | u64 ind64 = (u64)offset; | 282 | u64 ind64 = (u64)offset; |
289 | u32 ind = (u32)offset; | 283 | u32 ind = (u32)offset; |
290 | unsigned long pfn = page_to_pfn(page); | ||
291 | int pool = tmem_frontswap_poolid; | 284 | int pool = tmem_frontswap_poolid; |
292 | int ret; | 285 | int ret; |
293 | 286 | ||
@@ -296,7 +289,7 @@ static int tmem_frontswap_store(unsigned type, pgoff_t offset, | |||
296 | if (ind64 != ind) | 289 | if (ind64 != ind) |
297 | return -1; | 290 | return -1; |
298 | mb(); /* ensure page is quiescent; tmem may address it with an alias */ | 291 | mb(); /* ensure page is quiescent; tmem may address it with an alias */ |
299 | ret = xen_tmem_put_page(pool, oswiz(type, ind), iswiz(ind), pfn); | 292 | ret = xen_tmem_put_page(pool, oswiz(type, ind), iswiz(ind), page); |
300 | /* translate Xen tmem return values to linux semantics */ | 293 | /* translate Xen tmem return values to linux semantics */ |
301 | if (ret == 1) | 294 | if (ret == 1) |
302 | return 0; | 295 | return 0; |
@@ -313,7 +306,6 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset, | |||
313 | { | 306 | { |
314 | u64 ind64 = (u64)offset; | 307 | u64 ind64 = (u64)offset; |
315 | u32 ind = (u32)offset; | 308 | u32 ind = (u32)offset; |
316 | unsigned long pfn = page_to_pfn(page); | ||
317 | int pool = tmem_frontswap_poolid; | 309 | int pool = tmem_frontswap_poolid; |
318 | int ret; | 310 | int ret; |
319 | 311 | ||
@@ -321,7 +313,7 @@ static int tmem_frontswap_load(unsigned type, pgoff_t offset, | |||
321 | return -1; | 313 | return -1; |
322 | if (ind64 != ind) | 314 | if (ind64 != ind) |
323 | return -1; | 315 | return -1; |
324 | ret = xen_tmem_get_page(pool, oswiz(type, ind), iswiz(ind), pfn); | 316 | ret = xen_tmem_get_page(pool, oswiz(type, ind), iswiz(ind), page); |
325 | /* translate Xen tmem return values to linux semantics */ | 317 | /* translate Xen tmem return values to linux semantics */ |
326 | if (ret == 1) | 318 | if (ret == 1) |
327 | return 0; | 319 | return 0; |