summaryrefslogtreecommitdiff
path: root/sys/arch/alpha
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-10-20 12:05:02 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-10-20 12:05:02 +0000
commitf7cece8c3c829c8d01d483478df29e61c89a40ee (patch)
tree63a403e352d3cd17756902b305ae55283b9af496 /sys/arch/alpha
parentee8235f25846d438f8b8b94aa475f8def113ced1 (diff)
Make sure the logic deciding whether to use BWX operations in cia(4)
operation uses the CPU capabilities, rather than a not-yet-initialized variable which will eventually be set to the CPU capabilities. from miod@
Diffstat (limited to 'sys/arch/alpha')
-rw-r--r--sys/arch/alpha/pci/cia.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/sys/arch/alpha/pci/cia.c b/sys/arch/alpha/pci/cia.c
index d3fc3c43d93..d1b172cad65 100644
--- a/sys/arch/alpha/pci/cia.c
+++ b/sys/arch/alpha/pci/cia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cia.c,v 1.25 2009/03/30 21:43:13 kettenis Exp $ */
+/* $OpenBSD: cia.c,v 1.26 2017/10/20 12:05:01 mpi Exp $ */
/* $NetBSD: cia.c,v 1.56 2000/06/29 08:58:45 mrg Exp $ */
/*-
@@ -194,39 +194,48 @@ cia_init(ccp, mallocsafe)
else
ccp->cc_cnfg = 0;
- /*
- * Use BWX iff:
- *
- * - It hasn't been disabled by the user,
- * - it's enabled in CNFG,
- * - we're implementation version ev5,
- * - BWX is enabled in the CPU's capabilities mask (yes,
- * the bit is really cleared if the capability exists...)
- */
- if ((pci_use_bwx || bus_use_bwx) &&
- (ccp->cc_cnfg & CNFG_BWEN) != 0 &&
- (cpu_amask & ALPHA_AMASK_BWX) != 0) {
- u_int32_t ctrl;
-
- if (pci_use_bwx)
- ccp->cc_flags |= CCF_PCI_USE_BWX;
- if (bus_use_bwx)
- ccp->cc_flags |= CCF_BUS_USE_BWX;
+ if (!ccp->cc_initted) {
+ /*
+ * cpu_amask is not initialized if we are invoked during
+ * console initialization.
+ */
+ u_long amask = 0;
+ if (alpha_implver() >= ALPHA_IMPLVER_EV5)
+ amask =
+ (~alpha_amask(ALPHA_AMASK_ALL)) & ALPHA_AMASK_ALL;
/*
- * For whatever reason, the firmware seems to enable PCI
- * loopback mode if it also enables BWX. Make sure it's
- * enabled if we have an old, buggy firmware rev.
+ * Use BWX iff:
+ *
+ * - It hasn't been disabled by the user,
+ * - it's enabled in CNFG,
+ * - we're implementation version ev5,
+ * - BWX is enabled in the CPU's capabilities mask (yes,
+ * the bit is really cleared if the capability exists...)
*/
- alpha_mb();
- ctrl = REGVAL(CIA_CSR_CTRL);
- if ((ctrl & CTRL_PCI_LOOP_EN) == 0) {
- REGVAL(CIA_CSR_CTRL) = ctrl | CTRL_PCI_LOOP_EN;
+ if ((pci_use_bwx || bus_use_bwx) &&
+ (ccp->cc_cnfg & CNFG_BWEN) != 0 &&
+ (amask & ALPHA_AMASK_BWX) != 0) {
+ u_int32_t ctrl;
+
+ if (pci_use_bwx)
+ ccp->cc_flags |= CCF_PCI_USE_BWX;
+ if (bus_use_bwx)
+ ccp->cc_flags |= CCF_BUS_USE_BWX;
+
+ /*
+ * For whatever reason, the firmware seems to enable PCI
+ * loopback mode if it also enables BWX. Make sure it's
+ * enabled if we have an old, buggy firmware rev.
+ */
alpha_mb();
+ ctrl = REGVAL(CIA_CSR_CTRL);
+ if ((ctrl & CTRL_PCI_LOOP_EN) == 0) {
+ REGVAL(CIA_CSR_CTRL) = ctrl | CTRL_PCI_LOOP_EN;
+ alpha_mb();
+ }
}
- }
- if (!ccp->cc_initted) {
/* don't do these twice since they set up extents */
if (ccp->cc_flags & CCF_BUS_USE_BWX) {
cia_bwx_bus_io_init(&ccp->cc_iot, ccp);