Index: mpii.c =================================================================== RCS file: /cvs/src/sys/dev/pci/mpii.c,v retrieving revision 1.105 diff -u -p -r1.105 mpii.c --- mpii.c 14 Sep 2016 01:14:54 -0000 1.105 +++ mpii.c 21 Oct 2016 05:00:51 -0000 @@ -164,6 +164,7 @@ 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; @@ -344,6 +345,8 @@ void mpii_event_done(struct mpii_softc void mpii_event_sas(void *); void mpii_event_raid(struct mpii_softc *, struct mpii_msg_event_reply *); +void mpii_event_discovery(struct mpii_softc *, + struct mpii_msg_event_reply *); void mpii_sas_remove_device(struct mpii_softc *, u_int16_t); @@ -590,6 +593,10 @@ mpii_attach(struct device *parent, struc if (sc->sc_ih == NULL) goto free_devs; + /* force autoconf to wait for the first sas discovery to complete */ + SET(sc->sc_flags, MPII_F_CONFIG_PENDING); + config_pending_incr(); + /* config_found() returns the scsibus attached to us */ sc->sc_scsibus = (struct scsibus_softc *) config_found(&sc->sc_dev, &saa, scsiprint); @@ -1795,6 +1802,19 @@ mpii_event_sas(void *xsc) task_add(systq, &sc->sc_evt_sas_task); enp = (struct mpii_msg_event_reply *)rcb->rcb_reply; + switch (lemtoh16(&enp->event)) { + case MPII_EVENT_SAS_DISCOVERY: + mpii_event_discovery(sc, enp); + goto done; + case MPII_EVENT_SAS_TOPOLOGY_CHANGE_LIST: + /* handle below */ + break; + default: + panic("%s: unexpected event %#x in sas event queue", + DEVNAME(sc), lemtoh16(&enp->event)); + /* NOTREACHED */ + } + tcl = (struct mpii_evt_sas_tcl *)(enp + 1); pe = (struct mpii_evt_phy_entry *)(tcl + 1); @@ -1846,10 +1866,32 @@ mpii_event_sas(void *xsc) } } +done: mpii_event_done(sc, rcb); } void +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); + + printf("%s: %s reason %u\n", DEVNAME(sc), __func__, esd->reason_code); + + 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 (ISSET(sc->sc_flags, MPII_F_CONFIG_PENDING)) { + CLR(sc->sc_flags, MPII_F_CONFIG_PENDING); + config_pending_decr(); + } + } +} + +void mpii_event_process(struct mpii_softc *sc, struct mpii_rcb *rcb) { struct mpii_msg_event_reply *enp; @@ -1863,17 +1905,7 @@ mpii_event_process(struct mpii_softc *sc case MPII_EVENT_EVENT_CHANGE: /* should be properly ignored */ break; - case MPII_EVENT_SAS_DISCOVERY: { - struct mpii_evt_sas_discovery *esd = - (struct mpii_evt_sas_discovery *)(enp + 1); - - if (esd->reason_code == - MPII_EVENT_SAS_DISC_REASON_CODE_COMPLETED && - esd->discovery_status != 0) - printf("%s: sas discovery completed with status %#x\n", - DEVNAME(sc), esd->discovery_status); - } - break; + case MPII_EVENT_SAS_DISCOVERY: case MPII_EVENT_SAS_TOPOLOGY_CHANGE_LIST: mtx_enter(&sc->sc_evt_sas_mtx); SIMPLEQ_INSERT_TAIL(&sc->sc_evt_sas_queue, rcb, rcb_link);