Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/cortex Do not store a pointer to the passed in ...



details:   https://anonhg.NetBSD.org/src/rev/4b2fdddcf256
branches:  trunk
changeset: 971880:4b2fdddcf256
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu May 07 16:20:40 2020 +0000

description:
Do not store a pointer to the passed in struct pci_attach_args

diffstat:

 sys/arch/arm/cortex/gic_v2m.c |  18 ++++++++++++++----
 sys/arch/arm/cortex/gic_v2m.h |   4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diffs (72 lines):

diff -r 5125e79ede56 -r 4b2fdddcf256 sys/arch/arm/cortex/gic_v2m.c
--- a/sys/arch/arm/cortex/gic_v2m.c     Thu May 07 15:44:35 2020 +0000
+++ b/sys/arch/arm/cortex/gic_v2m.c     Thu May 07 16:20:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.c,v 1.8 2019/12/02 03:06:51 msaitoh Exp $ */
+/* $NetBSD: gic_v2m.c,v 1.9 2020/05/07 16:20:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.8 2019/12/02 03:06:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.9 2020/05/07 16:20:40 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -66,6 +66,7 @@
 gic_v2m_msi_alloc_spi(struct gic_v2m_frame *frame, int count,
     const struct pci_attach_args *pa)
 {
+       struct pci_attach_args *new_pa;
        int spi, n;
 
        for (spi = frame->frame_base;
@@ -75,8 +76,11 @@
                                if (frame->frame_pa[spi + n] != NULL)
                                        goto next_spi;
 
-                       for (n = 0; n < count; n++)
-                               frame->frame_pa[spi + n] = pa;
+                       for (n = 0; n < count; n++) {
+                               new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
+                               memcpy(new_pa, pa, sizeof(*new_pa));
+                               frame->frame_pa[spi + n] = new_pa;
+                       }
 
                        return spi;
                }
@@ -90,7 +94,13 @@
 static void
 gic_v2m_msi_free_spi(struct gic_v2m_frame *frame, int spi)
 {
+       struct pci_attach_args *pa;
+
+       pa = frame->frame_pa[spi];
        frame->frame_pa[spi] = NULL;
+
+       if (pa != NULL)
+               kmem_free(pa, sizeof(*pa));
 }
 
 static int
diff -r 5125e79ede56 -r 4b2fdddcf256 sys/arch/arm/cortex/gic_v2m.h
--- a/sys/arch/arm/cortex/gic_v2m.h     Thu May 07 15:44:35 2020 +0000
+++ b/sys/arch/arm/cortex/gic_v2m.h     Thu May 07 16:20:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.h,v 1.2 2019/10/14 11:00:13 jmcneill Exp $ */
+/* $NetBSD: gic_v2m.h,v 1.3 2020/05/07 16:20:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
        uint32_t                frame_flags;
 #define        GIC_V2M_FLAG_GRAVITON           0x01    /* Amazon Graviton quirk */
 
-       const struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
+       struct pci_attach_args *frame_pa[GICC_IAR_IRQ];
 
        struct arm_pci_msi      frame_msi;
 };



Home | Main Index | Thread Index | Old Index