Source-Changes-HG archive

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

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by jakllsch ...



details:   https://anonhg.NetBSD.org/src/rev/aedc1f29ddd2
branches:  netbsd-8
changeset: 435011:aedc1f29ddd2
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jun 07 15:52:54 2018 +0000

description:
Pull up following revision(s) (requested by jakllsch in ticket #832):

        sys/dev/pci/pcivar.h: revision 1.112
        sys/dev/pci/pci_map.c: revision 1.34,1.35
        sys/arch/x86/x86/efi.c: revision 1.15

Enable the appropriate memory or I/O space decode in the PCI
Command/Status Register upon mapping a BAR.

This should fix PR #53286.  It's also possible there are other similar
PRs that might be fixed by this.
 -
Refine previous change to enable PCI window decoding in Command
Register upon mapping; conditionalize on a global variable, that is set
to true on x86 machines booting under EFI.

For now, initialize the global variable at compile time to false.  This
is intended to limit potential problems for other NetBSD ports, should
this changeset be pulled up to netbsd-8.

Related to PR #53286.

diffstat:

 sys/arch/x86/x86/efi.c |   6 ++++--
 sys/dev/pci/pci_map.c  |  19 +++++++++++++++----
 sys/dev/pci/pcivar.h   |   4 +++-
 3 files changed, 22 insertions(+), 7 deletions(-)

diffs (113 lines):

diff -r c7551b0cd83a -r aedc1f29ddd2 sys/arch/x86/x86/efi.c
--- a/sys/arch/x86/x86/efi.c    Tue Jun 05 08:14:25 2018 +0000
+++ b/sys/arch/x86/x86/efi.c    Thu Jun 07 15:52:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efi.c,v 1.11 2017/03/11 07:21:10 nonaka Exp $  */
+/*     $NetBSD: efi.c,v 1.11.6.1 2018/06/07 15:52:54 martin Exp $      */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.11 2017/03/11 07:21:10 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.11.6.1 2018/06/07 15:52:54 martin Exp $");
 
 #include <sys/kmem.h>
 #include <sys/param.h>
@@ -40,6 +40,7 @@
 #include <x86/efi.h>
 
 #include <dev/mm.h>
+#include <dev/pci/pcivar.h> /* for pci_mapreg_map_enable_decode */
 
 const struct uuid EFI_UUID_ACPI20 = EFI_TABLE_ACPI20;
 const struct uuid EFI_UUID_ACPI10 = EFI_TABLE_ACPI10;
@@ -403,6 +404,7 @@
                efi_relva((vaddr_t) efi_systbl_va);
                return false;
        }
+       pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */
        return true;
 }
 
diff -r c7551b0cd83a -r aedc1f29ddd2 sys/dev/pci/pci_map.c
--- a/sys/dev/pci/pci_map.c     Tue Jun 05 08:14:25 2018 +0000
+++ b/sys/dev/pci/pci_map.c     Thu Jun 07 15:52:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_map.c,v 1.33 2017/03/17 11:21:45 msaitoh Exp $     */
+/*     $NetBSD: pci_map.c,v 1.33.6.1 2018/06/07 15:52:54 martin Exp $  */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.33 2017/03/17 11:21:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.33.6.1 2018/06/07 15:52:54 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,6 +43,8 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 
+bool pci_mapreg_map_enable_decode = false;
+
 static int
 pci_io_find(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t type,
     bus_addr_t *basep, bus_size_t *sizep, int *flagsp)
@@ -287,7 +289,8 @@
        bus_space_handle_t handle;
        bus_addr_t base;
        bus_size_t realmaxsize;
-       int flags;
+       pcireg_t csr;
+       int flags, s;
 
        if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) {
                if ((pa->pa_flags & PCI_FLAGS_IO_OKAY) == 0)
@@ -307,7 +310,6 @@
 
        if (reg == PCI_MAPREG_ROM) {
                pcireg_t        mask;
-               int             s;
                /* we have to enable the ROM address decoder... */
                s = splhigh();
                mask = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
@@ -329,6 +331,15 @@
        if (bus_space_map(tag, base, reqsize, busflags | flags, &handle))
                return 1;
 
+       if (pci_mapreg_map_enable_decode) {
+               s = splhigh();
+               csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+               csr |= (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) ?
+                   PCI_COMMAND_IO_ENABLE : PCI_COMMAND_MEM_ENABLE;
+               pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr);
+               splx(s);
+       }
+
        if (tagp != NULL)
                *tagp = tag;
        if (handlep != NULL)
diff -r c7551b0cd83a -r aedc1f29ddd2 sys/dev/pci/pcivar.h
--- a/sys/dev/pci/pcivar.h      Tue Jun 05 08:14:25 2018 +0000
+++ b/sys/dev/pci/pcivar.h      Thu Jun 07 15:52:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcivar.h,v 1.109 2016/11/25 12:10:59 knakahara Exp $   */
+/*     $NetBSD: pcivar.h,v 1.109.8.1 2018/06/07 15:52:54 martin Exp $  */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -256,6 +256,8 @@
 
 extern struct cfdriver pci_cd;
 
+extern bool pci_mapreg_map_enable_decode;
+
 int pcibusprint(void *, const char *);
 
 /*



Home | Main Index | Thread Index | Old Index