aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2014-07-17 06:01:07 -0400
committerAlex Deucher <alexander.deucher@amd.com>2014-08-05 08:53:32 -0400
commit77497f2735ad6e29c55475e15e9790dbfa2c2ef8 (patch)
tree4799ae3520773f139a24cf5ea539fede1fd5d54b /drivers
parenta3eb06dbca08e3fdad7039021ae03b46b215f22a (diff)
drm/radeon: Pass GART page flags to radeon_gart_set_page() explicitly
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/radeon/r100.c2
-rw-r--r--drivers/gpu/drm/radeon/r300.c12
-rw-r--r--drivers/gpu/drm/radeon/radeon.h12
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h8
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c8
-rw-r--r--drivers/gpu/drm/radeon/rs400.c13
-rw-r--r--drivers/gpu/drm/radeon/rs600.c16
8 files changed, 56 insertions, 24 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index cceef2711310..5fd242795178 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -682,7 +682,7 @@ void r100_pci_gart_disable(struct radeon_device *rdev)
682} 682}
683 683
684void r100_pci_gart_set_page(struct radeon_device *rdev, unsigned i, 684void r100_pci_gart_set_page(struct radeon_device *rdev, unsigned i,
685 uint64_t addr) 685 uint64_t addr, uint32_t flags)
686{ 686{
687 u32 *gtt = rdev->gart.ptr; 687 u32 *gtt = rdev->gart.ptr;
688 gtt[i] = cpu_to_le32(lower_32_bits(addr)); 688 gtt[i] = cpu_to_le32(lower_32_bits(addr));
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 8d14e665f241..75b30338c226 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -69,17 +69,23 @@ void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
69 mb(); 69 mb();
70} 70}
71 71
72#define R300_PTE_UNSNOOPED (1 << 0)
72#define R300_PTE_WRITEABLE (1 << 2) 73#define R300_PTE_WRITEABLE (1 << 2)
73#define R300_PTE_READABLE (1 << 3) 74#define R300_PTE_READABLE (1 << 3)
74 75
75void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i, 76void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i,
76 uint64_t addr) 77 uint64_t addr, uint32_t flags)
77{ 78{
78 void __iomem *ptr = rdev->gart.ptr; 79 void __iomem *ptr = rdev->gart.ptr;
79 80
80 addr = (lower_32_bits(addr) >> 8) | 81 addr = (lower_32_bits(addr) >> 8) |
81 ((upper_32_bits(addr) & 0xff) << 24) | 82 ((upper_32_bits(addr) & 0xff) << 24);
82 R300_PTE_WRITEABLE | R300_PTE_READABLE; 83 if (flags & RADEON_GART_PAGE_READ)
84 addr |= R300_PTE_READABLE;
85 if (flags & RADEON_GART_PAGE_WRITE)
86 addr |= R300_PTE_WRITEABLE;
87 if (!(flags & RADEON_GART_PAGE_SNOOP))
88 addr |= R300_PTE_UNSNOOPED;
83 /* on x86 we want this to be CPU endian, on powerpc 89 /* on x86 we want this to be CPU endian, on powerpc
84 * on powerpc without HW swappers, it'll get swapped on way 90 * on powerpc without HW swappers, it'll get swapped on way
85 * into VRAM - so no need for cpu_to_le32 on VRAM tables */ 91 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 43bc99b3926f..b1eea04a329e 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -593,6 +593,12 @@ struct radeon_mc;
593#define RADEON_GPU_PAGE_SHIFT 12 593#define RADEON_GPU_PAGE_SHIFT 12
594#define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK) 594#define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
595 595
596#define RADEON_GART_PAGE_DUMMY 0
597#define RADEON_GART_PAGE_VALID (1 << 0)
598#define RADEON_GART_PAGE_READ (1 << 1)
599#define RADEON_GART_PAGE_WRITE (1 << 2)
600#define RADEON_GART_PAGE_SNOOP (1 << 3)
601
596struct radeon_gart { 602struct radeon_gart {
597 dma_addr_t table_addr; 603 dma_addr_t table_addr;
598 struct radeon_bo *robj; 604 struct radeon_bo *robj;
@@ -617,7 +623,7 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
617 int pages); 623 int pages);
618int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, 624int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
619 int pages, struct page **pagelist, 625 int pages, struct page **pagelist,
620 dma_addr_t *dma_addr); 626 dma_addr_t *dma_addr, uint32_t flags);
621 627
622 628
623/* 629/*
@@ -1784,7 +1790,7 @@ struct radeon_asic {
1784 struct { 1790 struct {
1785 void (*tlb_flush)(struct radeon_device *rdev); 1791 void (*tlb_flush)(struct radeon_device *rdev);
1786 void (*set_page)(struct radeon_device *rdev, unsigned i, 1792 void (*set_page)(struct radeon_device *rdev, unsigned i,
1787 uint64_t addr); 1793 uint64_t addr, uint32_t flags);
1788 } gart; 1794 } gart;
1789 struct { 1795 struct {
1790 int (*init)(struct radeon_device *rdev); 1796 int (*init)(struct radeon_device *rdev);
@@ -2745,7 +2751,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
2745#define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state)) 2751#define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
2746#define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev)) 2752#define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
2747#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev)) 2753#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
2748#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p)) 2754#define radeon_gart_set_page(rdev, i, p, f) (rdev)->asic->gart.set_page((rdev), (i), (p), (f))
2749#define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev)) 2755#define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
2750#define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev)) 2756#define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
2751#define radeon_asic_vm_set_page(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (ib), (pe), (addr), (count), (incr), (flags))) 2757#define radeon_asic_vm_set_page(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_page((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 01e7c0ad8f01..f632e31b3554 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -68,7 +68,7 @@ int r100_asic_reset(struct radeon_device *rdev);
68u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc); 68u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc);
69void r100_pci_gart_tlb_flush(struct radeon_device *rdev); 69void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
70void r100_pci_gart_set_page(struct radeon_device *rdev, unsigned i, 70void r100_pci_gart_set_page(struct radeon_device *rdev, unsigned i,
71 uint64_t addr); 71 uint64_t addr, uint32_t flags);
72void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring); 72void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring);
73int r100_irq_set(struct radeon_device *rdev); 73int r100_irq_set(struct radeon_device *rdev);
74int r100_irq_process(struct radeon_device *rdev); 74int r100_irq_process(struct radeon_device *rdev);
@@ -173,7 +173,7 @@ extern void r300_fence_ring_emit(struct radeon_device *rdev,
173extern int r300_cs_parse(struct radeon_cs_parser *p); 173extern int r300_cs_parse(struct radeon_cs_parser *p);
174extern void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev); 174extern void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev);
175extern void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i, 175extern void rv370_pcie_gart_set_page(struct radeon_device *rdev, unsigned i,
176 uint64_t addr); 176 uint64_t addr, uint32_t flags);
177extern void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes); 177extern void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes);
178extern int rv370_get_pcie_lanes(struct radeon_device *rdev); 178extern int rv370_get_pcie_lanes(struct radeon_device *rdev);
179extern void r300_set_reg_safe(struct radeon_device *rdev); 179extern void r300_set_reg_safe(struct radeon_device *rdev);
@@ -209,7 +209,7 @@ extern int rs400_suspend(struct radeon_device *rdev);
209extern int rs400_resume(struct radeon_device *rdev); 209extern int rs400_resume(struct radeon_device *rdev);
210void rs400_gart_tlb_flush(struct radeon_device *rdev); 210void rs400_gart_tlb_flush(struct radeon_device *rdev);
211void rs400_gart_set_page(struct radeon_device *rdev, unsigned i, 211void rs400_gart_set_page(struct radeon_device *rdev, unsigned i,
212 uint64_t addr); 212 uint64_t addr, uint32_t flags);
213uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg); 213uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg);
214void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 214void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
215int rs400_gart_init(struct radeon_device *rdev); 215int rs400_gart_init(struct radeon_device *rdev);
@@ -233,7 +233,7 @@ void rs600_irq_disable(struct radeon_device *rdev);
233u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc); 233u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc);
234void rs600_gart_tlb_flush(struct radeon_device *rdev); 234void rs600_gart_tlb_flush(struct radeon_device *rdev);
235void rs600_gart_set_page(struct radeon_device *rdev, unsigned i, 235void rs600_gart_set_page(struct radeon_device *rdev, unsigned i,
236 uint64_t addr); 236 uint64_t addr, uint32_t flags);
237uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg); 237uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg);
238void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 238void rs600_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
239void rs600_bandwidth_update(struct radeon_device *rdev); 239void rs600_bandwidth_update(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index b7d3e846cd76..d684642d900b 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -243,7 +243,8 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
243 page_base = rdev->gart.pages_addr[p]; 243 page_base = rdev->gart.pages_addr[p];
244 for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) { 244 for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) {
245 if (rdev->gart.ptr) { 245 if (rdev->gart.ptr) {
246 radeon_gart_set_page(rdev, t, page_base); 246 radeon_gart_set_page(rdev, t, page_base,
247 RADEON_GART_PAGE_DUMMY);
247 } 248 }
248 page_base += RADEON_GPU_PAGE_SIZE; 249 page_base += RADEON_GPU_PAGE_SIZE;
249 } 250 }
@@ -261,13 +262,15 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
261 * @pages: number of pages to bind 262 * @pages: number of pages to bind
262 * @pagelist: pages to bind 263 * @pagelist: pages to bind
263 * @dma_addr: DMA addresses of pages 264 * @dma_addr: DMA addresses of pages
265 * @flags: RADEON_GART_PAGE_* flags
264 * 266 *
265 * Binds the requested pages to the gart page table 267 * Binds the requested pages to the gart page table
266 * (all asics). 268 * (all asics).
267 * Returns 0 for success, -EINVAL for failure. 269 * Returns 0 for success, -EINVAL for failure.
268 */ 270 */
269int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, 271int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
270 int pages, struct page **pagelist, dma_addr_t *dma_addr) 272 int pages, struct page **pagelist, dma_addr_t *dma_addr,
273 uint32_t flags)
271{ 274{
272 unsigned t; 275 unsigned t;
273 unsigned p; 276 unsigned p;
@@ -287,7 +290,7 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
287 if (rdev->gart.ptr) { 290 if (rdev->gart.ptr) {
288 page_base = rdev->gart.pages_addr[p]; 291 page_base = rdev->gart.pages_addr[p];
289 for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) { 292 for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) {
290 radeon_gart_set_page(rdev, t, page_base); 293 radeon_gart_set_page(rdev, t, page_base, flags);
291 page_base += RADEON_GPU_PAGE_SIZE; 294 page_base += RADEON_GPU_PAGE_SIZE;
292 } 295 }
293 } 296 }
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index c8a8a5144ec1..7fb7c1cc6af3 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -521,6 +521,8 @@ static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
521 struct ttm_mem_reg *bo_mem) 521 struct ttm_mem_reg *bo_mem)
522{ 522{
523 struct radeon_ttm_tt *gtt = (void*)ttm; 523 struct radeon_ttm_tt *gtt = (void*)ttm;
524 uint32_t flags = RADEON_GART_PAGE_VALID | RADEON_GART_PAGE_READ |
525 RADEON_GART_PAGE_WRITE;
524 int r; 526 int r;
525 527
526 gtt->offset = (unsigned long)(bo_mem->start << PAGE_SHIFT); 528 gtt->offset = (unsigned long)(bo_mem->start << PAGE_SHIFT);
@@ -528,8 +530,10 @@ static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
528 WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n", 530 WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n",
529 ttm->num_pages, bo_mem, ttm); 531 ttm->num_pages, bo_mem, ttm);
530 } 532 }
531 r = radeon_gart_bind(gtt->rdev, gtt->offset, 533 if (ttm->caching_state == tt_cached)
532 ttm->num_pages, ttm->pages, gtt->ttm.dma_address); 534 flags |= RADEON_GART_PAGE_SNOOP;
535 r = radeon_gart_bind(gtt->rdev, gtt->offset, ttm->num_pages,
536 ttm->pages, gtt->ttm.dma_address, flags);
533 if (r) { 537 if (r) {
534 DRM_ERROR("failed to bind %lu pages at 0x%08X\n", 538 DRM_ERROR("failed to bind %lu pages at 0x%08X\n",
535 ttm->num_pages, (unsigned)gtt->offset); 539 ttm->num_pages, (unsigned)gtt->offset);
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index 4519f9c93162..6c1fc339d228 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -208,17 +208,24 @@ void rs400_gart_fini(struct radeon_device *rdev)
208 radeon_gart_table_ram_free(rdev); 208 radeon_gart_table_ram_free(rdev);
209} 209}
210 210
211#define RS400_PTE_UNSNOOPED (1 << 0)
211#define RS400_PTE_WRITEABLE (1 << 2) 212#define RS400_PTE_WRITEABLE (1 << 2)
212#define RS400_PTE_READABLE (1 << 3) 213#define RS400_PTE_READABLE (1 << 3)
213 214
214void rs400_gart_set_page(struct radeon_device *rdev, unsigned i, uint64_t addr) 215void rs400_gart_set_page(struct radeon_device *rdev, unsigned i,
216 uint64_t addr, uint32_t flags)
215{ 217{
216 uint32_t entry; 218 uint32_t entry;
217 u32 *gtt = rdev->gart.ptr; 219 u32 *gtt = rdev->gart.ptr;
218 220
219 entry = (lower_32_bits(addr) & PAGE_MASK) | 221 entry = (lower_32_bits(addr) & PAGE_MASK) |
220 ((upper_32_bits(addr) & 0xff) << 4) | 222 ((upper_32_bits(addr) & 0xff) << 4);
221 RS400_PTE_WRITEABLE | RS400_PTE_READABLE; 223 if (flags & RADEON_GART_PAGE_READ)
224 addr |= RS400_PTE_READABLE;
225 if (flags & RADEON_GART_PAGE_WRITE)
226 addr |= RS400_PTE_WRITEABLE;
227 if (!(flags & RADEON_GART_PAGE_SNOOP))
228 entry |= RS400_PTE_UNSNOOPED;
222 entry = cpu_to_le32(entry); 229 entry = cpu_to_le32(entry);
223 gtt[i] = entry; 230 gtt[i] = entry;
224} 231}
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 27a56ad3a727..5f6db4629aaa 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -625,15 +625,21 @@ static void rs600_gart_fini(struct radeon_device *rdev)
625 radeon_gart_table_vram_free(rdev); 625 radeon_gart_table_vram_free(rdev);
626} 626}
627 627
628void rs600_gart_set_page(struct radeon_device *rdev, unsigned i, uint64_t addr) 628void rs600_gart_set_page(struct radeon_device *rdev, unsigned i,
629 uint64_t addr, uint32_t flags)
629{ 630{
630 void __iomem *ptr = (void *)rdev->gart.ptr; 631 void __iomem *ptr = (void *)rdev->gart.ptr;
631 632
632 addr = addr & 0xFFFFFFFFFFFFF000ULL; 633 addr = addr & 0xFFFFFFFFFFFFF000ULL;
633 if (addr == rdev->dummy_page.addr) 634 addr |= R600_PTE_SYSTEM;
634 addr |= R600_PTE_SYSTEM | R600_PTE_SNOOPED; 635 if (flags & RADEON_GART_PAGE_VALID)
635 else 636 addr |= R600_PTE_VALID;
636 addr |= R600_PTE_GART; 637 if (flags & RADEON_GART_PAGE_READ)
638 addr |= R600_PTE_READABLE;
639 if (flags & RADEON_GART_PAGE_WRITE)
640 addr |= R600_PTE_WRITEABLE;
641 if (flags & RADEON_GART_PAGE_SNOOP)
642 addr |= R600_PTE_SNOOPED;
637 writeq(addr, ptr + (i * 8)); 643 writeq(addr, ptr + (i * 8));
638} 644}
639 645