summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-07-07 11:17:37 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-07-07 11:17:37 +0000
commitd347f60944e664e5209e92c4729878d113dc8fbf (patch)
tree266bd094cb3d6fc2a86a5f1bde05ac76fa1e7c06 /sys
parent95fb94471ae8a455e51375b2610e924b66cf67f5 (diff)
tweak config pending handling so it waits for all ports to finish scanning
it waited until any port finished scanning before calling config_pending_decr, but if you have disks on other ports then they may race with the rest of the kernel getting to mountroot. this tweaks the config pending dance so it waits for all ports and avoids the race. i just got lucky on my system where root was on the first port. kettenis has been poking a t4 where the disks are all over the place and he lost the race. tested by and ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/mpii.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c
index 646b09aff7c..7b171ead9e4 100644
--- a/sys/dev/pci/mpii.c
+++ b/sys/dev/pci/mpii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpii.c,v 1.117 2019/06/05 00:36:20 dlg Exp $ */
+/* $OpenBSD: mpii.c,v 1.118 2019/07/07 11:17:36 dlg Exp $ */
/*
* Copyright (c) 2010, 2012 Mike Belopuhov
* Copyright (c) 2009 James Giannoules
@@ -164,9 +164,9 @@ struct mpii_softc {
int sc_flags;
#define MPII_F_RAID (1<<1)
#define MPII_F_SAS3 (1<<2)
-#define MPII_F_CONFIG_PENDING (1<<3)
struct scsibus_softc *sc_scsibus;
+ unsigned int sc_pending;
struct mpii_device **sc_devs;
@@ -601,7 +601,7 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
goto free_devs;
/* force autoconf to wait for the first sas discovery to complete */
- SET(sc->sc_flags, MPII_F_CONFIG_PENDING);
+ sc->sc_pending = 1;
config_pending_incr();
/* config_found() returns the scsibus attached to us */
@@ -1918,16 +1918,19 @@ mpii_event_discovery(struct mpii_softc *sc, struct mpii_msg_event_reply *enp)
struct mpii_evt_sas_discovery *esd =
(struct mpii_evt_sas_discovery *)(enp + 1);
- if (esd->reason_code == MPII_EVENT_SAS_DISC_REASON_CODE_COMPLETED) {
- if (esd->discovery_status != 0) {
- printf("%s: sas discovery completed with status %#x\n",
- DEVNAME(sc), esd->discovery_status);
- }
+ if (sc->sc_pending == 0)
+ return;
- if (ISSET(sc->sc_flags, MPII_F_CONFIG_PENDING)) {
- CLR(sc->sc_flags, MPII_F_CONFIG_PENDING);
+ switch (esd->reason_code) {
+ case MPII_EVENT_SAS_DISC_REASON_CODE_STARTED:
+ ++sc->sc_pending;
+ break;
+ case MPII_EVENT_SAS_DISC_REASON_CODE_COMPLETED:
+ if (--sc->sc_pending == 1) {
+ sc->sc_pending = 0;
config_pending_decr();
}
+ break;
}
}