Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/radeon drm: Sprinkle BUS_DMA_...



details:   https://anonhg.NetBSD.org/src/rev/b3d884b84e41
branches:  trunk
changeset: 1028608:b3d884b84e41
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:26:25 2021 +0000

description:
drm: Sprinkle BUS_DMA_COHERENT/NOCACHE and bus_dmamap_sync.

Algorithm:

- For dummy pages, use NOCACHE and PREREAD|PREWRITE.
- In #ifdef __NetBSD__ #else dma_alloc_coherent, use BUS_DMA_COHERENT.
- For (GPU) page tables we program, use PREWRITE.

diffstat:

 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.c                                    |  6 +++---
 sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c                                       |  8 +++++---
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mmu/nouveau_nvkm_subdev_mmu_vmmnv44.c |  6 +++---
 sys/external/bsd/drm2/dist/drm/radeon/radeon_device.c                                    |  6 ++++--
 sys/external/bsd/drm2/dist/drm/radeon/radeon_gart.c                                      |  8 +++++---
 5 files changed, 20 insertions(+), 14 deletions(-)

diffs (142 lines):

diff -r 3a545b979dc2 -r b3d884b84e41 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.c     Sun Dec 19 11:26:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.c     Sun Dec 19 11:26:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_ih.c,v 1.6 2021/12/19 10:20:10 riastradh Exp $  */
+/*     $NetBSD: amdgpu_ih.c,v 1.7 2021/12/19 11:26:25 riastradh Exp $  */
 
 /*
  * Copyright 2014 Advanced Micro Devices, Inc.
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_ih.c,v 1.6 2021/12/19 10:20:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_ih.c,v 1.7 2021/12/19 11:26:25 riastradh Exp $");
 
 #include <linux/dma-mapping.h>
 
@@ -84,7 +84,7 @@
                        goto fail0;
                }
                r = -bus_dmamem_map(adev->ddev->dmat, &ih->ring_seg, 1, size,
-                   &kva, BUS_DMA_WAITOK);
+                   &kva, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
                if (r) {
 fail2:                 bus_dmamap_destroy(adev->ddev->dmat, ih->ring_map);
                        ih->ring_map = NULL;
diff -r 3a545b979dc2 -r b3d884b84e41 sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c        Sun Dec 19 11:26:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gt/intel_gtt.c        Sun Dec 19 11:26:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_gtt.c,v 1.5 2021/12/19 11:12:13 riastradh Exp $  */
+/*     $NetBSD: intel_gtt.c,v 1.6 2021/12/19 11:26:26 riastradh Exp $  */
 
 // SPDX-License-Identifier: MIT
 /*
@@ -6,7 +6,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.5 2021/12/19 11:12:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.6 2021/12/19 11:26:26 riastradh Exp $");
 
 #include <linux/slab.h> /* fault-inject.h is not standalone! */
 
@@ -419,10 +419,12 @@
 
                /* Zero the page.  */
                ret = -bus_dmamem_map(vm->dmat, &vm->scratch_page.seg, 1,
-                   size, &kva, BUS_DMA_NOWAIT);
+                   size, &kva, BUS_DMA_NOWAIT|BUS_DMA_NOCACHE);
                if (ret)
                        goto unload_dmamap;
                memset(kva, 0, size);
+               bus_dmamap_sync(vm->dmat, vm->scratch_page.map, 0, size,
+                   BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
                bus_dmamem_unmap(vm->dmat, kva, size);
 
                /* XXX Is this page guaranteed to work as a huge page?  */
diff -r 3a545b979dc2 -r b3d884b84e41 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mmu/nouveau_nvkm_subdev_mmu_vmmnv44.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mmu/nouveau_nvkm_subdev_mmu_vmmnv44.c  Sun Dec 19 11:26:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mmu/nouveau_nvkm_subdev_mmu_vmmnv44.c  Sun Dec 19 11:26:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_subdev_mmu_vmmnv44.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $    */
+/*     $NetBSD: nouveau_nvkm_subdev_mmu_vmmnv44.c,v 1.4 2021/12/19 11:26:26 riastradh Exp $    */
 
 /*
  * Copyright 2017 Red Hat Inc.
@@ -22,7 +22,7 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mmu_vmmnv44.c,v 1.3 2021/12/19 10:51:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_mmu_vmmnv44.c,v 1.4 2021/12/19 11:26:26 riastradh Exp $");
 
 #include "vmm.h"
 
@@ -254,7 +254,7 @@
 
        /* XXX errno NetBSD->Linux */
        ret = -bus_dmamem_map(dmat, &vmm->nullseg, 1, nullsz,
-           &vmm->nullp, BUS_DMA_WAITOK);
+           &vmm->nullp, BUS_DMA_WAITOK|BUS_DMA_COHERENT);
        if (ret) {
 fail2:         bus_dmamap_destroy(dmat, vmm->nullmap);
                goto fail1;
diff -r 3a545b979dc2 -r b3d884b84e41 sys/external/bsd/drm2/dist/drm/radeon/radeon_device.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_device.c     Sun Dec 19 11:26:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_device.c     Sun Dec 19 11:26:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: radeon_device.c,v 1.11 2021/12/18 23:45:43 riastradh Exp $     */
+/*     $NetBSD: radeon_device.c,v 1.12 2021/12/19 11:26:26 riastradh Exp $     */
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_device.c,v 1.11 2021/12/18 23:45:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_device.c,v 1.12 2021/12/19 11:26:26 riastradh Exp $");
 
 #include <linux/console.h>
 #include <linux/efi.h>
@@ -839,6 +839,8 @@
                goto fail3;
 
        memset(rdev->dummy_page.rdp_addr, 0, PAGE_SIZE);
+       bus_dmamap_sync(rdev->ddev->dmat, rdev->dummy_page.rdp_map, 0,
+           PAGE_SIZE, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
        /* Success!  */
        rdev->dummy_page.addr = rdev->dummy_page.rdp_map->dm_segs[0].ds_addr;
diff -r 3a545b979dc2 -r b3d884b84e41 sys/external/bsd/drm2/dist/drm/radeon/radeon_gart.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_gart.c       Sun Dec 19 11:26:14 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_gart.c       Sun Dec 19 11:26:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: radeon_gart.c,v 1.13 2021/12/18 23:45:43 riastradh Exp $       */
+/*     $NetBSD: radeon_gart.c,v 1.14 2021/12/19 11:26:26 riastradh Exp $       */
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeon_gart.c,v 1.13 2021/12/18 23:45:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeon_gart.c,v 1.14 2021/12/19 11:26:26 riastradh Exp $");
 
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
@@ -99,7 +99,9 @@
        if (error)
                goto fail3;
 
-       memset((void *)rdev->gart.ptr, 0, rdev->gart.table_size);
+       memset(rdev->gart.ptr, 0, rdev->gart.table_size);
+       bus_dmamap_sync(rdev->ddev->dmat, rdev->gart.rg_table_map, 0,
+           rdev->gart.table_size, BUS_DMASYNC_PREWRITE);
 
        /* Success!  */
        rdev->gart.table_addr = rdev->gart.rg_table_map->dm_segs[0].ds_addr;



Home | Main Index | Thread Index | Old Index