Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/broadcom Avoid large stack usage with kmem_allo...



details:   https://anonhg.NetBSD.org/src/rev/0a22ae010066
branches:  trunk
changeset: 1011323:0a22ae010066
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Jun 26 08:42:01 2020 +0000

description:
Avoid large stack usage with kmem_alloc - we're in device_register so
there is no problem doing this.

diffstat:

 sys/arch/arm/broadcom/bcm283x_platform.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 752e819b6702 -r 0a22ae010066 sys/arch/arm/broadcom/bcm283x_platform.c
--- a/sys/arch/arm/broadcom/bcm283x_platform.c  Fri Jun 26 07:50:11 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm283x_platform.c  Fri Jun 26 08:42:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm283x_platform.c,v 1.38 2020/06/21 07:17:25 skrll Exp $      */
+/*     $NetBSD: bcm283x_platform.c,v 1.39 2020/06/26 08:42:01 skrll Exp $      */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.38 2020/06/21 07:17:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.39 2020/06/26 08:42:01 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_bcm283x.h"
@@ -53,6 +53,7 @@
 #include <sys/bus.h>
 #include <sys/cpu.h>
 #include <sys/device.h>
+#include <sys/kmem.h>
 #include <sys/termios.h>
 
 #include <net/if_ether.h>
@@ -881,11 +882,12 @@
        return true;
 }
 
+#define RPI_EDIDSIZE 1024
+
 static bool
 rpi_fb_get_edid_mode(uint32_t *pwidth, uint32_t *pheight)
 {
        struct edid_info ei;
-       uint8_t edid_data[1024];
        uint32_t res;
        int error;
 
@@ -901,7 +903,9 @@
            vb_edid.vbt_edid.status != 0)
                return false;
 
-       memset(edid_data, 0, sizeof(edid_data));
+       uint8_t *edid_data = kmem_alloc(RPI_EDIDSIZE, KM_SLEEP);
+
+       memset(edid_data, 0, RPI_EDIDSIZE);
        memcpy(edid_data, vb_edid.vbt_edid.data,
            sizeof(vb_edid.vbt_edid.data));
        edid_parse(edid_data, &ei);
@@ -914,6 +918,8 @@
                *pheight = ei.edid_preferred_mode->vdisplay;
        }
 
+       kmem_free(edid_data, RPI_EDIDSIZE);
+
        return true;
 }
 



Home | Main Index | Thread Index | Old Index