| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: radeon_ttm.c,v 1.23 2021/12/19 12:23:58 riastradh Exp $ */ | | 1 | /* $NetBSD: radeon_ttm.c,v 1.24 2021/12/23 17:09:25 hannken Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2009 Jerome Glisse. | | 4 | * Copyright 2009 Jerome Glisse. |
5 | * All Rights Reserved. | | 5 | * All Rights Reserved. |
6 | * | | 6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a | | 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
8 | * copy of this software and associated documentation files (the | | 8 | * copy of this software and associated documentation files (the |
9 | * "Software"), to deal in the Software without restriction, including | | 9 | * "Software"), to deal in the Software without restriction, including |
10 | * without limitation the rights to use, copy, modify, merge, publish, | | 10 | * without limitation the rights to use, copy, modify, merge, publish, |
11 | * distribute, sub license, and/or sell copies of the Software, and to | | 11 | * distribute, sub license, and/or sell copies of the Software, and to |
12 | * permit persons to whom the Software is furnished to do so, subject to | | 12 | * permit persons to whom the Software is furnished to do so, subject to |
13 | * the following conditions: | | 13 | * the following conditions: |
14 | * | | 14 | * |
| @@ -23,27 +23,27 @@ | | | @@ -23,27 +23,27 @@ |
23 | * The above copyright notice and this permission notice (including the | | 23 | * The above copyright notice and this permission notice (including the |
24 | * next paragraph) shall be included in all copies or substantial portions | | 24 | * next paragraph) shall be included in all copies or substantial portions |
25 | * of the Software. | | 25 | * of the Software. |
26 | * | | 26 | * |
27 | */ | | 27 | */ |
28 | /* | | 28 | /* |
29 | * Authors: | | 29 | * Authors: |
30 | * Jerome Glisse <glisse@freedesktop.org> | | 30 | * Jerome Glisse <glisse@freedesktop.org> |
31 | * Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | | 31 | * Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> |
32 | * Dave Airlie | | 32 | * Dave Airlie |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | __KERNEL_RCSID(0, "$NetBSD: radeon_ttm.c,v 1.23 2021/12/19 12:23:58 riastradh Exp $"); | | 36 | __KERNEL_RCSID(0, "$NetBSD: radeon_ttm.c,v 1.24 2021/12/23 17:09:25 hannken Exp $"); |
37 | | | 37 | |
38 | #include <linux/dma-mapping.h> | | 38 | #include <linux/dma-mapping.h> |
39 | #include <linux/pagemap.h> | | 39 | #include <linux/pagemap.h> |
40 | #include <linux/pci.h> | | 40 | #include <linux/pci.h> |
41 | #include <linux/seq_file.h> | | 41 | #include <linux/seq_file.h> |
42 | #include <linux/slab.h> | | 42 | #include <linux/slab.h> |
43 | #include <linux/swap.h> | | 43 | #include <linux/swap.h> |
44 | #include <linux/swiotlb.h> | | 44 | #include <linux/swiotlb.h> |
45 | | | 45 | |
46 | #include <drm/drm_agpsupport.h> | | 46 | #include <drm/drm_agpsupport.h> |
47 | #include <drm/drm_debugfs.h> | | 47 | #include <drm/drm_debugfs.h> |
48 | #include <drm/drm_device.h> | | 48 | #include <drm/drm_device.h> |
49 | #include <drm/drm_file.h> | | 49 | #include <drm/drm_file.h> |
| @@ -436,28 +436,28 @@ static int radeon_ttm_io_mem_reserve(str | | | @@ -436,28 +436,28 @@ static int radeon_ttm_io_mem_reserve(str |
436 | return -EINVAL; | | 436 | return -EINVAL; |
437 | switch (mem->mem_type) { | | 437 | switch (mem->mem_type) { |
438 | case TTM_PL_SYSTEM: | | 438 | case TTM_PL_SYSTEM: |
439 | /* system memory */ | | 439 | /* system memory */ |
440 | return 0; | | 440 | return 0; |
441 | case TTM_PL_TT: | | 441 | case TTM_PL_TT: |
442 | #if IS_ENABLED(CONFIG_AGP) | | 442 | #if IS_ENABLED(CONFIG_AGP) |
443 | if (rdev->flags & RADEON_IS_AGP) { | | 443 | if (rdev->flags & RADEON_IS_AGP) { |
444 | /* RADEON_IS_AGP is set only if AGP is active */ | | 444 | /* RADEON_IS_AGP is set only if AGP is active */ |
445 | mem->bus.offset = mem->start << PAGE_SHIFT; | | 445 | mem->bus.offset = mem->start << PAGE_SHIFT; |
446 | mem->bus.base = rdev->mc.agp_base; | | 446 | mem->bus.base = rdev->mc.agp_base; |
447 | mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture; | | 447 | mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture; |
448 | KASSERTMSG((mem->bus.base & (PAGE_SIZE - 1)) == 0, | | 448 | KASSERTMSG((mem->bus.base & (PAGE_SIZE - 1)) == 0, |
449 | "agp aperture is not page-aligned: %lx", | | 449 | "agp aperture is not page-aligned: %" PRIx64 "", |
450 | mem->bus.base); | | 450 | (uint64_t)mem->bus.base); |
451 | KASSERT((mem->bus.offset & (PAGE_SIZE - 1)) == 0); | | 451 | KASSERT((mem->bus.offset & (PAGE_SIZE - 1)) == 0); |
452 | } | | 452 | } |
453 | #endif | | 453 | #endif |
454 | break; | | 454 | break; |
455 | case TTM_PL_VRAM: | | 455 | case TTM_PL_VRAM: |
456 | mem->bus.offset = mem->start << PAGE_SHIFT; | | 456 | mem->bus.offset = mem->start << PAGE_SHIFT; |
457 | /* check if it's visible */ | | 457 | /* check if it's visible */ |
458 | if ((mem->bus.offset + mem->bus.size) > rdev->mc.visible_vram_size) | | 458 | if ((mem->bus.offset + mem->bus.size) > rdev->mc.visible_vram_size) |
459 | return -EINVAL; | | 459 | return -EINVAL; |
460 | mem->bus.base = rdev->mc.aper_base; | | 460 | mem->bus.base = rdev->mc.aper_base; |
461 | mem->bus.is_iomem = true; | | 461 | mem->bus.is_iomem = true; |
462 | #ifdef __alpha__ | | 462 | #ifdef __alpha__ |
463 | /* | | 463 | /* |
| @@ -475,28 +475,28 @@ static int radeon_ttm_io_mem_reserve(str | | | @@ -475,28 +475,28 @@ static int radeon_ttm_io_mem_reserve(str |
475 | if (!mem->bus.addr) | | 475 | if (!mem->bus.addr) |
476 | return -ENOMEM; | | 476 | return -ENOMEM; |
477 | | | 477 | |
478 | /* | | 478 | /* |
479 | * Alpha: Use just the bus offset plus | | 479 | * Alpha: Use just the bus offset plus |
480 | * the hose/domain memory base for bus.base. | | 480 | * the hose/domain memory base for bus.base. |
481 | * It then can be used to build PTEs for VRAM | | 481 | * It then can be used to build PTEs for VRAM |
482 | * access, as done in ttm_bo_vm_fault(). | | 482 | * access, as done in ttm_bo_vm_fault(). |
483 | */ | | 483 | */ |
484 | mem->bus.base = (mem->bus.base & 0x0ffffffffUL) + | | 484 | mem->bus.base = (mem->bus.base & 0x0ffffffffUL) + |
485 | rdev->ddev->hose->dense_mem_base; | | 485 | rdev->ddev->hose->dense_mem_base; |
486 | #endif | | 486 | #endif |
487 | KASSERTMSG((mem->bus.base & (PAGE_SIZE - 1)) == 0, | | 487 | KASSERTMSG((mem->bus.base & (PAGE_SIZE - 1)) == 0, |
488 | "mc aperture is not page-aligned: %lx", | | 488 | "mc aperture is not page-aligned: %" PRIx64 "", |
489 | mem->bus.base); | | 489 | (uint64_t)mem->bus.base); |
490 | KASSERT((mem->bus.offset & (PAGE_SIZE - 1)) == 0); | | 490 | KASSERT((mem->bus.offset & (PAGE_SIZE - 1)) == 0); |
491 | break; | | 491 | break; |
492 | default: | | 492 | default: |
493 | return -EINVAL; | | 493 | return -EINVAL; |
494 | } | | 494 | } |
495 | return 0; | | 495 | return 0; |
496 | } | | 496 | } |
497 | | | 497 | |
498 | static void radeon_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) | | 498 | static void radeon_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) |
499 | { | | 499 | { |
500 | } | | 500 | } |
501 | | | 501 | |
502 | /* | | 502 | /* |