diff options
author | peter <peter@FreeBSD.org> | 1998-04-16 12:28:31 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-04-16 12:28:31 +0000 |
commit | bee3002b7dbd4cd7e368e51d13e2bd2fa00c32b4 (patch) | |
tree | bce99dd22cd9acf87ef4e29cab467996cfbe96e8 /sys | |
parent | 8c412834a471859e654ad07977b4f5b1ec8eb4d7 (diff) | |
download | FreeBSD-src-bee3002b7dbd4cd7e368e51d13e2bd2fa00c32b4.zip FreeBSD-src-bee3002b7dbd4cd7e368e51d13e2bd2fa00c32b4.tar.gz |
Attempt to fix BOUNCE_BUFFERS. I cannot test these drivers, but they
seem to compile OK with the bounce buffer mods. I have only visually
checked for missing bounce buffer support, I could have missed some.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/ch.c | 31 | ||||
-rw-r--r-- | sys/scsi/worm.c | 25 |
2 files changed, 54 insertions, 2 deletions
diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index 5b507c6..5faca39 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -33,10 +33,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ch.c,v 1.42 1997/09/14 03:19:38 peter Exp $ + * $Id: ch.c,v 1.43 1998/01/24 02:54:48 eivind Exp $ */ #include "opt_devfs.h" +#include "opt_bounce.h" #include <sys/param.h> #include <sys/systm.h> @@ -47,6 +48,9 @@ #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ +#ifdef BOUNCE_BUFFERS +#include <sys/buf.h> +#endif #include <scsi/scsi_changer.h> #include <scsi/scsiconf.h> @@ -507,6 +511,9 @@ ch_usergetelemstatus(sc, chet, uptr) struct read_element_status_page_header *pg_hdr; struct read_element_status_descriptor *desc; caddr_t data = NULL; +#ifdef BOUNCE_BUFFERS + int datasize = 0; +#endif size_t size, desclen; int avail, i, error = 0; u_int8_t *user_data = NULL; @@ -524,7 +531,14 @@ ch_usergetelemstatus(sc, chet, uptr) * we can allocate enough storage for all of them. We assume * that the first one can fit into 1k. */ +#ifdef BOUNCE_BUFFERS + data = (caddr_t)vm_bounce_kva_alloc(btoc(1024)); + if (!data) + return (ENOMEM); + datasize = 1024; +#else data = (caddr_t)malloc(1024, M_DEVBUF, M_WAITOK); +#endif if (error = ch_getelemstatus(sc, sc->sc_firsts[chet], 1, data, 1024)) goto done; @@ -541,8 +555,18 @@ ch_usergetelemstatus(sc, chet, uptr) * Reallocate storage for descriptors and get them from the * device. */ +#ifdef BOUNCE_BUFFERS + vm_bounce_kva_alloc_free((vm_offset_t)data, btoc(datasize)); + data = (caddr_t)vm_bounce_kva_alloc(btoc(size)); + if (!data) { + error = ENOMEM; + goto done; + } + datasize = size; +#else free(data, M_DEVBUF); data = (caddr_t)malloc(size, M_DEVBUF, M_WAITOK); +#endif if (error = ch_getelemstatus(sc, sc->sc_firsts[chet], sc->sc_counts[chet], data, size)) goto done; @@ -570,8 +594,13 @@ ch_usergetelemstatus(sc, chet, uptr) error = copyout(user_data, uptr, avail); done: +#ifdef BOUNCE_BUFFERS + if (data != NULL) + vm_bounce_kva_alloc_free((vm_offset_t)data, btoc(datasize)); +#else if (data != NULL) free(data, M_DEVBUF); +#endif if (user_data != NULL) free(user_data, M_DEVBUF); return (error); diff --git a/sys/scsi/worm.c b/sys/scsi/worm.c index e79c512..c8f7200 100644 --- a/sys/scsi/worm.c +++ b/sys/scsi/worm.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: worm.c,v 1.53 1998/03/31 01:56:21 jmz Exp $ + * $Id: worm.c,v 1.54 1998/04/15 17:47:24 bde Exp $ */ #include "opt_bounce.h" @@ -611,7 +611,13 @@ worm_close(dev_t dev, int flags, int fmt, struct proc *p, } else { worm->worm_flags &= ~WORMFL_IOCTL_ONLY; if (worm->write_session) { +#ifdef BOUNCE_BUFFERS + vm_bounce_kva_alloc_free((vm_offset_t)worm->write_session, + btoc(sizeof(struct wormio_write_session) + + worm->write_session->length)); +#else free(worm->write_session, M_DEVBUF); +#endif worm->write_session = 0; } } @@ -677,7 +683,13 @@ worm_ioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p, worm->worm_flags |= WORMFL_TRACK_PREP; worm->preptrack = *w; if (worm->write_session) { +#ifdef BOUNCE_BUFFERS + vm_bounce_kva_alloc_free((vm_offset_t)worm->write_session, + btoc(sizeof(struct wormio_write_session) + + worm->write_session->length)); +#else free(worm->write_session, M_DEVBUF); +#endif worm->write_session = 0; } } @@ -732,9 +744,20 @@ worm_ioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p, error = EINVAL; worm->error = WORM_SEQUENCE_ERROR; } else { +#ifdef BOUNCE_BUFFERS + worm->write_session = (struct wormio_write_session *) + vm_bounce_kva_alloc( + btoc(sizeof(struct wormio_write_session) + + ((struct wormio_write_session *) addr)->length)); + if (!worm->write_session) { + error = ENOMEM; + break; + } +#else worm->write_session = malloc(sizeof(struct wormio_write_session) + ((struct wormio_write_session *) addr)->length, M_DEVBUF, M_WAITOK); +#endif bcopy(addr, worm->write_session, sizeof(struct wormio_write_session)); worm->write_session->track_desc = sizeof(struct wormio_write_session) + (u_char *) worm->write_session; |