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 Update intel gtt API.



details:   https://anonhg.NetBSD.org/src/rev/cb903cb3cbfc
branches:  trunk
changeset: 1028006:cb903cb3cbfc
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:35:10 2021 +0000

description:
Update intel gtt API.

TODO: Find where the stolen memory base is in agp_i810.

diffstat:

 sys/external/bsd/drm2/i915drm/intel_gtt.c     |  74 ++++++++++++++++++--------
 sys/external/bsd/drm2/include/drm/intel-gtt.h |   9 ++-
 2 files changed, 58 insertions(+), 25 deletions(-)

diffs (177 lines):

diff -r 56e8cdd91556 -r cb903cb3cbfc sys/external/bsd/drm2/i915drm/intel_gtt.c
--- a/sys/external/bsd/drm2/i915drm/intel_gtt.c Sun Dec 19 01:35:04 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/intel_gtt.c Sun Dec 19 01:35:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_gtt.c,v 1.11 2018/08/27 16:15:23 riastradh Exp $ */
+/*     $NetBSD: intel_gtt.c,v 1.12 2021/12/19 01:35:10 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 /* Intel GTT stubs */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.11 2018/08/27 16:15:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_gtt.c,v 1.12 2021/12/19 01:35:10 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/bus.h>
@@ -53,15 +53,15 @@
        bus_dmamap_t            scratch_map;
 } intel_gtt;
 
+struct resource intel_graphics_stolen_res;
+
 void
-intel_gtt_get(uint64_t *va_size, size_t *stolen_size, bus_addr_t *aper_base,
-    uint64_t *aper_size)
+intel_gtt_get(uint64_t *va_size, bus_addr_t *aper_base, uint64_t *aper_size)
 {
        struct agp_softc *const sc = agp_i810_sc;
 
        if (sc == NULL) {
                *va_size = 0;
-               *stolen_size = 0;
                *aper_base = 0;
                *aper_size = 0;
                return;
@@ -69,9 +69,13 @@
 
        struct agp_i810_softc *const isc = sc->as_chipc;
        *va_size = ((size_t)(isc->gtt_size/sizeof(uint32_t)) << PAGE_SHIFT);
-       *stolen_size = ((size_t)isc->stolen << PAGE_SHIFT);
        *aper_base = sc->as_apaddr;
        *aper_size = sc->as_apsize;
+
+#ifdef notyet
+       intel_graphics_stolen_res.base = ...;
+       intel_graphics_stolen_res.size = isc->stolen;
+#endif
 }
 
 int
@@ -143,21 +147,11 @@
        agp_i810_chipset_flush(agp_i810_sc->as_chipc);
 }
 
-void
-intel_gtt_insert_sg_entries(bus_dmamap_t dmamap, unsigned va_page,
-    unsigned flags)
+static int
+intel_gtt_flags(unsigned flags)
 {
-       struct agp_i810_softc *const isc = agp_i810_sc->as_chipc;
-       off_t va = (va_page << PAGE_SHIFT);
-       unsigned seg;
-       int gtt_flags = 0;
-       int error;
+       int gtt_flags = AGP_I810_GTT_VALID;
 
-       KASSERT(0 <= va);
-       KASSERT((va >> PAGE_SHIFT) == va_page);
-       KASSERT(0 < dmamap->dm_nsegs);
-
-       gtt_flags |= AGP_I810_GTT_VALID;
        switch (flags) {
        case AGP_USER_MEMORY:
                break;
@@ -168,6 +162,42 @@
                panic("invalid intel gtt flags: %x", flags);
        }
 
+       return gtt_flags;
+}
+
+void
+intel_gtt_insert_page(bus_addr_t addr, unsigned va_page, unsigned flags)
+{
+       struct agp_i810_softc *const isc = agp_i810_sc->as_chipc;
+       off_t va = (off_t)va_page << PAGE_SHIFT;
+       int gtt_flags = intel_gtt_flags(flags);
+       int error;
+
+       error = agp_i810_write_gtt_entry(isc, va, addr, gtt_flags);
+       if (error)
+               device_printf(agp_i810_sc->as_dev,
+                   "write gtt entry"
+                   " %"PRIxMAX" -> %"PRIxMAX" (flags=%x) failed: %d\n",
+                   (uintmax_t)va, (uintmax_t)addr, flags,
+                   error);
+       agp_i810_post_gtt_entry(isc, va);
+       intel_gtt_chipset_flush();
+}
+
+void
+intel_gtt_insert_sg_entries(bus_dmamap_t dmamap, unsigned va_page,
+    unsigned flags)
+{
+       struct agp_i810_softc *const isc = agp_i810_sc->as_chipc;
+       off_t va = (off_t)va_page << PAGE_SHIFT;
+       unsigned seg;
+       int gtt_flags = intel_gtt_flags(flags);
+       int error;
+
+       KASSERT(0 <= va);
+       KASSERT((va >> PAGE_SHIFT) == va_page);
+       KASSERT(0 < dmamap->dm_nsegs);
+
        for (seg = 0; seg < dmamap->dm_nsegs; seg++) {
                const bus_addr_t addr = dmamap->dm_segs[seg].ds_addr;
                bus_size_t len;
@@ -175,14 +205,14 @@
                for (len = dmamap->dm_segs[seg].ds_len;
                     len >= PAGE_SIZE;
                     len -= PAGE_SIZE, va += PAGE_SIZE) {
-                       /* XXX Respect flags.  */
                        error = agp_i810_write_gtt_entry(isc, va, addr,
                            gtt_flags);
                        if (error)
                                device_printf(agp_i810_sc->as_dev,
                                    "write gtt entry"
-                                   " %"PRIxMAX" -> %"PRIxMAX" failed: %d\n",
-                                   (uintmax_t)va, (uintmax_t)(addr | 1),
+                                   " %"PRIxMAX" -> %"PRIxMAX" (flags=%x)"
+                                   " failed: %d\n",
+                                   (uintmax_t)va, (uintmax_t)addr, flags,
                                    error);
                }
                KASSERTMSG(len == 0,
diff -r 56e8cdd91556 -r cb903cb3cbfc sys/external/bsd/drm2/include/drm/intel-gtt.h
--- a/sys/external/bsd/drm2/include/drm/intel-gtt.h     Sun Dec 19 01:35:04 2021 +0000
+++ b/sys/external/bsd/drm2/include/drm/intel-gtt.h     Sun Dec 19 01:35:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel-gtt.h,v 1.7 2018/08/27 16:15:09 riastradh Exp $  */
+/*     $NetBSD: intel-gtt.h,v 1.8 2021/12/19 01:35:10 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,11 +35,12 @@
 #include <sys/types.h>
 #include <sys/bus.h>
 
+#include <linux/ioport.h>
+
 struct pci_dev;
 struct agp_bridge_data;
 
 void   intel_gtt_get(uint64_t * /* GPU VA size in bytes */,
-           size_t * /* graphics stolen memory in bytes */,
            bus_addr_t * /* aperture base */,
            uint64_t * /* aperture size in bytes */);
 int    intel_gmch_probe(struct pci_dev *, struct pci_dev *,
@@ -47,12 +48,14 @@
 void   intel_gmch_remove(void);
 bool   intel_enable_gtt(void);
 void   intel_gtt_chipset_flush(void);
+void   intel_gtt_insert_page(bus_addr_t, unsigned, unsigned);
 void   intel_gtt_insert_sg_entries(bus_dmamap_t, unsigned, unsigned);
 void   intel_gtt_clear_range(unsigned, unsigned);
 
 #define        AGP_USER_MEMORY         1
 #define        AGP_USER_CACHED_MEMORY  2
 
-extern int     intel_iommu_gfx_mapped;
+extern int             intel_iommu_gfx_mapped;
+extern struct resource intel_graphics_stolen_res;
 
 #endif  /* _DRM_INTEL_GTT_H_ */



Home | Main Index | Thread Index | Old Index