Index: mpii.c =================================================================== RCS file: /cvs/src/sys/dev/pci/mpii.c,v retrieving revision 1.117 diff -u -p -r1.117 mpii.c --- mpii.c 5 Jun 2019 00:36:20 -0000 1.117 +++ mpii.c 6 Jul 2019 11:05:05 -0000 @@ -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, struc 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,24 @@ mpii_event_discovery(struct mpii_softc * 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); - } + printf("%s: %s flags 0x%02x, reason_code 0x%02x, port 0x%02x, " + "status 0x%08x\n", DEVNAME(sc), __func__, + esd->flags, esd->reason_code, esd->physical_port, + lemtoh32(&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; } } @@ -1939,6 +1947,8 @@ mpii_event_process(struct mpii_softc *sc enp = (struct mpii_msg_event_reply *)rcb->rcb_reply; DNPRINTF(MPII_D_EVT, "%s: mpii_event_process: %#x\n", DEVNAME(sc), + lemtoh16(&enp->event)); + printf("%s: %s 0x%04x\n", DEVNAME(sc), __func__, lemtoh16(&enp->event)); switch (lemtoh16(&enp->event)) {