summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-07-10 19:43:09 +0000
committerkrw <krw@openbsd.org>2020-07-10 19:43:09 +0000
commitc0d956de747863e6a7710c912198e57be0601af2 (patch)
tree072884d2400120e419a28427c9baadecfb039028
parentOops, I didn't intend to commit these bits. (diff)
downloadwireguard-openbsd-c0d956de747863e6a7710c912198e57be0601af2.tar.xz
wireguard-openbsd-c0d956de747863e6a7710c912198e57be0601af2.zip
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.
-rw-r--r--sys/dev/pv/vioblk.c10
-rw-r--r--sys/dev/pv/vioscsi.c10
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;