Source-Changes-HG archive

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

[src/trunk]: src/sys Refine previous change to enable PCI window...



details:   https://anonhg.NetBSD.org/src/rev/d1f4a8556003
branches:  trunk
changeset: 319174:d1f4a8556003
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat May 19 17:18:57 2018 +0000

description:
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  |  25 +++++++++++++------------
 sys/dev/pci/pcivar.h   |   4 +++-
 3 files changed, 20 insertions(+), 15 deletions(-)

diffs (119 lines):

diff -r 5558ed621a15 -r d1f4a8556003 sys/arch/x86/x86/efi.c
--- a/sys/arch/x86/x86/efi.c    Sat May 19 16:55:59 2018 +0000
+++ b/sys/arch/x86/x86/efi.c    Sat May 19 17:18:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efi.c,v 1.14 2017/10/22 01:29:26 maya Exp $    */
+/*     $NetBSD: efi.c,v 1.15 2018/05/19 17:18:57 jakllsch Exp $        */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.14 2017/10/22 01:29:26 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.15 2018/05/19 17:18:57 jakllsch 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;
@@ -407,6 +408,7 @@
                return;
        }
        bootmethod_efi = true;
+       pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */
 }
 
 bool
diff -r 5558ed621a15 -r d1f4a8556003 sys/dev/pci/pci_map.c
--- a/sys/dev/pci/pci_map.c     Sat May 19 16:55:59 2018 +0000
+++ b/sys/dev/pci/pci_map.c     Sat May 19 17:18:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_map.c,v 1.34 2018/05/16 19:02:00 jakllsch Exp $    */
+/*     $NetBSD: pci_map.c,v 1.35 2018/05/19 17:18:57 jakllsch 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.34 2018/05/16 19:02:00 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.35 2018/05/19 17:18:57 jakllsch 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)
@@ -293,11 +295,6 @@
        if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) {
                if ((pa->pa_flags & PCI_FLAGS_IO_OKAY) == 0)
                        return 1;
-               s = splhigh();
-               csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
-               csr |= PCI_COMMAND_IO_ENABLE;
-               pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr);
-               splx(s);
                if (pci_io_find(pa->pa_pc, pa->pa_tag, reg, type, &base,
                    &realmaxsize, &flags))
                        return 1;
@@ -305,11 +302,6 @@
        } else {
                if ((pa->pa_flags & PCI_FLAGS_MEM_OKAY) == 0)
                        return 1;
-               s = splhigh();
-               csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
-               csr |= PCI_COMMAND_MEM_ENABLE;
-               pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr);
-               splx(s);
                if (pci_mem_find(pa->pa_pc, pa->pa_tag, reg, type, &base,
                    &realmaxsize, &flags))
                        return 1;
@@ -339,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 5558ed621a15 -r d1f4a8556003 sys/dev/pci/pcivar.h
--- a/sys/dev/pci/pcivar.h      Sat May 19 16:55:59 2018 +0000
+++ b/sys/dev/pci/pcivar.h      Sat May 19 17:18:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcivar.h,v 1.111 2018/04/19 21:50:09 christos Exp $    */
+/*     $NetBSD: pcivar.h,v 1.112 2018/05/19 17:18:57 jakllsch Exp $    */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -258,6 +258,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