Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: remove drm specific kmap_atomic code

kmap_atomic_prot() is now exported by all architectures. Use this
function rather than open coding a driver specific kmap_atomic.

[arnd@arndb.de: include linux/highmem.h]
Link: http://lkml.kernel.org/r/20200508220150.649044-1-arnd@arndb.de
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20200507150004.1423069-12-ira.weiny@intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ira Weiny and committed by
Linus Torvalds
915ecc22 20b271df

+13 -64
+4 -52
drivers/gpu/drm/ttm/ttm_bo_util.c
··· 257 257 return 0; 258 258 } 259 259 260 - #ifdef CONFIG_X86 261 - #define __ttm_kmap_atomic_prot(__page, __prot) kmap_atomic_prot(__page, __prot) 262 - #define __ttm_kunmap_atomic(__addr) kunmap_atomic(__addr) 263 - #else 264 - #define __ttm_kmap_atomic_prot(__page, __prot) vmap(&__page, 1, 0, __prot) 265 - #define __ttm_kunmap_atomic(__addr) vunmap(__addr) 266 - #endif 267 - 268 - 269 - /** 270 - * ttm_kmap_atomic_prot - Efficient kernel map of a single page with 271 - * specified page protection. 272 - * 273 - * @page: The page to map. 274 - * @prot: The page protection. 275 - * 276 - * This function maps a TTM page using the kmap_atomic api if available, 277 - * otherwise falls back to vmap. The user must make sure that the 278 - * specified page does not have an aliased mapping with a different caching 279 - * policy unless the architecture explicitly allows it. Also mapping and 280 - * unmapping using this api must be correctly nested. Unmapping should 281 - * occur in the reverse order of mapping. 282 - */ 283 - void *ttm_kmap_atomic_prot(struct page *page, pgprot_t prot) 284 - { 285 - if (pgprot_val(prot) == pgprot_val(PAGE_KERNEL)) 286 - return kmap_atomic(page); 287 - else 288 - return __ttm_kmap_atomic_prot(page, prot); 289 - } 290 - EXPORT_SYMBOL(ttm_kmap_atomic_prot); 291 - 292 - /** 293 - * ttm_kunmap_atomic_prot - Unmap a page that was mapped using 294 - * ttm_kmap_atomic_prot. 295 - * 296 - * @addr: The virtual address from the map. 297 - * @prot: The page protection. 298 - */ 299 - void ttm_kunmap_atomic_prot(void *addr, pgprot_t prot) 300 - { 301 - if (pgprot_val(prot) == pgprot_val(PAGE_KERNEL)) 302 - kunmap_atomic(addr); 303 - else 304 - __ttm_kunmap_atomic(addr); 305 - } 306 - EXPORT_SYMBOL(ttm_kunmap_atomic_prot); 307 - 308 260 static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src, 309 261 unsigned long page, 310 262 pgprot_t prot) ··· 268 316 return -ENOMEM; 269 317 270 318 src = (void *)((unsigned long)src + (page << PAGE_SHIFT)); 271 - dst = ttm_kmap_atomic_prot(d, prot); 319 + dst = kmap_atomic_prot(d, prot); 272 320 if (!dst) 273 321 return -ENOMEM; 274 322 275 323 memcpy_fromio(dst, src, PAGE_SIZE); 276 324 277 - ttm_kunmap_atomic_prot(dst, prot); 325 + kunmap_atomic(dst); 278 326 279 327 return 0; 280 328 } ··· 290 338 return -ENOMEM; 291 339 292 340 dst = (void *)((unsigned long)dst + (page << PAGE_SHIFT)); 293 - src = ttm_kmap_atomic_prot(s, prot); 341 + src = kmap_atomic_prot(s, prot); 294 342 if (!src) 295 343 return -ENOMEM; 296 344 297 345 memcpy_toio(dst, src, PAGE_SIZE); 298 346 299 - ttm_kunmap_atomic_prot(src, prot); 347 + kunmap_atomic(src); 300 348 301 349 return 0; 302 350 }
+9 -8
drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
··· 27 27 **************************************************************************/ 28 28 29 29 #include "vmwgfx_drv.h" 30 + #include <linux/highmem.h> 30 31 31 32 /* 32 33 * Template that implements find_first_diff() for a generic ··· 375 374 copy_size = min_t(u32, copy_size, PAGE_SIZE - src_page_offset); 376 375 377 376 if (unmap_src) { 378 - ttm_kunmap_atomic_prot(d->src_addr, d->src_prot); 377 + kunmap_atomic(d->src_addr); 379 378 d->src_addr = NULL; 380 379 } 381 380 382 381 if (unmap_dst) { 383 - ttm_kunmap_atomic_prot(d->dst_addr, d->dst_prot); 382 + kunmap_atomic(d->dst_addr); 384 383 d->dst_addr = NULL; 385 384 } 386 385 ··· 389 388 return -EINVAL; 390 389 391 390 d->dst_addr = 392 - ttm_kmap_atomic_prot(d->dst_pages[dst_page], 393 - d->dst_prot); 391 + kmap_atomic_prot(d->dst_pages[dst_page], 392 + d->dst_prot); 394 393 if (!d->dst_addr) 395 394 return -ENOMEM; 396 395 ··· 402 401 return -EINVAL; 403 402 404 403 d->src_addr = 405 - ttm_kmap_atomic_prot(d->src_pages[src_page], 406 - d->src_prot); 404 + kmap_atomic_prot(d->src_pages[src_page], 405 + d->src_prot); 407 406 if (!d->src_addr) 408 407 return -ENOMEM; 409 408 ··· 500 499 } 501 500 out: 502 501 if (d.src_addr) 503 - ttm_kunmap_atomic_prot(d.src_addr, d.src_prot); 502 + kunmap_atomic(d.src_addr); 504 503 if (d.dst_addr) 505 - ttm_kunmap_atomic_prot(d.dst_addr, d.dst_prot); 504 + kunmap_atomic(d.dst_addr); 506 505 507 506 return ret; 508 507 }
-4
include/drm/ttm/ttm_bo_api.h
··· 668 668 int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma, 669 669 struct ttm_bo_device *bdev); 670 670 671 - void *ttm_kmap_atomic_prot(struct page *page, pgprot_t prot); 672 - 673 - void ttm_kunmap_atomic_prot(void *addr, pgprot_t prot); 674 - 675 671 /** 676 672 * ttm_bo_io 677 673 *