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 amdgpu: Another pass through.



details:   https://anonhg.NetBSD.org/src/rev/8db3197b44c2
branches:  trunk
changeset: 1028869:8db3197b44c2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:21:29 2021 +0000

description:
amdgpu: Another pass through.

amdgpu_object.c
amdgpu_pci.c
amdgpu_pm.c
amdgpu_polaris10_smumgr.c
amdgpu_pp_psm.c
amdgpu_ppatomctrl.c
amdgpu_ppatomfwctrl.c
amdgpu_process_pptables_v1_0.o
amdgpu_psp.o
amdgpu_psp_v10_0.c
amdgpu_psp_v11_0.c
amdgpu_psp_v12_0.c
amdgpu_psp_v3_1.c
amdgpu_ras.c
amdgpu_ras_eeprom.c
amdgpu_rc_calc.c
amdgpu_rc_calc_dpi.c
amdgpu_ring.c
amdgpu_rlc.c
amdgpu_rn_clk_mgr.c
amdgpu_sdma_v3_0.c
amdgpu_sdma_v4_0.c
amdgpu_sdma_v5_0.c
amdgpu_si.c
amdgpu_si_dma.c
amdgpu_si_dpm.c
amdgpu_smu.c
amdgpu_smu10_hwmgr.c
amdgpu_smu7_hwmgr.c
amdgpu_smu8_hwmgr.c
amdgpu_smu8_smumgr.c
amdgpu_smu_v11_0.c (and a sprinkling of consts)
amdgpu_smu_v11_0_i2c.c
amdgpu_soc15.c
amdgpu_tonga_smumgr.c
amdgpu_ttm.c
amdgpu_ucode.c
amdgpu_uvd.c
amdgpu_uvd_v5_0.c
amdgpu_uvd_v6_0.c
amdgpu_uvd_v7_0.c
amdgpu_vce.c
amdgpu_vce_v2_0.c
amdgpu_vce_v4_0.c
amdgpu_vcn_v1_0.c
amdgpu_vcn_v2_0.c
amdgpu_vcn_v2_5.c
amdgpu_vega10_hwmgr.c
amdgpu_vega10_powertune.c
amdgpu_vega10_processpptables.c
amdgpu_vega10_reg_init.c
amdgpu_vega12_hwmgr.c
amdgpu_vega20_hwmgr.c
amdgpu_vega20_ppt.c
amdgpu_vega20_reg_init.c
amdgpu_vi.c
amdgpu_virt.c
amdgpu_vram_mgr.c
amdgpu_xgmi.c -- disable (for now?)
amdgpufb.c

diffstat:

 sys/external/bsd/drm2/amdgpu/amdgpu_pci.c                                          |  35 ++-
 sys/external/bsd/drm2/amdgpu/amdgpufb.c                                            |   8 +-
 sys/external/bsd/drm2/amdgpu/files.amdgpu                                          |  15 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c                            |  60 +++++++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.h                            |   7 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc.h                             |   5 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v10_0.c                       |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v6_0.c                        |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v7_0.c                        |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v8_0.c                        |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gmc_v9_0.c                        |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_object.c                          |   7 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_pm.c                              |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp.c                             |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp.h                             |  20 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp_v10_0.c                       |  10 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp_v11_0.c                       |  29 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp_v12_0.c                       |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_psp_v3_1.c                        |  10 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras.c                             |  29 ++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ras_eeprom.c                      |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ring.c                            |  10 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_rlc.c                             |  16 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sdma_v3_0.c                       |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sdma_v4_0.c                       |  30 ++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_sdma_v5_0.c                       |  24 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c                              |  14 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si_dma.c                          |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si_dpm.c                          |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_smu_v11_0_i2c.c                   |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_soc15.c                           |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ttm.c                             |  78 +++++++--
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ttm.h                             |   7 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ucode.c                           |  28 ++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_uvd.c                             |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_uvd_v5_0.c                        |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_uvd_v6_0.c                        |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_uvd_v7_0.c                        |  10 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vce.c                             |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vce_v2_0.c                        |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vce_v4_0.c                        |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vcn_v1_0.c                        |  18 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vcn_v2_0.c                        |  16 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vcn_v2_5.c                        |  16 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c                              |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_virt.c                            |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vram_mgr.c                        |  19 ++-
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/atom.h                                   |   3 +-
 sys/external/bsd/drm2/dist/drm/amd/display/dc/clk_mgr/dcn21/amdgpu_rn_clk_mgr.c    |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/amdgpu_arcturus_ppt.c                 |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/amdgpu_navi10_ppt.c                   |  14 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/amdgpu_smu.c                          |  12 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/amdgpu_smu_v11_0.c                    |  28 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/amdgpu_vega20_ppt.c                   |  16 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_pp_psm.c                 |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_ppatomctrl.c             |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_ppatomfwctrl.c           |  24 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_process_pptables_v1_0.c  |  28 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu10_hwmgr.c            |  18 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c             |  38 ++--
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu8_hwmgr.c             |  12 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_vega10_hwmgr.c           |  48 +++---
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_vega10_powertune.c       |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_vega10_processpptables.c |  30 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_vega12_hwmgr.c           |  22 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_vega20_hwmgr.c           |  12 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/ppevvmath.h                     |  22 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/inc/amdgpu_smu.h                      |   6 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/smumgr/amdgpu_polaris10_smumgr.c      |  28 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/smumgr/amdgpu_smu8_smumgr.c           |   8 +-
 sys/external/bsd/drm2/dist/drm/amd/powerplay/smumgr/amdgpu_tonga_smumgr.c          |   6 +-
 sys/external/bsd/drm2/include/drm/drmfb.h                                          |   3 +-
 sys/external/bsd/drm2/include/linux/atomic.h                                       |   8 +-
 sys/external/bsd/drm2/include/linux/bitmap.h                                       |  36 ++++-
 sys/external/bsd/drm2/include/linux/dma-mapping.h                                  |   4 +-
 sys/external/bsd/drm2/include/linux/dma-resv.h                                     |   4 +-
 sys/external/bsd/drm2/include/linux/ktime.h                                        |   8 +-
 sys/external/bsd/drm2/include/linux/mm.h                                           |   4 +-
 sys/external/bsd/drm2/include/linux/pfn.h                                          |  38 ++++
 sys/external/bsd/drm2/linux/linux_dma_resv.c                                       |  16 +-
 80 files changed, 765 insertions(+), 436 deletions(-)

diffs (truncated from 4363 to 300 lines):

diff -r 148330aaf98d -r 8db3197b44c2 sys/external/bsd/drm2/amdgpu/amdgpu_pci.c
--- a/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c Sun Dec 19 12:21:10 2021 +0000
+++ b/sys/external/bsd/drm2/amdgpu/amdgpu_pci.c Sun Dec 19 12:21:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_pci.c,v 1.8 2021/12/19 11:53:50 riastradh Exp $ */
+/*     $NetBSD: amdgpu_pci.c,v 1.9 2021/12/19 12:21:29 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,13 +30,22 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.8 2021/12/19 11:53:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_pci.c,v 1.9 2021/12/19 12:21:29 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/queue.h>
 #include <sys/systm.h>
 #include <sys/workqueue.h>
 
+#include <dev/pci/pcivar.h>
+
+#include <linux/pci.h>
+
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_pci.h>
+
 #include <amdgpu.h>
 #include "amdgpu_drv.h"
 #include "amdgpu_task.h"
@@ -222,25 +231,25 @@
                return error;
 
        if (sc->sc_task_state == AMDGPU_TASK_ATTACH)
-               goto out;
+               goto out0;
        if (sc->sc_task_u.workqueue != NULL) {
                workqueue_destroy(sc->sc_task_u.workqueue);
                sc->sc_task_u.workqueue = NULL;
        }
 
        if (sc->sc_drm_dev == NULL)
-               goto out0;
+               goto out1;
        if (!sc->sc_pci_attached)
-               goto out1;
+               goto out2;
        if (!sc->sc_dev_registered)
-               goto out2;
+               goto out3;
 
        drm_dev_unregister(sc->sc_drm_dev);
-out2:  drm_pci_detach(sc->sc_drm_dev);
-out1:  drm_dev_put(sc->sc_drm_dev);
+out3:  drm_pci_detach(sc->sc_drm_dev);
+out2:  drm_dev_put(sc->sc_drm_dev);
        sc->sc_drm_dev = NULL;
-out0:  linux_pci_dev_destroy(&sc->sc_pci_dev);
-       pmf_device_deregister(self);
+out1:  linux_pci_dev_destroy(&sc->sc_pci_dev);
+out0:  pmf_device_deregister(self);
        return 0;
 }
 
@@ -250,12 +259,11 @@
        struct amdgpu_softc *const sc = device_private(self);
        struct drm_device *const dev = sc->sc_drm_dev;
        int ret;
-       bool is_console = true; /* XXX */
 
        if (dev == NULL)
                return true;
 
-       ret = amdgpu_suspend_kms(dev, true, is_console);
+       ret = amdgpu_device_suspend(dev, /*fbcon*/true);
        if (ret)
                return false;
 
@@ -268,12 +276,11 @@
        struct amdgpu_softc *const sc = device_private(self);
        struct drm_device *const dev = sc->sc_drm_dev;
        int ret;
-       bool is_console = true; /* XXX */
 
        if (dev == NULL)
                return true;
 
-       ret = amdgpu_resume_kms(dev, true, is_console);
+       ret = amdgpu_device_resume(dev, /*fbcon*/true);
        if (ret)
                return false;
 
diff -r 148330aaf98d -r 8db3197b44c2 sys/external/bsd/drm2/amdgpu/amdgpufb.c
--- a/sys/external/bsd/drm2/amdgpu/amdgpufb.c   Sun Dec 19 12:21:10 2021 +0000
+++ b/sys/external/bsd/drm2/amdgpu/amdgpufb.c   Sun Dec 19 12:21:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpufb.c,v 1.2 2021/12/19 10:32:59 riastradh Exp $   */
+/*     $NetBSD: amdgpufb.c,v 1.3 2021/12/19 12:21:29 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpufb.c,v 1.2 2021/12/19 10:32:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpufb.c,v 1.3 2021/12/19 12:21:29 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/bus.h>
@@ -178,9 +178,7 @@
            struct amdgpufb_softc, sc_drmfb);
        struct drm_fb_helper *const helper = sc->sc_afa.afa_fb_helper;
        struct drm_framebuffer *const fb = helper->fb;
-       struct amdgpu_framebuffer *const rfb = container_of(fb,
-           struct amdgpu_framebuffer, base);
-       struct drm_gem_object *const gobj = rfb->obj;
+       struct drm_gem_object *const gobj = fb->obj[0];
        struct amdgpu_bo *const rbo = gem_to_amdgpu_bo(gobj);
        const unsigned num_pages __diagused = rbo->tbo.num_pages;
        int flags = 0;
diff -r 148330aaf98d -r 8db3197b44c2 sys/external/bsd/drm2/amdgpu/files.amdgpu
--- a/sys/external/bsd/drm2/amdgpu/files.amdgpu Sun Dec 19 12:21:10 2021 +0000
+++ b/sys/external/bsd/drm2/amdgpu/files.amdgpu Sun Dec 19 12:21:29 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amdgpu,v 1.21 2021/12/19 12:02:38 riastradh Exp $
+#      $NetBSD: files.amdgpu,v 1.22 2021/12/19 12:21:29 riastradh Exp $
 
 version        20180827
 
@@ -42,6 +42,8 @@
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu"+="-Wno-pointer-arith"
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu"+="-Wno-override-init"
 
+makeoptions    amdgpufb        "CWARNFLAGS.amdgpufb"+="-Wno-pointer-arith"
+
 # Half the file strips const qualifier; file is small enough this is
 # not an issue.
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu_arct_reg_init.c"+="-Wno-cast-qual"
@@ -53,6 +55,13 @@
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu_hw_generic.c"+="-Wno-type-limits"
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu_hw_hpd.c"+="-Wno-type-limits"
 makeoptions    amdgpu  "CWARNFLAGS.amdgpu_navi10_ppt.c"+="-Wno-type-limits"
+makeoptions    amdgpu  "CWARNFLAGS.amdgpu_rn_clk_mgr.c"+="-Wno-type-limits"
+
+# Small file, mostly casts that remove const in a way that is harmless,
+# so let's just disable the warning on it for now rather than patch
+# half the file.
+makeoptions    amdgpu  "CWARNFLAGS.amdgpu_vega10_reg_init.c"+="-Wno-cast-qual"
+makeoptions    amdgpu  "CWARNFLAGS.amdgpu_vega20_reg_init.c"+="-Wno-cast-qual"
 
 ifdef amd64
 makeoptions    amdgpu  "COPTS.amdgpu_dcn20_resource.c"+="-mhard-float -msse -msse2"
@@ -69,6 +78,8 @@
 makeoptions    amdgpu  "COPTS.amdgpu_display_rq_dlg_calc_21.c"+="-mhard-float -msse -msse2"
 makeoptions    amdgpu  "COPTS.amdgpu_dml1_display_rq_dlg_calc.c"+="-mhard-float -msse -msse2"
 makeoptions    amdgpu  "COPTS.amdgpu_dml_common_defs.c"+="-mhard-float -msse -msse2"
+makeoptions    amdgpu  "COPTS.amdgpu_rc_calc.c"+="-mhard-float -msse -msse2"
+makeoptions    amdgpu  "COPTS.amdgpu_rc_calc_dpi.c"+="-mhard-float -msse -msse2"
 endif
 
 # Local additions.
@@ -486,4 +497,4 @@
 file   external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vm_cpu.c   amdgpu
 file   external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vm_sdma.c  amdgpu
 file   external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vram_mgr.c amdgpu
-file   external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_xgmi.c     amdgpu
+#file  external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_xgmi.c     amdgpu
diff -r 148330aaf98d -r 8db3197b44c2 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c   Sun Dec 19 12:21:10 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c   Sun Dec 19 12:21:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_gart.c,v 1.6 2021/12/19 12:02:39 riastradh Exp $        */
+/*     $NetBSD: amdgpu_gart.c,v 1.7 2021/12/19 12:21:29 riastradh Exp $        */
 
 /*
  * Copyright 2008 Advanced Micro Devices, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.6 2021/12/19 12:02:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_gart.c,v 1.7 2021/12/19 12:21:29 riastradh Exp $");
 
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
@@ -294,7 +294,7 @@
  * Common gart functions.
  */
 #ifdef __NetBSD__
-void
+int
 amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t gpu_start,
     unsigned npages)
 {
@@ -311,7 +311,7 @@
 
        if (!adev->gart.ready) {
                WARN(1, "trying to bind memory to uninitialized GART !\n");
-               return;
+               return -EINVAL;
        }
 
        amdgpu_gart_pre_update(adev, gpu_pgstart, gpu_npages);
@@ -329,6 +329,8 @@
                }
        }
        amdgpu_gart_post_update(adev, gpu_pgstart, gpu_npages);
+
+       return 0;
 }
 #else  /* __NetBSD__ */
 /**
@@ -380,6 +382,7 @@
 
        return 0;
 }
+#endif /* __NetBSD__ */
 
 /**
  * amdgpu_gart_map - map dma_addresses into GART entries
@@ -394,6 +397,55 @@
  * Map the dma_addresses into GART entries (all asics).
  * Returns 0 for success, -EINVAL for failure.
  */
+#ifdef __NetBSD__
+int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t gpu_start,
+    unsigned npages, bus_size_t map_start, bus_dmamap_t dmamap, uint32_t flags,
+    void *dst)
+{
+       bus_size_t seg_off = 0;
+       unsigned i, j, t;
+
+       CTASSERT(AMDGPU_GPU_PAGE_SIZE <= PAGE_SIZE);
+       CTASSERT((PAGE_SIZE % AMDGPU_GPU_PAGE_SIZE) == 0);
+
+       KASSERT((gpu_start & (PAGE_SIZE - 1)) == 0);
+
+       if (!adev->gart.ready) {
+               WARN(1, "trying to bind memory to uninitialized GART !\n");
+               return -EINVAL;
+       }
+
+       for (i = 0; i < dmamap->dm_nsegs; i++) {
+               KASSERT((dmamap->dm_segs[i].ds_len & (PAGE_SIZE - 1)) == 0);
+               if (map_start == 0)
+                       break;
+               if (map_start < dmamap->dm_segs[i].ds_len) {
+                       seg_off = map_start;
+                       break;
+               }
+               map_start -= dmamap->dm_segs[i].ds_len;
+       }
+       KASSERT(i < dmamap->dm_nsegs);
+
+       t = gpu_start / AMDGPU_GPU_PAGE_SIZE;
+
+       for (i = 0; npages --> 0;) {
+               KASSERT(i < dmamap->dm_nsegs);
+               for (j = 0; j < AMDGPU_GPU_PAGES_IN_CPU_PAGE; j++) {
+                       amdgpu_gmc_set_pte_pde(adev, dst, t,
+                           dmamap->dm_segs[i].ds_addr + seg_off, flags);
+                       seg_off += AMDGPU_GPU_PAGE_SIZE;
+                       if (seg_off == dmamap->dm_segs[i].ds_len) {
+                               i++;
+                               seg_off = 0;
+                       }
+                       KASSERT(seg_off < dmamap->dm_segs[i].ds_len);
+               }
+       }
+
+       return 0;
+}
+#else
 int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,
                    int pages, dma_addr_t *dma_addr, uint64_t flags,
                    void *dst)
diff -r 148330aaf98d -r 8db3197b44c2 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.h
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.h   Sun Dec 19 12:21:10 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.h   Sun Dec 19 12:21:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_gart.h,v 1.3 2021/12/19 12:02:39 riastradh Exp $        */
+/*     $NetBSD: amdgpu_gart.h,v 1.4 2021/12/19 12:21:29 riastradh Exp $        */
 
 /*
  * Copyright 2017 Advanced Micro Devices, Inc.
@@ -68,8 +68,11 @@
 int amdgpu_gart_init(struct amdgpu_device *adev);
 void amdgpu_gart_fini(struct amdgpu_device *adev);
 #ifdef __NetBSD__
-void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t gpu_start,
+int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t gpu_start,
     unsigned npages);
+int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t gpu_start,
+    unsigned npages, bus_size_t map_start, bus_dmamap_t map, uint32_t flags,
+    void *dst);
 int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t gpu_start,



Home | Main Index | Thread Index | Old Index