Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/arm/sunxi Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/8a723b967309
branches:  netbsd-9
changeset: 461408:8a723b967309
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Nov 25 16:20:41 2019 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #472):

        sys/arch/arm/sunxi/sunxi_drm.c: revision 1.9

Reclaim bootloader FB memory for CMA pool.

diffstat:

 sys/arch/arm/sunxi/sunxi_drm.c |  56 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 48 insertions(+), 8 deletions(-)

diffs (93 lines):

diff -r c0e57bcd9009 -r 8a723b967309 sys/arch/arm/sunxi/sunxi_drm.c
--- a/sys/arch/arm/sunxi/sunxi_drm.c    Mon Nov 25 16:18:40 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_drm.c    Mon Nov 25 16:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_drm.c,v 1.7.6.1 2019/11/06 09:48:31 martin Exp $ */
+/* $NetBSD: sunxi_drm.c,v 1.7.6.2 2019/11/25 16:20:41 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.7.6.1 2019/11/06 09:48:31 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_drm.c,v 1.7.6.2 2019/11/25 16:20:41 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -296,6 +296,27 @@
 };
 
 static int
+sunxi_drm_simplefb_lookup(bus_addr_t *paddr, bus_size_t *psize)
+{
+       static const char * compat[] = { "simple-framebuffer", NULL };
+       int chosen, child;
+
+       chosen = OF_finddevice("/chosen");
+       if (chosen == -1)
+               return ENOENT;
+
+       for (child = OF_child(chosen); child; child = OF_peer(child)) {
+               if (!fdtbus_status_okay(child))
+                       continue;
+               if (!of_match_compatible(child, compat))
+                       continue;
+               return fdtbus_get_reg(child, 0, paddr, psize);
+       }
+
+       return ENOENT;
+}
+
+static int
 sunxi_drm_fb_probe(struct drm_fb_helper *helper, struct drm_fb_helper_surface_size *sizes)
 {
        struct sunxi_drm_softc * const sc = sunxi_drm_private(helper->dev);
@@ -303,6 +324,8 @@
        struct sunxi_drm_framebuffer *sfb = to_sunxi_drm_framebuffer(helper->fb);
        struct drm_framebuffer *fb = helper->fb;
        struct sunxi_drmfb_attach_args sfa;
+       bus_addr_t sfb_addr;
+       bus_size_t sfb_size;
        size_t cma_size;
        int error;
 
@@ -312,14 +335,31 @@
 
        const size_t size = roundup(height * pitch, PAGE_SIZE);
 
-       /* Reserve enough memory for the FB console plus a 4K plane, rounded to 1MB */
-       cma_size = size;
-       cma_size += (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4);
+       if (sunxi_drm_simplefb_lookup(&sfb_addr, &sfb_size) != 0)
+               sfb_size = 0;
+
+       /* Reserve enough memory for a 4K plane, rounded to 1MB */
+       cma_size = (SUNXI_DRM_MAX_WIDTH * SUNXI_DRM_MAX_HEIGHT * 4);
+       if (sfb_size == 0) {
+               /* Add memory for FB console if we cannot reclaim bootloader memory */
+               cma_size += size;
+       }
        cma_size = roundup(cma_size, 1024 * 1024);
        sc->sc_ddev->cma_pool = sunxi_drm_alloc_cma_pool(sc->sc_ddev, cma_size);
-       if (sc->sc_ddev->cma_pool != NULL)
-               aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA\n",
-                   (u_int)(cma_size / (1024 * 1024)));
+       if (sc->sc_ddev->cma_pool != NULL) {
+               if (sfb_size != 0) {
+                       error = vmem_add(sc->sc_ddev->cma_pool, sfb_addr,
+                           sfb_size, VM_SLEEP);
+                       if (error != 0)
+                               sfb_size = 0;
+               }
+               aprint_normal_dev(sc->sc_dev, "reserved %u MB DRAM for CMA",
+                   (u_int)((cma_size + sfb_size) / (1024 * 1024)));
+               if (sfb_size != 0)
+                       aprint_normal(" (%u MB reclaimed from bootloader)",
+                           (u_int)(sfb_size / (1024 * 1024)));
+               aprint_normal("\n");
+       }
 
        sfb->obj = drm_gem_cma_create(ddev, size);
        if (sfb->obj == NULL) {



Home | Main Index | Thread Index | Old Index