Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/pci Pull up following revision(s) (requested by j...



details:   https://anonhg.NetBSD.org/src/rev/000b12a33c08
branches:  netbsd-9
changeset: 936366:000b12a33c08
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jul 26 10:46:14 2020 +0000

description:
Pull up following revision(s) (requested by jdolecek in ticket #1024):

        sys/dev/pci/pci_subr.c: revision 1.224

change pci_conf_print() to allocate memory for the regs dynamically
instead of on-stack

diffstat:

 sys/dev/pci/pci_subr.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (76 lines):

diff -r 7b2cc42a32e7 -r 000b12a33c08 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c    Sun Jul 26 10:44:28 2020 +0000
+++ b/sys/dev/pci/pci_subr.c    Sun Jul 26 10:46:14 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_subr.c,v 1.215.2.3 2020/03/19 19:05:34 martin Exp $        */
+/*     $NetBSD: pci_subr.c,v 1.215.2.4 2020/07/26 10:46:14 martin Exp $        */
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215.2.3 2020/03/19 19:05:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215.2.4 2020/07/26 10:46:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -52,6 +52,11 @@
 #include <sys/systm.h>
 #include <sys/intr.h>
 #include <sys/module.h>
+#include <sys/kmem.h>
+
+#define MALLOC(sz)     kmem_alloc(sz, KM_SLEEP)
+#define FREE(p, sz)    kmem_free(p, sz)
+
 #else
 #include <pci.h>
 #include <stdarg.h>
@@ -59,6 +64,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#define MALLOC(sz)     malloc(sz)
+#define FREE(p, sz)    free(p)
+
 #endif
 
 #include <dev/pci/pcireg.h>
@@ -4811,7 +4820,7 @@
 #endif
     )
 {
-       pcireg_t regs[o2i(PCI_EXTCONF_SIZE)];
+       pcireg_t *regs;
        int off, capoff, endoff, hdrtype;
        const char *type_name;
 #ifdef _KERNEL
@@ -4820,6 +4829,8 @@
        void (*type_printfn)(const pcireg_t *);
 #endif
 
+       regs = MALLOC(PCI_EXTCONF_SIZE);
+
        printf("PCI configuration registers:\n");
 
        for (off = 0; off < PCI_EXTCONF_SIZE; off += 4) {
@@ -4916,7 +4927,7 @@
 
        if (regs[o2i(PCI_EXTCAPLIST_BASE)] == 0xffffffff ||
            regs[o2i(PCI_EXTCAPLIST_BASE)] == 0)
-               return;
+               goto out;
 
        printf("\n");
 #ifdef _KERNEL
@@ -4929,4 +4940,7 @@
        /* Extended Configuration Space, if present */
        printf("  Extended Configuration Space:\n");
        pci_conf_print_regs(regs, PCI_EXTCAPLIST_BASE, PCI_EXTCONF_SIZE);
+
+out:
+       FREE(regs, PCI_EXTCONF_SIZE);
 }



Home | Main Index | Thread Index | Old Index