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/i915drm Have i915_vma_pin_iomap map us...



details:   https://anonhg.NetBSD.org/src/rev/75fe5fbea243
branches:  trunk
changeset: 1028669:75fe5fbea243
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:38:46 2021 +0000

description:
Have i915_vma_pin_iomap map us the framebuffer

Rather than passing bus space arguments around. Also fixes build.


Author: Maya Rashish <maya%NetBSD.org@localhost>
Committer: Taylor R Campbell <riastradh%NetBSD.org@localhost>

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c |  33 ++++++++++----
 sys/external/bsd/drm2/i915drm/intelfb.c                   |  28 +-----------
 sys/external/bsd/drm2/i915drm/intelfb.h                   |   7 +--
 3 files changed, 29 insertions(+), 39 deletions(-)

diffs (182 lines):

diff -r 4340d9e0ad8e -r 75fe5fbea243 sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c
--- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c Sun Dec 19 11:38:37 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_fbdev.c Sun Dec 19 11:38:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intel_fbdev.c,v 1.3 2021/12/19 10:46:43 riastradh Exp $        */
+/*     $NetBSD: intel_fbdev.c,v 1.4 2021/12/19 11:38:46 riastradh Exp $        */
 
 /*
  * Copyright © 2007 David Airlie
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.3 2021/12/19 10:46:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intel_fbdev.c,v 1.4 2021/12/19 11:38:46 riastradh Exp $");
 
 #include <linux/async.h>
 #include <linux/console.h>
@@ -172,6 +172,10 @@
        return 0;
 }
 
+#ifdef __NetBSD__
+#  define      __iomem         __i915_vma_iomem
+#endif
+
 static int intelfb_create(struct drm_fb_helper *helper,
                          struct drm_fb_helper_surface_size *sizes)
 {
@@ -238,14 +242,23 @@
        static const struct intelfb_attach_args zero_ifa;
        struct intelfb_attach_args ifa = zero_ifa;
 
+       __USE(ggtt);
+       __USE(pdev);
+
+       vaddr = i915_vma_pin_iomap(vma);
+       if (IS_ERR(vaddr)) {
+               DRM_ERROR("Failed to remap framebuffer into virtual memory\n");
+               ret = PTR_ERR(vaddr);
+               goto out_unpin;
+       }
+
+        if (vma->obj->stolen && !prealloc)
+               memset_io(vaddr, 0, vma->node.size);
+
        ifa.ifa_drm_dev = dev;
        ifa.ifa_fb_helper = helper;
        ifa.ifa_fb_sizes = *sizes;
-       ifa.ifa_fb_bst = dev->pdev->pd_pa.pa_memt;
-       ifa.ifa_fb_addr = (dev_priv->gtt.mappable_base +
-           i915_gem_obj_ggtt_offset(obj));
-       ifa.ifa_fb_size = size;
-       ifa.ifa_fb_zero = (ifbdev->fb->obj->stolen && !prealloc);
+       ifa.ifa_fb_vaddr = vaddr;
 
        /*
         * XXX Should do this asynchronously, since we hold
@@ -258,8 +271,7 @@
                ret = -ENXIO;
                goto out_unpin;
        }
-       fb = &ifbdev->fb->base;
-       ifbdev->helper.fb = fb;
+       ifbdev->helper.fb = &ifbdev->fb->base;
     }
 #else
        info = drm_fb_helper_alloc_fbi(helper);
@@ -321,6 +333,9 @@
        intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
        return ret;
 }
+#ifdef __NetBSD__
+#  undef       __iomem
+#endif
 
 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
        .fb_probe = intelfb_create,
diff -r 4340d9e0ad8e -r 75fe5fbea243 sys/external/bsd/drm2/i915drm/intelfb.c
--- a/sys/external/bsd/drm2/i915drm/intelfb.c   Sun Dec 19 11:38:37 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/intelfb.c   Sun Dec 19 11:38:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intelfb.c,v 1.20 2021/12/19 11:02:12 riastradh Exp $   */
+/*     $NetBSD: intelfb.c,v 1.21 2021/12/19 11:38:46 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.20 2021/12/19 11:02:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.21 2021/12/19 11:38:46 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/bus.h>
@@ -60,7 +60,6 @@
        struct intelfb_attach_args      sc_ifa;
        bus_space_handle_t              sc_fb_bsh;
        struct i915drmkms_task          sc_attach_task;
-       bool                            sc_mapped:1;
        bool                            sc_scheduled:1;
        bool                            sc_attached:1;
 };
@@ -92,25 +91,12 @@
 
        sc->sc_dev = self;
        sc->sc_ifa = *ifa;
-       sc->sc_mapped = false;
        sc->sc_scheduled = false;
        sc->sc_attached = false;
 
        aprint_naive("\n");
        aprint_normal("\n");
 
-       /* XXX Defer this too?  */
-       error = bus_space_map(ifa->ifa_fb_bst, ifa->ifa_fb_addr,
-           ifa->ifa_fb_size,
-           BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE,
-           &sc->sc_fb_bsh);
-       if (error) {
-               aprint_error_dev(self, "unable to map framebuffer: %d\n",
-                   error);
-               goto fail0;
-       }
-       sc->sc_mapped = true;
-
        i915drmkms_task_init(&sc->sc_attach_task, &intelfb_attach_task);
        error = i915drmkms_task_schedule(parent, &sc->sc_attach_task);
        if (error) {
@@ -124,8 +110,6 @@
        /* Success!  */
        return;
 
-fail1: bus_space_unmap(ifa->ifa_fb_bst, sc->sc_fb_bsh, ifa->ifa_fb_size);
-       sc->sc_mapped = false;
 fail0: return;
 }
 
@@ -150,12 +134,6 @@
                sc->sc_attached = false;
        }
 
-       if (sc->sc_mapped) {
-               bus_space_unmap(sc->sc_ifa.ifa_fb_bst, sc->sc_fb_bsh,
-                   sc->sc_ifa.ifa_fb_size);
-               sc->sc_mapped = false;
-       }
-
        return 0;
 }
 
@@ -169,7 +147,7 @@
                .da_dev = sc->sc_dev,
                .da_fb_helper = ifa->ifa_fb_helper,
                .da_fb_sizes = &ifa->ifa_fb_sizes,
-               .da_fb_vaddr = bus_space_vaddr(ifa->ifa_fb_bst, sc->sc_fb_bsh),
+               .da_fb_vaddr = ifa->ifa_fb_vaddr,
                .da_fb_linebytes = ifa->ifa_fb_helper->fb->pitches[0],
                .da_params = &intelfb_drmfb_params,
        };
diff -r 4340d9e0ad8e -r 75fe5fbea243 sys/external/bsd/drm2/i915drm/intelfb.h
--- a/sys/external/bsd/drm2/i915drm/intelfb.h   Sun Dec 19 11:38:37 2021 +0000
+++ b/sys/external/bsd/drm2/i915drm/intelfb.h   Sun Dec 19 11:38:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intelfb.h,v 1.2 2021/12/19 10:32:59 riastradh Exp $    */
+/*     $NetBSD: intelfb.h,v 1.3 2021/12/19 11:38:46 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,10 +42,7 @@
        struct drm_device                       *ifa_drm_dev;
        struct drm_fb_helper                    *ifa_fb_helper;
        struct drm_fb_helper_surface_size       ifa_fb_sizes;
-       bus_space_tag_t                         ifa_fb_bst;
-       bus_addr_t                              ifa_fb_addr;
-       bus_size_t                              ifa_fb_size;
-       bool                                    ifa_fb_zero;
+       void*                                   ifa_fb_vaddr;
 };
 
 #endif /* _I915DRM_INTELFB_H_ */



Home | Main Index | Thread Index | Old Index