diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-07-10 19:43:10 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-07-10 19:43:10 +0000 |
commit | 85062ec526d6ea60b2fe51a8c8df5ec498859865 (patch) | |
tree | 291e9384b7265fb8e2f8a698d4149e63f2a3e727 /sys/dev/pv | |
parent | f9090d0fdcf5f0bcf3648548468a1f1b8439e2da (diff) |
Shuffle a bit of code to stop using sc->sc_link to hold values for
openings outside of the one used at config_found() time. Adapters
should take care of their own data.
ok dlg@ for a sligthly different vioblk.c version.
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/vioblk.c | 10 | ||||
-rw-r--r-- | sys/dev/pv/vioscsi.c | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/pv/vioblk.c b/sys/dev/pv/vioblk.c index 670b8fc0197..8e47821ba99 100644 --- a/sys/dev/pv/vioblk.c +++ b/sys/dev/pv/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.20 2020/06/27 14:29:45 krw Exp $ */ +/* $OpenBSD: vioblk.c,v 1.21 2020/07/10 19:43:09 krw Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -107,6 +107,7 @@ struct vioblk_softc { struct virtqueue sc_vq[1]; struct virtio_blk_req *sc_reqs; bus_dma_segment_t sc_reqs_segs[1]; + int sc_nreqs; struct scsi_link sc_link; struct scsi_iopool sc_iopool; @@ -229,12 +230,13 @@ vioblk_attach(struct device *parent, struct device *self, void *aux) mtx_init(&sc->sc_vr_mtx, IPL_BIO); scsi_iopool_init(&sc->sc_iopool, sc, vioblk_req_get, vioblk_req_put); - sc->sc_link.openings = vioblk_alloc_reqs(sc, qsize); - if (sc->sc_link.openings == 0) { + sc->sc_nreqs = vioblk_alloc_reqs(sc, qsize); + if (sc->sc_nreqs == 0) { printf("\nCan't alloc reqs\n"); goto err; } + sc->sc_link.openings = sc->sc_nreqs; sc->sc_link.adapter = &vioblk_switch; sc->sc_link.pool = &sc->sc_iopool; sc->sc_link.adapter_softc = self; @@ -373,7 +375,7 @@ vioblk_reset(struct vioblk_softc *sc) vioblk_vq_done(&sc->sc_vq[0]); /* abort all remaining requests */ - for (i = 0; i < sc->sc_link.openings; i++) { + for (i = 0; i < sc->sc_nreqs; i++) { struct virtio_blk_req *vr = &sc->sc_reqs[i]; struct scsi_xfer *xs = vr->vr_xs; diff --git a/sys/dev/pv/vioscsi.c b/sys/dev/pv/vioscsi.c index 94b18b74e5d..76a027e5172 100644 --- a/sys/dev/pv/vioscsi.c +++ b/sys/dev/pv/vioscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioscsi.c,v 1.19 2020/06/27 17:28:58 krw Exp $ */ +/* $OpenBSD: vioscsi.c,v 1.20 2020/07/10 19:43:09 krw Exp $ */ /* * Copyright (c) 2013 Google Inc. * @@ -154,13 +154,13 @@ vioscsi_attach(struct device *parent, struct device *self, void *aux) mtx_init(&sc->sc_vr_mtx, IPL_BIO); scsi_iopool_init(&sc->sc_iopool, sc, vioscsi_req_get, vioscsi_req_put); - sc->sc_link.openings = vioscsi_alloc_reqs(sc, vsc, qsize); - if (sc->sc_link.openings == 0) { + int nreqs = vioscsi_alloc_reqs(sc, vsc, qsize); + if (nreqs == 0) { printf("\nCan't alloc reqs\n"); goto err; - } else if (sc->sc_link.openings > cmd_per_lun) - sc->sc_link.openings = cmd_per_lun; + } + sc->sc_link.openings = (nreqs > cmd_per_lun) ? cmd_per_lun : nreqs; sc->sc_link.adapter = &vioscsi_switch; sc->sc_link.adapter_softc = sc; sc->sc_link.adapter_target = SDEV_NO_ADAPTER_TARGET; |