Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/pci Pull up following revision(s) (requested by m...
details: https://anonhg.NetBSD.org/src/rev/1a16230f7139
branches: netbsd-8
changeset: 852233:1a16230f7139
user: martin <martin%NetBSD.org@localhost>
date: Sun Jan 27 18:35:19 2019 +0000
description:
Pull up following revision(s) (requested by msaitoh in ticket #1172):
sys/dev/pci/nvme_pci.c: revision 1.26
sys/dev/pci/xhci_pci.c: revision 1.21
sys/dev/pci/ixgbe/ixv.c: revision 1.108
sys/dev/pci/ixgbe/ixgbe.c: revision 1.171
sys/dev/pci/if_fxp_pci.c: revision 1.84
sys/dev/pci/if_fxp_pci.c: revision 1.85
sys/dev/pci/xhci_pci.c: revision 1.16
remove #ifdef DEBUG printf, it seems to have outlived it's usefulness
-
KNF. No functional change.
-
Nowadays some UEFI BIOSes don't enable some PCI devices' address decoding.
To resolve this problem, pci_map.c rev. 1.34-1.36 changed the
pci_mapreg_(sub)map()'s to set the decode bit if it's not set. It's good for
almost all drivers, but some other drivers don't use pci_mapreg_map().
In drivers which don't use pci_mapreg_map(), some of them explicitly enable
decoding but others don't. Add code to enable decoding to them.
See also the following discussion:
http://mail-index.netbsd.org/tech-kern/2017/03/22/msg021678.html
diffstat:
sys/dev/pci/if_fxp_pci.c | 32 ++++++++++++++++++++------------
sys/dev/pci/ixgbe/ixgbe.c | 13 +++++++++++--
sys/dev/pci/ixgbe/ixv.c | 13 +++++++++++--
sys/dev/pci/nvme_pci.c | 22 ++++++++++++++--------
sys/dev/pci/xhci_pci.c | 20 +++++++++++---------
5 files changed, 67 insertions(+), 33 deletions(-)
diffs (258 lines):
diff -r 6708923128a3 -r 1a16230f7139 sys/dev/pci/if_fxp_pci.c
--- a/sys/dev/pci/if_fxp_pci.c Sun Jan 27 18:25:52 2019 +0000
+++ b/sys/dev/pci/if_fxp_pci.c Sun Jan 27 18:35:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_fxp_pci.c,v 1.82 2015/04/13 16:33:25 riastradh Exp $ */
+/* $NetBSD: if_fxp_pci.c,v 1.82.10.1 2019/01/27 18:35:19 martin Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.82 2015/04/13 16:33:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.82.10.1 2019/01/27 18:35:19 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -190,13 +190,13 @@
const struct fxp_pci_product *fpp;
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
- return (NULL);
+ return NULL;
for (fpp = fxp_pci_products; fpp->fpp_name != NULL; fpp++)
if (PCI_PRODUCT(pa->pa_id) == fpp->fpp_prodid)
- return (fpp);
+ return fpp;
- return (NULL);
+ return NULL;
}
static int
@@ -205,9 +205,9 @@
struct pci_attach_args *pa = aux;
if (fxp_pci_lookup(pa) != NULL)
- return (1);
+ return 1;
- return (0);
+ return 0;
}
/*
@@ -245,8 +245,7 @@
reg = pci_conf_read(psc->psc_pc, psc->psc_tag, PCI_COMMAND_STATUS_REG);
#endif
- pci_conf_write(psc->psc_pc, psc->psc_tag,
- PCI_COMMAND_STATUS_REG,
+ pci_conf_write(psc->psc_pc, psc->psc_tag, PCI_COMMAND_STATUS_REG,
(reg & 0xffff0000) |
(psc->psc_regs[PCI_COMMAND_STATUS_REG>>2] & 0xffff));
pci_conf_write(psc->psc_pc, psc->psc_tag, PCI_BHLC_REG,
@@ -303,6 +302,7 @@
bus_space_handle_t ioh, memh;
int ioh_valid, memh_valid;
bus_addr_t addr;
+ pcireg_t csr;
int flags;
int error;
char intrbuf[PCI_INTRSTR_LEN];
@@ -312,8 +312,7 @@
/*
* Map control/status registers.
*/
- ioh_valid = (pci_mapreg_map(pa, FXP_PCI_IOBA,
- PCI_MAPREG_TYPE_IO, 0,
+ ioh_valid = (pci_mapreg_map(pa, FXP_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0,
&iot, &ioh, NULL, NULL) == 0);
/*
@@ -352,6 +351,15 @@
if (memh_valid) {
sc->sc_st = memt;
sc->sc_sh = memh;
+ /*
+ * Enable address decoding for memory range in case BIOS or
+ * UEFI didn't set it.
+ */
+ 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);
} else if (ioh_valid) {
sc->sc_st = iot;
sc->sc_sh = ioh;
@@ -541,5 +549,5 @@
/* Now restore the configuration registers. */
fxp_pci_confreg_restore(psc);
- return (0);
+ return 0;
}
diff -r 6708923128a3 -r 1a16230f7139 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Sun Jan 27 18:25:52 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Sun Jan 27 18:35:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.25 2018/11/08 12:04:48 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.26 2019/01/27 18:35:19 martin Exp $ */
/******************************************************************************
@@ -3344,7 +3344,7 @@
ixgbe_allocate_pci_resources(struct adapter *adapter,
const struct pci_attach_args *pa)
{
- pcireg_t memtype;
+ pcireg_t memtype, csr;
device_t dev = adapter->dev;
bus_addr_t addr;
int flags;
@@ -3369,6 +3369,15 @@
aprint_error_dev(dev, "unable to map BAR0\n");
return ENXIO;
}
+ /*
+ * Enable address decoding for memory range in case BIOS or
+ * UEFI don't set it.
+ */
+ 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);
break;
default:
aprint_error_dev(dev, "unexpected type on BAR0\n");
diff -r 6708923128a3 -r 1a16230f7139 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c Sun Jan 27 18:25:52 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c Sun Jan 27 18:35:19 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.56.2.18 2018/11/08 12:04:48 martin Exp $*/
+/*$NetBSD: ixv.c,v 1.56.2.19 2019/01/27 18:35:19 martin Exp $*/
/******************************************************************************
@@ -1403,7 +1403,7 @@
ixv_allocate_pci_resources(struct adapter *adapter,
const struct pci_attach_args *pa)
{
- pcireg_t memtype;
+ pcireg_t memtype, csr;
device_t dev = adapter->dev;
bus_addr_t addr;
int flags;
@@ -1428,6 +1428,15 @@
aprint_error_dev(dev, "unable to map BAR0\n");
return ENXIO;
}
+ /*
+ * Enable address decoding for memory range in case it's not
+ * set.
+ */
+ 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);
break;
default:
aprint_error_dev(dev, "unexpected type on BAR0\n");
diff -r 6708923128a3 -r 1a16230f7139 sys/dev/pci/nvme_pci.c
--- a/sys/dev/pci/nvme_pci.c Sun Jan 27 18:25:52 2019 +0000
+++ b/sys/dev/pci/nvme_pci.c Sun Jan 27 18:35:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme_pci.c,v 1.19.2.1 2018/04/19 15:37:56 martin Exp $ */
+/* $NetBSD: nvme_pci.c,v 1.19.2.2 2019/01/27 18:35:19 martin Exp $ */
/* $OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
/*
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.19.2.1 2018/04/19 15:37:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.19.2.2 2019/01/27 18:35:19 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -160,18 +160,24 @@
pci_aprint_devinfo(pa, NULL);
- reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
- if ((reg & PCI_COMMAND_MASTER_ENABLE) == 0) {
- reg |= PCI_COMMAND_MASTER_ENABLE;
- pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg);
- }
-
/* Map registers */
memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, NVME_PCI_BAR);
if (PCI_MAPREG_TYPE(memtype) != PCI_MAPREG_TYPE_MEM) {
aprint_error_dev(self, "invalid type (type=0x%x)\n", memtype);
return;
}
+ reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+ if (((reg & PCI_COMMAND_MASTER_ENABLE) == 0) ||
+ ((reg & PCI_COMMAND_MEM_ENABLE) == 0)) {
+ /*
+ * Enable address decoding for memory range in case BIOS or
+ * UEFI didn't set it.
+ */
+ reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
+ pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+ reg);
+ }
+
sc->sc_iot = pa->pa_memt;
error = pci_mapreg_info(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START,
memtype, &memaddr, &sc->sc_ios, &flags);
diff -r 6708923128a3 -r 1a16230f7139 sys/dev/pci/xhci_pci.c
--- a/sys/dev/pci/xhci_pci.c Sun Jan 27 18:25:52 2019 +0000
+++ b/sys/dev/pci/xhci_pci.c Sun Jan 27 18:35:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci_pci.c,v 1.8.6.1 2018/09/27 14:52:27 martin Exp $ */
+/* $NetBSD: xhci_pci.c,v 1.8.6.2 2019/01/27 18:35:19 martin Exp $ */
/* OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.8.6.1 2018/09/27 14:52:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.8.6.2 2019/01/27 18:35:19 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -132,15 +132,17 @@
/* Check for quirks */
sc->sc_quirks = 0;
- /* check if memory space access is enabled */
csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
-#ifdef DEBUG
- printf("%s: csr: %08x\n", __func__, csr);
-#endif
if ((csr & PCI_COMMAND_MEM_ENABLE) == 0) {
- sc->sc_ios = 0;
- aprint_error_dev(self, "memory access is disabled\n");
- return;
+ /*
+ * Enable address decoding for memory range in case BIOS or
+ * UEFI didn't set it.
+ */
+ 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);
}
/* map MMIO registers */
Home |
Main Index |
Thread Index |
Old Index