From: mikeb Date: Thu, 15 Jun 2017 15:01:28 +0000 (+0000) Subject: Correct the number of targets vs number of LUNs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d917c19627c965bbea0a240c6caea8cc92a62df5;p=openbsd Correct the number of targets vs number of LUNs jsg@ has found out that the number of targets wasn't correct and it turns out that the device supports up to 2 targets and 1 or 64 LUNs depending on whether it's taking over an IDE device or is a virtual SCSI. While here make sure the command response is copied back only for synchronous commands that are issued during initialization phase. --- diff --git a/sys/dev/pv/hvs.c b/sys/dev/pv/hvs.c index 1ce93732677..0fe13372a50 100644 --- a/sys/dev/pv/hvs.c +++ b/sys/dev/pv/hvs.c @@ -169,7 +169,6 @@ struct hvs_cmd_xio { uint32_t cmd_qsortkey; } __packed; -#define HVS_INIT_TID 0x1984 #define HVS_CMD_SIZE 64 union hvs_cmd { @@ -246,7 +245,7 @@ void hvs_scsi_probe(void *arg); void hvs_scsi_done(struct scsi_xfer *, int); int hvs_connect(struct hvs_softc *); -void hvs_empty_done(struct hvs_ccb *); +void hvs_cmd_done(struct hvs_ccb *); int hvs_alloc_ccbs(struct hvs_softc *); void hvs_free_ccbs(struct hvs_softc *); @@ -316,8 +315,9 @@ hvs_attach(struct device *parent, struct device *self, void *aux) sc->sc_link.adapter = &sc->sc_switch; sc->sc_link.adapter_softc = self; - sc->sc_link.adapter_buswidth = sc->sc_flags & HVSF_SCSI ? 64 : 1; - sc->sc_link.adapter_target = sc->sc_flags & HVSF_SCSI ? 64 : 1; + sc->sc_link.luns = sc->sc_flags & HVSF_SCSI ? 64 : 1; + sc->sc_link.adapter_buswidth = 2; + sc->sc_link.adapter_target = 2; sc->sc_link.openings = sc->sc_nccb; sc->sc_link.pool = &sc->sc_iopool; @@ -469,12 +469,8 @@ hvs_start(struct hvs_ccb *ccb) void hvs_poll_done(struct hvs_ccb *ccb) { - struct hvs_softc *sc = ccb->ccb_softc; int *rv = ccb->ccb_cookie; - if (ccb->ccb_cmd) - memcpy(&sc->sc_resp, ccb->ccb_cmd, HVS_CMD_SIZE); - *rv = 0; } @@ -701,7 +697,7 @@ hvs_connect(struct hvs_softc *sc) return (-1); } - ccb->ccb_done = hvs_empty_done; + ccb->ccb_done = hvs_cmd_done; cmd = (struct hvs_cmd_ver *)&ucmd; @@ -820,9 +816,12 @@ hvs_connect(struct hvs_softc *sc) } void -hvs_empty_done(struct hvs_ccb *ccb) +hvs_cmd_done(struct hvs_ccb *ccb) { - /* nothing */ + struct hvs_softc *sc = ccb->ccb_softc; + + if (ccb->ccb_cmd) + memcpy(&sc->sc_resp, ccb->ccb_cmd, HVS_CMD_SIZE); } int