diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2011-04-27 07:14:51 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2011-04-27 07:14:51 +0000 |
commit | 157ba4c6c2044e8df0dbd0428dae409dc8995a58 (patch) | |
tree | fefd9ea0efafe92a08f20a65bc8d0a1ce93d8aeb /sys/scsi | |
parent | 0e3edff357b3065473941e1c4870d66e14c4ba17 (diff) |
use dma safe memory when talking to devices. this was written before bigmem
required this.
requested by deraadt@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/mpath_emc.c | 51 | ||||
-rw-r--r-- | sys/scsi/mpath_rdac.c | 58 |
2 files changed, 67 insertions, 42 deletions
diff --git a/sys/scsi/mpath_emc.c b/sys/scsi/mpath_emc.c index cb77e0c079b..0589a7dbf9f 100644 --- a/sys/scsi/mpath_emc.c +++ b/sys/scsi/mpath_emc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpath_emc.c,v 1.1 2011/04/05 14:25:42 dlg Exp $ */ +/* $OpenBSD: mpath_emc.c,v 1.2 2011/04/27 07:14:50 dlg Exp $ */ /* * Copyright (c) 2011 David Gwynne <dlg@openbsd.org> @@ -232,23 +232,26 @@ emc_mpath_offline(struct scsi_link *link) int emc_inquiry(struct emc_softc *sc, char *model, char *serial) { - u_int8_t buffer[255]; + u_int8_t *buffer; struct scsi_inquiry *cdb; struct scsi_xfer *xs; size_t length; int error; u_int8_t slen, mlen; - length = MIN(sc->sc_path.p_link->inqdata.additional_length + 5, - sizeof(buffer)); + length = MIN(sc->sc_path.p_link->inqdata.additional_length + 5, 255); if (length < 160) { printf("%s: FC (Legacy)\n"); return (0); } + buffer = dma_alloc(length, PR_WAITOK); + xs = scsi_xs_get(sc->sc_path.p_link, scsi_autoconf); - if (xs == NULL) - return (EBUSY); + if (xs == NULL) { + error = EBUSY; + goto done; + } cdb = (struct scsi_inquiry *)xs->cmd; cdb->opcode = INQUIRY; @@ -263,36 +266,48 @@ emc_inquiry(struct emc_softc *sc, char *model, char *serial) scsi_xs_put(xs); if (error != 0) - return (error); + goto done; slen = buffer[160]; - if (slen == 0 || slen + 161 > length) - return (EIO); + if (slen == 0 || slen + 161 > length) { + error = EIO; + goto done; + } mlen = buffer[99]; - if (mlen == 0 || slen + mlen + 161 > length) - return (EIO); + if (mlen == 0 || slen + mlen + 161 > length) { + error = EIO; + goto done; + } scsi_strvis(serial, buffer + 161, slen); scsi_strvis(model, buffer + 161 + slen, mlen); - return (0); + error = 0; +done: + dma_free(buffer, length); + return (error); } int emc_sp_info(struct emc_softc *sc) { - struct emc_vpd_sp_info pg; + struct emc_vpd_sp_info *pg; int error; + pg = dma_alloc(sizeof(*pg), PR_WAITOK); + error = scsi_inquire_vpd(sc->sc_path.p_link, &pg, sizeof(pg), EMC_VPD_SP_INFO, scsi_autoconf); if (error != 0) - return (error); + goto done; - sc->sc_sp = pg.current_sp; - sc->sc_port = pg.port; - sc->sc_lun_state = pg.lun_state; + sc->sc_sp = pg->current_sp; + sc->sc_port = pg->port; + sc->sc_lun_state = pg->lun_state; - return (0); + error = 0; +done: + dma_free(pg, sizeof(*pg)); + return (error); } diff --git a/sys/scsi/mpath_rdac.c b/sys/scsi/mpath_rdac.c index 493912ead7e..6f530d968de 100644 --- a/sys/scsi/mpath_rdac.c +++ b/sys/scsi/mpath_rdac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpath_rdac.c,v 1.1 2011/04/05 14:25:42 dlg Exp $ */ +/* $OpenBSD: mpath_rdac.c,v 1.2 2011/04/27 07:14:50 dlg Exp $ */ /* * Copyright (c) 2010 David Gwynne <dlg@openbsd.org> @@ -273,63 +273,73 @@ rdac_mpath_offline(struct scsi_link *link) int rdac_c8(struct rdac_softc *sc) { - struct rdac_vpd_extdevid pg; + struct rdac_vpd_extdevid *pg; char array[31]; char vol[31]; int i; + int rv = 1; - if (scsi_inquire_vpd(sc->sc_path.p_link, &pg, sizeof(pg), 0xc8, + pg = dma_alloc(sizeof(*pg), PR_WAITOK | PR_ZERO); + + if (scsi_inquire_vpd(sc->sc_path.p_link, pg, sizeof(*pg), 0xc8, scsi_autoconf) != 0) { printf("%s: unable to fetch vpd page c8\n", DEVNAME(sc)); - return (1); + goto done; } - if (_4btol(pg.pg_id) != RDAC_VPD_ID_EXTDEVID) { + if (_4btol(pg->pg_id) != RDAC_VPD_ID_EXTDEVID) { printf("%s: extended hardware id page is invalid\n", DEVNAME(sc)); - return (1); + goto done; } memset(array, 0, sizeof(array)); - for (i = 0; i < sizeof(pg.array_label) / 2; i++) - array[i] = pg.array_label[i * 2 + 1]; + for (i = 0; i < sizeof(pg->array_label) / 2; i++) + array[i] = pg->array_label[i * 2 + 1]; memset(vol, 0, sizeof(vol)); - for (i = 0; i < sizeof(pg.vol_label) / 2; i++) - vol[i] = pg.vol_label[i * 2 + 1]; + for (i = 0; i < sizeof(pg->vol_label) / 2; i++) + vol[i] = pg->vol_label[i * 2 + 1]; printf("%s: array %s, volume %s\n", DEVNAME(sc), array, vol); - return (0); + rv = 0; +done: + dma_free(pg, sizeof(*pg)); + return (rv); } int rdac_c9(struct rdac_softc *sc) { - struct rdac_vpd_volaccessctl pg; + struct rdac_vpd_volaccessctl *pg; + int rv = 1; - if (scsi_inquire_vpd(sc->sc_path.p_link, &pg, sizeof(pg), + pg = dma_alloc(sizeof(*pg), PR_WAITOK | PR_ZERO); + + if (scsi_inquire_vpd(sc->sc_path.p_link, pg, sizeof(*pg), RDAC_VPD_VOLACCESSCTL, scsi_autoconf) != 0) { printf("%s: unable to fetch vpd page c9\n", DEVNAME(sc)); - return (1); + goto done; } - if (_4btol(pg.pg_id) != RDAC_VPD_ID_VOLACCESSCTL) { + if (_4btol(pg->pg_id) != RDAC_VPD_ID_VOLACCESSCTL) { printf("%s: volume access control page id is invalid\n", DEVNAME(sc)); - return (1); + goto done; } - if (ISSET(pg.avtcvp, RDAC_VOLACCESSCTL_AVT)) { + if (ISSET(pg->avtcvp, RDAC_VOLACCESSCTL_AVT)) { printf("%s: avt\n", DEVNAME(sc)); - return (0); - } - if (ISSET(pg.avtcvp, RDAC_VOLACCESSCTL_OWNER)) { + rv = 0; + } else if (ISSET(pg->avtcvp, RDAC_VOLACCESSCTL_OWNER)) { printf("%s: owner\n", DEVNAME(sc)); - return (0); - } + rv = 0; + } else + printf("%s: unowned\n", DEVNAME(sc)); - printf("%s: unowned\n", DEVNAME(sc)); - return (1); +done: + dma_free(pg, sizeof(*pg)); + return (rv); } |