Module Name: src Committed By: martin Date: Thu Jun 7 15:52:54 UTC 2018
Modified Files: src/sys/arch/x86/x86 [netbsd-8]: efi.c src/sys/dev/pci [netbsd-8]: pci_map.c pcivar.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.11.6.1 src/sys/arch/x86/x86/efi.c cvs rdiff -u -r1.33 -r1.33.6.1 src/sys/dev/pci/pci_map.c cvs rdiff -u -r1.109 -r1.109.8.1 src/sys/dev/pci/pcivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/efi.c diff -u src/sys/arch/x86/x86/efi.c:1.11 src/sys/arch/x86/x86/efi.c:1.11.6.1 --- src/sys/arch/x86/x86/efi.c:1.11 Sat Mar 11 07:21:10 2017 +++ src/sys/arch/x86/x86/efi.c Thu Jun 7 15:52:54 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.11 #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_probe(void) efi_relva((vaddr_t) efi_systbl_va); return false; } + pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */ return true; } Index: src/sys/dev/pci/pci_map.c diff -u src/sys/dev/pci/pci_map.c:1.33 src/sys/dev/pci/pci_map.c:1.33.6.1 --- src/sys/dev/pci/pci_map.c:1.33 Fri Mar 17 11:21:45 2017 +++ src/sys/dev/pci/pci_map.c Thu Jun 7 15:52:54 2018 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: pci_map.c,v #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 @@ pci_mapreg_submap(const struct pci_attac 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 @@ pci_mapreg_submap(const struct pci_attac 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 @@ pci_mapreg_submap(const struct pci_attac 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) Index: src/sys/dev/pci/pcivar.h diff -u src/sys/dev/pci/pcivar.h:1.109 src/sys/dev/pci/pcivar.h:1.109.8.1 --- src/sys/dev/pci/pcivar.h:1.109 Fri Nov 25 12:10:59 2016 +++ src/sys/dev/pci/pcivar.h Thu Jun 7 15:52:54 2018 @@ -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 @@ struct pci_softc { extern struct cfdriver pci_cd; +extern bool pci_mapreg_map_enable_decode; + int pcibusprint(void *, const char *); /*