Expand struct scsipi_bustype {} in a ABI-backward-compatible way to pass more informations about the bus: - bustype_type has 2 different bytes, one holding the existing SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_* subtype. Introduce macros to build or extract bustype_type. - for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel, SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI is 0 so that bustype_type value doesn't change for existing code - for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet, so the bustype_type value doesn't change. - provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype along with scsi_bustype to be used by bus driver where appropriate - scsipi_print_xfer_mode(): more existing code under a (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as sync/wide parameters only make sense for parallel SCSI. For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print tagged queing status if enabled. Just be silent for other bustypes. This change is prompted by this problem: right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with appropriate parameters is enough to enable tagged queuing, but then scsipi will print: sd0: async, 8-bit transfers, tagged queueing which is harmless (async, 8-bit transfers doens't make sense on SAS anyway) but will confuse users. With this change scsipi will only print: sd0: tagged queueing which is correct. In the long run, knowning the underlying transport in scsipi will allow better handling of device which are not parallel SCSI. Another change adding an extra callback to struct scsipi_bustype {} will come (so that scsipi_print_xfer_mode(), which is SCSI-specific, can be moved out of scsipi_base, and split into per-subtype callback), but this will break kernel ABI and so is not suitable for netbsd-6, so will be commmited later. The above is enough to get tagged queuing on FC and SAS in netbsd-6.diff -r1.84 -r1.85 src/sys/dev/scsipi/atapiconf.c
(bouyer)
--- src/sys/dev/scsipi/atapiconf.c 2012/04/06 17:12:45 1.84
+++ src/sys/dev/scsipi/atapiconf.c 2012/04/19 17:45:20 1.85
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $ */ | 1 | /* $NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved. | 4 | * Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $"); | |
29 | 29 | |||
30 | #include <sys/param.h> | 30 | #include <sys/param.h> | |
31 | #include <sys/systm.h> | 31 | #include <sys/systm.h> | |
32 | #include <sys/malloc.h> | 32 | #include <sys/malloc.h> | |
33 | #include <sys/device.h> | 33 | #include <sys/device.h> | |
34 | #include <sys/buf.h> | 34 | #include <sys/buf.h> | |
35 | #include <sys/proc.h> | 35 | #include <sys/proc.h> | |
36 | #include <sys/kthread.h> | 36 | #include <sys/kthread.h> | |
37 | 37 | |||
38 | #include <dev/scsipi/scsipi_all.h> | 38 | #include <dev/scsipi/scsipi_all.h> | |
39 | #include <dev/scsipi/scsipiconf.h> | 39 | #include <dev/scsipi/scsipiconf.h> | |
40 | #include <dev/scsipi/atapiconf.h> | 40 | #include <dev/scsipi/atapiconf.h> | |
41 | 41 | |||
@@ -107,27 +107,28 @@ atapiprint(void *aux, const char *pnp) | @@ -107,27 +107,28 @@ atapiprint(void *aux, const char *pnp) | |||
107 | if (pnp) | 107 | if (pnp) | |
108 | aprint_normal("atapibus at %s", pnp); | 108 | aprint_normal("atapibus at %s", pnp); | |
109 | return (UNCONF); | 109 | return (UNCONF); | |
110 | } | 110 | } | |
111 | 111 | |||
112 | static int | 112 | static int | |
113 | atapibusmatch(device_t parent, cfdata_t cf, void *aux) | 113 | atapibusmatch(device_t parent, cfdata_t cf, void *aux) | |
114 | { | 114 | { | |
115 | struct scsipi_channel *chan = aux; | 115 | struct scsipi_channel *chan = aux; | |
116 | 116 | |||
117 | if (chan == NULL) | 117 | if (chan == NULL) | |
118 | return (0); | 118 | return (0); | |
119 | 119 | |||
120 | if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_ATAPI) | 120 | if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) != | |
121 | SCSIPI_BUSTYPE_ATAPI) | |||
121 | return (0); | 122 | return (0); | |
122 | 123 | |||
123 | return (1); | 124 | return (1); | |
124 | } | 125 | } | |
125 | 126 | |||
126 | static int | 127 | static int | |
127 | atapibussubmatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | 128 | atapibussubmatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | |
128 | { | 129 | { | |
129 | struct scsipibus_attach_args *sa = aux; | 130 | struct scsipibus_attach_args *sa = aux; | |
130 | struct scsipi_periph *periph = sa->sa_periph; | 131 | struct scsipi_periph *periph = sa->sa_periph; | |
131 | 132 | |||
132 | if (cf->cf_loc[ATAPIBUSCF_DRIVE] != ATAPIBUSCF_DRIVE_DEFAULT && | 133 | if (cf->cf_loc[ATAPIBUSCF_DRIVE] != ATAPIBUSCF_DRIVE_DEFAULT && | |
133 | cf->cf_loc[ATAPIBUSCF_DRIVE] != periph->periph_target) | 134 | cf->cf_loc[ATAPIBUSCF_DRIVE] != periph->periph_target) |
--- src/sys/dev/scsipi/cd.c 2012/02/25 10:17:14 1.306
+++ src/sys/dev/scsipi/cd.c 2012/04/19 17:45:20 1.307
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $ */ | 1 | /* $NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, | 4 | * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation, | |
5 | * Inc. All rights reserved. | 5 | * Inc. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * MMC framework implemented and contributed to the NetBSD Foundation by | 10 | * MMC framework implemented and contributed to the NetBSD Foundation by | |
11 | * Reinoud Zandijk. | 11 | * Reinoud Zandijk. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | * Mellon University, makes this software available to CMU to distribute | 40 | * Mellon University, makes this software available to CMU to distribute | |
41 | * or use in any manner that they see fit as long as this message is kept with | 41 | * or use in any manner that they see fit as long as this message is kept with | |
42 | * the software. For this reason TFS also grants any other persons or | 42 | * the software. For this reason TFS also grants any other persons or | |
43 | * organisations permission to use or modify this software. | 43 | * organisations permission to use or modify this software. | |
44 | * | 44 | * | |
45 | * TFS supplies this software to be publicly redistributed | 45 | * TFS supplies this software to be publicly redistributed | |
46 | * on the understanding that TFS is not responsible for the correct | 46 | * on the understanding that TFS is not responsible for the correct | |
47 | * functioning of this software in any circumstances. | 47 | * functioning of this software in any circumstances. | |
48 | * | 48 | * | |
49 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | 49 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | |
50 | */ | 50 | */ | |
51 | 51 | |||
52 | #include <sys/cdefs.h> | 52 | #include <sys/cdefs.h> | |
53 | __KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $"); | 53 | __KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $"); | |
54 | 54 | |||
55 | #include <sys/param.h> | 55 | #include <sys/param.h> | |
56 | #include <sys/systm.h> | 56 | #include <sys/systm.h> | |
57 | #include <sys/kernel.h> | 57 | #include <sys/kernel.h> | |
58 | #include <sys/file.h> | 58 | #include <sys/file.h> | |
59 | #include <sys/stat.h> | 59 | #include <sys/stat.h> | |
60 | #include <sys/ioctl.h> | 60 | #include <sys/ioctl.h> | |
61 | #include <sys/buf.h> | 61 | #include <sys/buf.h> | |
62 | #include <sys/bufq.h> | 62 | #include <sys/bufq.h> | |
63 | #include <sys/uio.h> | 63 | #include <sys/uio.h> | |
64 | #include <sys/malloc.h> | 64 | #include <sys/malloc.h> | |
65 | #include <sys/errno.h> | 65 | #include <sys/errno.h> | |
66 | #include <sys/device.h> | 66 | #include <sys/device.h> | |
@@ -241,28 +241,28 @@ cdmatch(device_t parent, cfdata_t match, | @@ -241,28 +241,28 @@ cdmatch(device_t parent, cfdata_t match, | |||
241 | static void | 241 | static void | |
242 | cdattach(device_t parent, device_t self, void *aux) | 242 | cdattach(device_t parent, device_t self, void *aux) | |
243 | { | 243 | { | |
244 | struct cd_softc *cd = device_private(self); | 244 | struct cd_softc *cd = device_private(self); | |
245 | struct scsipibus_attach_args *sa = aux; | 245 | struct scsipibus_attach_args *sa = aux; | |
246 | struct scsipi_periph *periph = sa->sa_periph; | 246 | struct scsipi_periph *periph = sa->sa_periph; | |
247 | 247 | |||
248 | SC_DEBUG(periph, SCSIPI_DB2, ("cdattach: ")); | 248 | SC_DEBUG(periph, SCSIPI_DB2, ("cdattach: ")); | |
249 | 249 | |||
250 | cd->sc_dev = self; | 250 | cd->sc_dev = self; | |
251 | 251 | |||
252 | mutex_init(&cd->sc_lock, MUTEX_DEFAULT, IPL_NONE); | 252 | mutex_init(&cd->sc_lock, MUTEX_DEFAULT, IPL_NONE); | |
253 | 253 | |||
254 | if (scsipi_periph_bustype(sa->sa_periph) == SCSIPI_BUSTYPE_SCSI && | 254 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) == | |
255 | periph->periph_version == 0) | 255 | SCSIPI_BUSTYPE_SCSI && periph->periph_version == 0) | |
256 | cd->flags |= CDF_ANCIENT; | 256 | cd->flags |= CDF_ANCIENT; | |
257 | 257 | |||
258 | bufq_alloc(&cd->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK); | 258 | bufq_alloc(&cd->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK); | |
259 | 259 | |||
260 | callout_init(&cd->sc_callout, 0); | 260 | callout_init(&cd->sc_callout, 0); | |
261 | 261 | |||
262 | /* | 262 | /* | |
263 | * Store information needed to contact our base driver | 263 | * Store information needed to contact our base driver | |
264 | */ | 264 | */ | |
265 | cd->sc_periph = periph; | 265 | cd->sc_periph = periph; | |
266 | 266 | |||
267 | periph->periph_dev = cd->sc_dev; | 267 | periph->periph_dev = cd->sc_dev; | |
268 | periph->periph_switch = &cd_switch; | 268 | periph->periph_switch = &cd_switch; | |
@@ -1672,27 +1672,27 @@ static void | @@ -1672,27 +1672,27 @@ static void | |||
1672 | cdgetdefaultlabel(struct cd_softc *cd, struct cd_formatted_toc *toc, | 1672 | cdgetdefaultlabel(struct cd_softc *cd, struct cd_formatted_toc *toc, | |
1673 | struct disklabel *lp) | 1673 | struct disklabel *lp) | |
1674 | { | 1674 | { | |
1675 | int lastsession; | 1675 | int lastsession; | |
1676 | 1676 | |||
1677 | memset(lp, 0, sizeof(struct disklabel)); | 1677 | memset(lp, 0, sizeof(struct disklabel)); | |
1678 | 1678 | |||
1679 | lp->d_secsize = cd->params.blksize; | 1679 | lp->d_secsize = cd->params.blksize; | |
1680 | lp->d_ntracks = 1; | 1680 | lp->d_ntracks = 1; | |
1681 | lp->d_nsectors = 100; | 1681 | lp->d_nsectors = 100; | |
1682 | lp->d_ncylinders = (cd->params.disksize / 100) + 1; | 1682 | lp->d_ncylinders = (cd->params.disksize / 100) + 1; | |
1683 | lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; | 1683 | lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; | |
1684 | 1684 | |||
1685 | switch (scsipi_periph_bustype(cd->sc_periph)) { | 1685 | switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(cd->sc_periph))) { | |
1686 | case SCSIPI_BUSTYPE_SCSI: | 1686 | case SCSIPI_BUSTYPE_SCSI: | |
1687 | lp->d_type = DTYPE_SCSI; | 1687 | lp->d_type = DTYPE_SCSI; | |
1688 | break; | 1688 | break; | |
1689 | case SCSIPI_BUSTYPE_ATAPI: | 1689 | case SCSIPI_BUSTYPE_ATAPI: | |
1690 | lp->d_type = DTYPE_ATAPI; | 1690 | lp->d_type = DTYPE_ATAPI; | |
1691 | break; | 1691 | break; | |
1692 | } | 1692 | } | |
1693 | /* | 1693 | /* | |
1694 | * XXX | 1694 | * XXX | |
1695 | * We could probe the mode pages to figure out what kind of disc it is. | 1695 | * We could probe the mode pages to figure out what kind of disc it is. | |
1696 | * Is this worthwhile? | 1696 | * Is this worthwhile? | |
1697 | */ | 1697 | */ | |
1698 | strncpy(lp->d_typename, "optical media", 16); | 1698 | strncpy(lp->d_typename, "optical media", 16); |
--- src/sys/dev/scsipi/scsiconf.c 2012/04/06 22:50:39 1.265
+++ src/sys/dev/scsipi/scsiconf.c 2012/04/19 17:45:20 1.266
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: scsiconf.c,v 1.265 2012/04/06 22:50:39 christos Exp $ */ | 1 | /* $NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility, NASA Ames Research Center. | 9 | * Simulation Facility, NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -38,27 +38,27 @@ | @@ -38,27 +38,27 @@ | |||
38 | * Mellon University, makes this software available to CMU to distribute | 38 | * Mellon University, makes this software available to CMU to distribute | |
39 | * or use in any manner that they see fit as long as this message is kept with | 39 | * or use in any manner that they see fit as long as this message is kept with | |
40 | * the software. For this reason TFS also grants any other persons or | 40 | * the software. For this reason TFS also grants any other persons or | |
41 | * organisations permission to use or modify this software. | 41 | * organisations permission to use or modify this software. | |
42 | * | 42 | * | |
43 | * TFS supplies this software to be publicly redistributed | 43 | * TFS supplies this software to be publicly redistributed | |
44 | * on the understanding that TFS is not responsible for the correct | 44 | * on the understanding that TFS is not responsible for the correct | |
45 | * functioning of this software in any circumstances. | 45 | * functioning of this software in any circumstances. | |
46 | * | 46 | * | |
47 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | 47 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | |
48 | */ | 48 | */ | |
49 | 49 | |||
50 | #include <sys/cdefs.h> | 50 | #include <sys/cdefs.h> | |
51 | __KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.265 2012/04/06 22:50:39 christos Exp $"); | 51 | __KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $"); | |
52 | 52 | |||
53 | #include <sys/param.h> | 53 | #include <sys/param.h> | |
54 | #include <sys/systm.h> | 54 | #include <sys/systm.h> | |
55 | #include <sys/kernel.h> | 55 | #include <sys/kernel.h> | |
56 | #include <sys/proc.h> | 56 | #include <sys/proc.h> | |
57 | #include <sys/kthread.h> | 57 | #include <sys/kthread.h> | |
58 | #include <sys/malloc.h> | 58 | #include <sys/malloc.h> | |
59 | #include <sys/mutex.h> | 59 | #include <sys/mutex.h> | |
60 | #include <sys/once.h> | 60 | #include <sys/once.h> | |
61 | #include <sys/device.h> | 61 | #include <sys/device.h> | |
62 | #include <sys/conf.h> | 62 | #include <sys/conf.h> | |
63 | #include <sys/fcntl.h> | 63 | #include <sys/fcntl.h> | |
64 | #include <sys/scsiio.h> | 64 | #include <sys/scsiio.h> | |
@@ -104,27 +104,51 @@ extern struct cfdriver scsibus_cd; | @@ -104,27 +104,51 @@ extern struct cfdriver scsibus_cd; | |||
104 | static dev_type_open(scsibusopen); | 104 | static dev_type_open(scsibusopen); | |
105 | static dev_type_close(scsibusclose); | 105 | static dev_type_close(scsibusclose); | |
106 | static dev_type_ioctl(scsibusioctl); | 106 | static dev_type_ioctl(scsibusioctl); | |
107 | 107 | |||
108 | const struct cdevsw scsibus_cdevsw = { | 108 | const struct cdevsw scsibus_cdevsw = { | |
109 | scsibusopen, scsibusclose, noread, nowrite, scsibusioctl, | 109 | scsibusopen, scsibusclose, noread, nowrite, scsibusioctl, | |
110 | nostop, notty, nopoll, nommap, nokqfilter, D_OTHER, | 110 | nostop, notty, nopoll, nommap, nokqfilter, D_OTHER, | |
111 | }; | 111 | }; | |
112 | 112 | |||
113 | static int scsibusprint(void *, const char *); | 113 | static int scsibusprint(void *, const char *); | |
114 | static void scsibus_config(struct scsipi_channel *, void *); | 114 | static void scsibus_config(struct scsipi_channel *, void *); | |
115 | 115 | |||
116 | const struct scsipi_bustype scsi_bustype = { | 116 | const struct scsipi_bustype scsi_bustype = { | |
117 | SCSIPI_BUSTYPE_SCSI, | 117 | SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI), | |
118 | scsi_scsipi_cmd, | |||
119 | scsipi_interpret_sense, | |||
120 | scsi_print_addr, | |||
121 | scsi_kill_pending, | |||
122 | }; | |||
123 | ||||
124 | const struct scsipi_bustype scsi_fc_bustype = { | |||
125 | SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC), | |||
126 | scsi_scsipi_cmd, | |||
127 | scsipi_interpret_sense, | |||
128 | scsi_print_addr, | |||
129 | scsi_kill_pending, | |||
130 | }; | |||
131 | ||||
132 | const struct scsipi_bustype scsi_sas_bustype = { | |||
133 | SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), | |||
134 | scsi_scsipi_cmd, | |||
135 | scsipi_interpret_sense, | |||
136 | scsi_print_addr, | |||
137 | scsi_kill_pending, | |||
138 | }; | |||
139 | ||||
140 | const struct scsipi_bustype scsi_usb_bustype = { | |||
141 | SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_USB), | |||
118 | scsi_scsipi_cmd, | 142 | scsi_scsipi_cmd, | |
119 | scsipi_interpret_sense, | 143 | scsipi_interpret_sense, | |
120 | scsi_print_addr, | 144 | scsi_print_addr, | |
121 | scsi_kill_pending, | 145 | scsi_kill_pending, | |
122 | }; | 146 | }; | |
123 | 147 | |||
124 | static int | 148 | static int | |
125 | scsibus_init(void) | 149 | scsibus_init(void) | |
126 | { | 150 | { | |
127 | 151 | |||
128 | TAILQ_INIT(&scsi_initq_head); | 152 | TAILQ_INIT(&scsi_initq_head); | |
129 | mutex_init(&scsibus_qlock, MUTEX_DEFAULT, IPL_NONE); | 153 | mutex_init(&scsibus_qlock, MUTEX_DEFAULT, IPL_NONE); | |
130 | cv_init(&scsibus_qcv, "scsinitq"); | 154 | cv_init(&scsibus_qcv, "scsinitq"); | |
@@ -143,27 +167,28 @@ scsiprint(void *aux, const char *pnp) | @@ -143,27 +167,28 @@ scsiprint(void *aux, const char *pnp) | |||
143 | 167 | |||
144 | /* don't print channel if the controller says there can be only one. */ | 168 | /* don't print channel if the controller says there can be only one. */ | |
145 | if (adapt->adapt_nchannels != 1) | 169 | if (adapt->adapt_nchannels != 1) | |
146 | aprint_normal(" channel %d", chan->chan_channel); | 170 | aprint_normal(" channel %d", chan->chan_channel); | |
147 | 171 | |||
148 | return (UNCONF); | 172 | return (UNCONF); | |
149 | } | 173 | } | |
150 | 174 | |||
151 | static int | 175 | static int | |
152 | scsibusmatch(device_t parent, cfdata_t cf, void *aux) | 176 | scsibusmatch(device_t parent, cfdata_t cf, void *aux) | |
153 | { | 177 | { | |
154 | struct scsipi_channel *chan = aux; | 178 | struct scsipi_channel *chan = aux; | |
155 | 179 | |||
156 | if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_SCSI) | 180 | if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) != | |
181 | SCSIPI_BUSTYPE_SCSI) | |||
157 | return 0; | 182 | return 0; | |
158 | 183 | |||
159 | if (cf->cf_loc[SCSICF_CHANNEL] != chan->chan_channel && | 184 | if (cf->cf_loc[SCSICF_CHANNEL] != chan->chan_channel && | |
160 | cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT) | 185 | cf->cf_loc[SCSICF_CHANNEL] != SCSICF_CHANNEL_DEFAULT) | |
161 | return (0); | 186 | return (0); | |
162 | 187 | |||
163 | return (1); | 188 | return (1); | |
164 | } | 189 | } | |
165 | 190 | |||
166 | static void | 191 | static void | |
167 | scsibusattach(device_t parent, device_t self, void *aux) | 192 | scsibusattach(device_t parent, device_t self, void *aux) | |
168 | { | 193 | { | |
169 | struct scsibus_softc *sc = device_private(self); | 194 | struct scsibus_softc *sc = device_private(self); |
--- src/sys/dev/scsipi/scsiconf.h 2008/07/16 18:50:58 1.56
+++ src/sys/dev/scsipi/scsiconf.h 2012/04/19 17:45:20 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: scsiconf.h,v 1.56 2008/07/16 18:50:58 drochner Exp $ */ | 1 | /* $NetBSD: scsiconf.h,v 1.57 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility, NASA Ames Research Center. | 9 | * Simulation Facility, NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -54,21 +54,24 @@ | @@ -54,21 +54,24 @@ | |||
54 | 54 | |||
55 | int scsiprint(void *, const char *); | 55 | int scsiprint(void *, const char *); | |
56 | 56 | |||
57 | struct scsibus_softc { | 57 | struct scsibus_softc { | |
58 | device_t sc_dev; | 58 | device_t sc_dev; | |
59 | struct scsipi_channel *sc_channel; /* our scsipi_channel */ | 59 | struct scsipi_channel *sc_channel; /* our scsipi_channel */ | |
60 | int sc_flags; | 60 | int sc_flags; | |
61 | }; | 61 | }; | |
62 | 62 | |||
63 | /* sc_flags */ | 63 | /* sc_flags */ | |
64 | #define SCSIBUSF_OPEN 0x00000001 /* bus is open */ | 64 | #define SCSIBUSF_OPEN 0x00000001 /* bus is open */ | |
65 | 65 | |||
66 | extern const struct scsipi_bustype scsi_bustype; | 66 | extern const struct scsipi_bustype scsi_bustype; | |
67 | extern const struct scsipi_bustype scsi_fc_bustype; | |||
68 | extern const struct scsipi_bustype scsi_sas_bustype; | |||
69 | extern const struct scsipi_bustype scsi_usb_bustype; | |||
67 | 70 | |||
68 | int scsi_change_def(struct scsipi_periph *, int); | 71 | int scsi_change_def(struct scsipi_periph *, int); | |
69 | void scsi_kill_pending(struct scsipi_periph *); | 72 | void scsi_kill_pending(struct scsipi_periph *); | |
70 | void scsi_print_addr(struct scsipi_periph *); | 73 | void scsi_print_addr(struct scsipi_periph *); | |
71 | int scsi_probe_bus(struct scsibus_softc *, int, int); | 74 | int scsi_probe_bus(struct scsibus_softc *, int, int); | |
72 | void scsi_scsipi_cmd(struct scsipi_xfer *); | 75 | void scsi_scsipi_cmd(struct scsipi_xfer *); | |
73 | 76 | |||
74 | #endif /* _DEV_SCSIPI_SCSICONF_H_ */ | 77 | #endif /* _DEV_SCSIPI_SCSICONF_H_ */ |
--- src/sys/dev/scsipi/scsipi_base.c 2012/04/18 20:37:49 1.157
+++ src/sys/dev/scsipi/scsipi_base.c 2012/04/19 17:45:20 1.158
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $ */ | 1 | /* $NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility, NASA Ames Research Center. | 9 | * Simulation Facility, NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $"); | |
35 | 35 | |||
36 | #include "opt_scsi.h" | 36 | #include "opt_scsi.h" | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/buf.h> | 41 | #include <sys/buf.h> | |
42 | #include <sys/uio.h> | 42 | #include <sys/uio.h> | |
43 | #include <sys/malloc.h> | 43 | #include <sys/malloc.h> | |
44 | #include <sys/pool.h> | 44 | #include <sys/pool.h> | |
45 | #include <sys/errno.h> | 45 | #include <sys/errno.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/proc.h> | 47 | #include <sys/proc.h> | |
@@ -2171,62 +2171,83 @@ scsipi_async_event(struct scsipi_channel | @@ -2171,62 +2171,83 @@ scsipi_async_event(struct scsipi_channel | |||
2171 | /* | 2171 | /* | |
2172 | * scsipi_print_xfer_mode: | 2172 | * scsipi_print_xfer_mode: | |
2173 | * | 2173 | * | |
2174 | * Print a periph's capabilities. | 2174 | * Print a periph's capabilities. | |
2175 | */ | 2175 | */ | |
2176 | void | 2176 | void | |
2177 | scsipi_print_xfer_mode(struct scsipi_periph *periph) | 2177 | scsipi_print_xfer_mode(struct scsipi_periph *periph) | |
2178 | { | 2178 | { | |
2179 | int period, freq, speed, mbs; | 2179 | int period, freq, speed, mbs; | |
2180 | 2180 | |||
2181 | if ((periph->periph_flags & PERIPH_MODE_VALID) == 0) | 2181 | if ((periph->periph_flags & PERIPH_MODE_VALID) == 0) | |
2182 | return; | 2182 | return; | |
2183 | 2183 | |||
2184 | aprint_normal_dev(periph->periph_dev, ""); | 2184 | switch(scsipi_periph_bustype(periph)) { | |
2185 | if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) { | 2185 | case SCSIPI_BUSTYPE_BUSTYPE( | |
2186 | period = scsipi_sync_factor_to_period(periph->periph_period); | 2186 | SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI): | |
2187 | aprint_normal("sync (%d.%02dns offset %d)", | 2187 | aprint_normal_dev(periph->periph_dev, ""); | |
2188 | period / 100, period % 100, periph->periph_offset); | 2188 | if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) { | |
2189 | } else | 2189 | period = | |
2190 | aprint_normal("async"); | 2190 | scsipi_sync_factor_to_period(periph->periph_period); | |
2191 | 2191 | aprint_normal("sync (%d.%02dns offset %d)", | ||
2192 | if (periph->periph_mode & PERIPH_CAP_WIDE32) | 2192 | period / 100, period % 100, periph->periph_offset); | |
2193 | aprint_normal(", 32-bit"); | 2193 | } else | |
2194 | else if (periph->periph_mode & (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT)) | 2194 | aprint_normal("async"); | |
2195 | aprint_normal(", 16-bit"); | |||
2196 | else | |||
2197 | aprint_normal(", 8-bit"); | |||
2198 | 2195 | |||
2199 | if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) { | |||
2200 | freq = scsipi_sync_factor_to_freq(periph->periph_period); | |||
2201 | speed = freq; | |||
2202 | if (periph->periph_mode & PERIPH_CAP_WIDE32) | 2196 | if (periph->periph_mode & PERIPH_CAP_WIDE32) | |
2203 | speed *= 4; | 2197 | aprint_normal(", 32-bit"); | |
2204 | else if (periph->periph_mode & | 2198 | else if ( | |
2205 | (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT)) | 2199 | periph->periph_mode & (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT)) | |
2206 | speed *= 2; | 2200 | aprint_normal(", 16-bit"); | |
2207 | mbs = speed / 1000; | |||
2208 | if (mbs > 0) | |||
2209 | aprint_normal(" (%d.%03dMB/s)", mbs, speed % 1000); | |||
2210 | else | 2201 | else | |
2211 | aprint_normal(" (%dKB/s)", speed % 1000); | 2202 | aprint_normal(", 8-bit"); | |
2212 | } | 2203 | ||
2204 | if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) { | |||
2205 | freq = | |||
2206 | scsipi_sync_factor_to_freq(periph->periph_period); | |||
2207 | speed = freq; | |||
2208 | if (periph->periph_mode & PERIPH_CAP_WIDE32) | |||
2209 | speed *= 4; | |||
2210 | else if (periph->periph_mode & | |||
2211 | (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT)) | |||
2212 | speed *= 2; | |||
2213 | mbs = speed / 1000; | |||
2214 | if (mbs > 0) { | |||
2215 | aprint_normal(" (%d.%03dMB/s)", mbs, | |||
2216 | speed % 1000); | |||
2217 | } else | |||
2218 | aprint_normal(" (%dKB/s)", speed % 1000); | |||
2219 | } | |||
2213 | 2220 | |||
2214 | aprint_normal(" transfers"); | 2221 | aprint_normal(" transfers"); | |
2215 | 2222 | |||
2216 | if (periph->periph_mode & PERIPH_CAP_TQING) | 2223 | if (periph->periph_mode & PERIPH_CAP_TQING) | |
2217 | aprint_normal(", tagged queueing"); | 2224 | aprint_normal(", tagged queueing"); | |
2218 | 2225 | |||
2219 | aprint_normal("\n"); | 2226 | aprint_normal("\n"); | |
2227 | break; | |||
2228 | case SCSIPI_BUSTYPE_BUSTYPE( | |||
2229 | SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC): | |||
2230 | case SCSIPI_BUSTYPE_BUSTYPE( | |||
2231 | SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS): | |||
2232 | if (periph->periph_mode & PERIPH_CAP_TQING) { | |||
2233 | aprint_normal_dev(periph->periph_dev, | |||
2234 | "tagged queueing\n"); | |||
2235 | } | |||
2236 | break; | |||
2237 | default: | |||
2238 | /* nothing */ | |||
2239 | break; | |||
2240 | } | |||
2220 | } | 2241 | } | |
2221 | 2242 | |||
2222 | /* | 2243 | /* | |
2223 | * scsipi_async_event_max_openings: | 2244 | * scsipi_async_event_max_openings: | |
2224 | * | 2245 | * | |
2225 | * Update the maximum number of outstanding commands a | 2246 | * Update the maximum number of outstanding commands a | |
2226 | * device may have. | 2247 | * device may have. | |
2227 | */ | 2248 | */ | |
2228 | static void | 2249 | static void | |
2229 | scsipi_async_event_max_openings(struct scsipi_channel *chan, | 2250 | scsipi_async_event_max_openings(struct scsipi_channel *chan, | |
2230 | struct scsipi_max_openings *mo) | 2251 | struct scsipi_max_openings *mo) | |
2231 | { | 2252 | { | |
2232 | struct scsipi_periph *periph; | 2253 | struct scsipi_periph *periph; |
--- src/sys/dev/scsipi/scsipi_ioctl.c 2008/07/14 12:36:44 1.66
+++ src/sys/dev/scsipi/scsipi_ioctl.c 2012/04/19 17:45:20 1.67
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $ */ | 1 | /* $NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Contributed by HD Associates (hd@world.std.com). | 33 | * Contributed by HD Associates (hd@world.std.com). | |
34 | * Copyright (c) 1992, 1993 HD Associates | 34 | * Copyright (c) 1992, 1993 HD Associates | |
35 | * | 35 | * | |
36 | * Berkeley style copyright. | 36 | * Berkeley style copyright. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $"); | |
41 | 41 | |||
42 | #include "opt_compat_freebsd.h" | 42 | #include "opt_compat_freebsd.h" | |
43 | #include "opt_compat_netbsd.h" | 43 | #include "opt_compat_netbsd.h" | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/errno.h> | 46 | #include <sys/errno.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/malloc.h> | 48 | #include <sys/malloc.h> | |
49 | #include <sys/buf.h> | 49 | #include <sys/buf.h> | |
50 | #include <sys/proc.h> | 50 | #include <sys/proc.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | #include <sys/fcntl.h> | 52 | #include <sys/fcntl.h> | |
53 | 53 | |||
@@ -369,49 +369,49 @@ scsipi_do_ioctl(struct scsipi_periph *pe | @@ -369,49 +369,49 @@ scsipi_do_ioctl(struct scsipi_periph *pe | |||
369 | periph->periph_dbflags |= SCSIPI_DB2; | 369 | periph->periph_dbflags |= SCSIPI_DB2; | |
370 | if (level & 4) | 370 | if (level & 4) | |
371 | periph->periph_dbflags |= SCSIPI_DB3; | 371 | periph->periph_dbflags |= SCSIPI_DB3; | |
372 | if (level & 8) | 372 | if (level & 8) | |
373 | periph->periph_dbflags |= SCSIPI_DB4; | 373 | periph->periph_dbflags |= SCSIPI_DB4; | |
374 | return (0); | 374 | return (0); | |
375 | } | 375 | } | |
376 | case SCIOCRECONFIG: | 376 | case SCIOCRECONFIG: | |
377 | case SCIOCDECONFIG: | 377 | case SCIOCDECONFIG: | |
378 | return (EINVAL); | 378 | return (EINVAL); | |
379 | case SCIOCIDENTIFY: { | 379 | case SCIOCIDENTIFY: { | |
380 | struct scsi_addr *sca = (struct scsi_addr *)addr; | 380 | struct scsi_addr *sca = (struct scsi_addr *)addr; | |
381 | 381 | |||
382 | switch (scsipi_periph_bustype(periph)) { | 382 | switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) { | |
383 | case SCSIPI_BUSTYPE_SCSI: | 383 | case SCSIPI_BUSTYPE_SCSI: | |
384 | sca->type = TYPE_SCSI; | 384 | sca->type = TYPE_SCSI; | |
385 | sca->addr.scsi.scbus = | 385 | sca->addr.scsi.scbus = | |
386 | device_unit(device_parent(periph->periph_dev)); | 386 | device_unit(device_parent(periph->periph_dev)); | |
387 | sca->addr.scsi.target = periph->periph_target; | 387 | sca->addr.scsi.target = periph->periph_target; | |
388 | sca->addr.scsi.lun = periph->periph_lun; | 388 | sca->addr.scsi.lun = periph->periph_lun; | |
389 | return (0); | 389 | return (0); | |
390 | case SCSIPI_BUSTYPE_ATAPI: | 390 | case SCSIPI_BUSTYPE_ATAPI: | |
391 | sca->type = TYPE_ATAPI; | 391 | sca->type = TYPE_ATAPI; | |
392 | sca->addr.atapi.atbus = | 392 | sca->addr.atapi.atbus = | |
393 | device_unit(device_parent(periph->periph_dev)); | 393 | device_unit(device_parent(periph->periph_dev)); | |
394 | sca->addr.atapi.drive = periph->periph_target; | 394 | sca->addr.atapi.drive = periph->periph_target; | |
395 | return (0); | 395 | return (0); | |
396 | } | 396 | } | |
397 | return (ENXIO); | 397 | return (ENXIO); | |
398 | } | 398 | } | |
399 | #if defined(COMPAT_12) || defined(COMPAT_FREEBSD) | 399 | #if defined(COMPAT_12) || defined(COMPAT_FREEBSD) | |
400 | /* SCIOCIDENTIFY before ATAPI staff merge */ | 400 | /* SCIOCIDENTIFY before ATAPI staff merge */ | |
401 | case OSCIOCIDENTIFY: { | 401 | case OSCIOCIDENTIFY: { | |
402 | struct oscsi_addr *sca = (struct oscsi_addr *)addr; | 402 | struct oscsi_addr *sca = (struct oscsi_addr *)addr; | |
403 | 403 | |||
404 | switch (scsipi_periph_bustype(periph)) { | 404 | switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) { | |
405 | case SCSIPI_BUSTYPE_SCSI: | 405 | case SCSIPI_BUSTYPE_SCSI: | |
406 | sca->scbus = | 406 | sca->scbus = | |
407 | device_unit(device_parent(periph->periph_dev)); | 407 | device_unit(device_parent(periph->periph_dev)); | |
408 | sca->target = periph->periph_target; | 408 | sca->target = periph->periph_target; | |
409 | sca->lun = periph->periph_lun; | 409 | sca->lun = periph->periph_lun; | |
410 | return (0); | 410 | return (0); | |
411 | } | 411 | } | |
412 | return (ENODEV); | 412 | return (ENODEV); | |
413 | } | 413 | } | |
414 | #endif | 414 | #endif | |
415 | default: | 415 | default: | |
416 | return (ENOTTY); | 416 | return (ENOTTY); | |
417 | } | 417 | } |
--- src/sys/dev/scsipi/scsipiconf.h 2012/04/06 22:50:39 1.119
+++ src/sys/dev/scsipi/scsipiconf.h 2012/04/19 17:45:20 1.120
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: scsipiconf.h,v 1.119 2012/04/06 22:50:39 christos Exp $ */ | 1 | /* $NetBSD: scsipiconf.h,v 1.120 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum; by Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility, NASA Ames Research Center. | 9 | * Simulation Facility, NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -229,30 +229,45 @@ struct scsipi_adapter { | @@ -229,30 +229,45 @@ struct scsipi_adapter { | |||
229 | * The bustype_type member is shared with struct ata_bustype | 229 | * The bustype_type member is shared with struct ata_bustype | |
230 | * (because we can ata, atapi or scsi busses to the same controller) | 230 | * (because we can ata, atapi or scsi busses to the same controller) | |
231 | */ | 231 | */ | |
232 | struct scsipi_bustype { | 232 | struct scsipi_bustype { | |
233 | int bustype_type; /* symbolic name of type */ | 233 | int bustype_type; /* symbolic name of type */ | |
234 | 234 | |||
235 | void (*bustype_cmd)(struct scsipi_xfer *); | 235 | void (*bustype_cmd)(struct scsipi_xfer *); | |
236 | int (*bustype_interpret_sense)(struct scsipi_xfer *); | 236 | int (*bustype_interpret_sense)(struct scsipi_xfer *); | |
237 | void (*bustype_printaddr)(struct scsipi_periph *); | 237 | void (*bustype_printaddr)(struct scsipi_periph *); | |
238 | void (*bustype_kill_pending)(struct scsipi_periph *); | 238 | void (*bustype_kill_pending)(struct scsipi_periph *); | |
239 | }; | 239 | }; | |
240 | 240 | |||
241 | /* bustype_type */ | 241 | /* bustype_type */ | |
242 | #define SCSIPI_BUSTYPE_SCSI 0 | 242 | /* type is stored in the first byte */ | |
243 | #define SCSIPI_BUSTYPE_TYPE_SHIFT 0 | |||
244 | #define SCSIPI_BUSTYPE_TYPE(x) (((x) >> SCSIPI_BUSTYPE_TYPE_SHIFT) & 0xff) | |||
245 | #define SCSIPI_BUSTYPE_SCSI 0 /* parallel SCSI */ | |||
243 | #define SCSIPI_BUSTYPE_ATAPI 1 | 246 | #define SCSIPI_BUSTYPE_ATAPI 1 | |
244 | /* #define SCSIPI_BUSTYPE_ATA 2 */ | 247 | /* #define SCSIPI_BUSTYPE_ATA 2 */ | |
245 | 248 | /* subtype is stored in the second byte */ | ||
249 | #define SCSIPI_BUSTYPE_SUBTYPE_SHIFT 8 | |||
250 | #define SCSIPI_BUSTYPE_SUBTYPE(x) (((x) >> SCSIPI_BUSTYPE_SUBTYPE_SHIFT) & 0xff) | |||
251 | ||||
252 | #define SCSIPI_BUSTYPE_BUSTYPE(t, s) \ | |||
253 | ((t) << SCSIPI_BUSTYPE_TYPE_SHIFT | (s) << SCSIPI_BUSTYPE_SUBTYPE_SHIFT) | |||
254 | /* subtypes are defined in each bus type headers */ | |||
255 | /* XXX this should be in scsiconf.h but is used in scsipi_base.c */ | |||
256 | /* SCSI subtypes */ | |||
257 | #define SCSIPI_BUSTYPE_SCSI_PSCSI 0 /* parallel SCSI */ | |||
258 | #define SCSIPI_BUSTYPE_SCSI_FC 1 /* Fiber channel */ | |||
259 | #define SCSIPI_BUSTYPE_SCSI_SAS 2 /* SAS */ | |||
260 | #define SCSIPI_BUSTYPE_SCSI_USB 3 /* USB */ | |||
246 | 261 | |||
247 | /* | 262 | /* | |
248 | * scsipi_channel: | 263 | * scsipi_channel: | |
249 | * | 264 | * | |
250 | * This structure describes a single channel of a SCSIPI adapter. | 265 | * This structure describes a single channel of a SCSIPI adapter. | |
251 | * An adapter may have one or more channels. See the comment above | 266 | * An adapter may have one or more channels. See the comment above | |
252 | * regarding the resource counter. | 267 | * regarding the resource counter. | |
253 | * Note: chan_bustype has to be first member, as its bustype_type member | 268 | * Note: chan_bustype has to be first member, as its bustype_type member | |
254 | * is shared with the aa_bustype member of struct ata_atapi_attach. | 269 | * is shared with the aa_bustype member of struct ata_atapi_attach. | |
255 | */ | 270 | */ | |
256 | 271 | |||
257 | #define SCSIPI_CHAN_PERIPH_BUCKETS 16 | 272 | #define SCSIPI_CHAN_PERIPH_BUCKETS 16 | |
258 | #define SCSIPI_CHAN_PERIPH_HASHMASK (SCSIPI_CHAN_PERIPH_BUCKETS - 1) | 273 | #define SCSIPI_CHAN_PERIPH_HASHMASK (SCSIPI_CHAN_PERIPH_BUCKETS - 1) |
--- src/sys/dev/scsipi/sd.c 2012/04/06 22:50:39 1.297
+++ src/sys/dev/scsipi/sd.c 2012/04/19 17:45:20 1.298
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sd.c,v 1.297 2012/04/06 22:50:39 christos Exp $ */ | 1 | /* $NetBSD: sd.c,v 1.298 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -37,27 +37,27 @@ | @@ -37,27 +37,27 @@ | |||
37 | * Mellon University, makes this software available to CMU to distribute | 37 | * Mellon University, makes this software available to CMU to distribute | |
38 | * or use in any manner that they see fit as long as this message is kept with | 38 | * or use in any manner that they see fit as long as this message is kept with | |
39 | * the software. For this reason TFS also grants any other persons or | 39 | * the software. For this reason TFS also grants any other persons or | |
40 | * organisations permission to use or modify this software. | 40 | * organisations permission to use or modify this software. | |
41 | * | 41 | * | |
42 | * TFS supplies this software to be publicly redistributed | 42 | * TFS supplies this software to be publicly redistributed | |
43 | * on the understanding that TFS is not responsible for the correct | 43 | * on the understanding that TFS is not responsible for the correct | |
44 | * functioning of this software in any circumstances. | 44 | * functioning of this software in any circumstances. | |
45 | * | 45 | * | |
46 | * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 | 46 | * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 | |
47 | */ | 47 | */ | |
48 | 48 | |||
49 | #include <sys/cdefs.h> | 49 | #include <sys/cdefs.h> | |
50 | __KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.297 2012/04/06 22:50:39 christos Exp $"); | 50 | __KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.298 2012/04/19 17:45:20 bouyer Exp $"); | |
51 | 51 | |||
52 | #include "opt_scsi.h" | 52 | #include "opt_scsi.h" | |
53 | 53 | |||
54 | #include <sys/param.h> | 54 | #include <sys/param.h> | |
55 | #include <sys/systm.h> | 55 | #include <sys/systm.h> | |
56 | #include <sys/kernel.h> | 56 | #include <sys/kernel.h> | |
57 | #include <sys/file.h> | 57 | #include <sys/file.h> | |
58 | #include <sys/stat.h> | 58 | #include <sys/stat.h> | |
59 | #include <sys/ioctl.h> | 59 | #include <sys/ioctl.h> | |
60 | #include <sys/scsiio.h> | 60 | #include <sys/scsiio.h> | |
61 | #include <sys/buf.h> | 61 | #include <sys/buf.h> | |
62 | #include <sys/bufq.h> | 62 | #include <sys/bufq.h> | |
63 | #include <sys/uio.h> | 63 | #include <sys/uio.h> | |
@@ -217,28 +217,28 @@ sdattach(device_t parent, device_t self, | @@ -217,28 +217,28 @@ sdattach(device_t parent, device_t self, | |||
217 | struct scsipi_periph *periph = sa->sa_periph; | 217 | struct scsipi_periph *periph = sa->sa_periph; | |
218 | int error, result, rndval = cprng_strong32(); | 218 | int error, result, rndval = cprng_strong32(); | |
219 | struct disk_parms *dp = &sd->params; | 219 | struct disk_parms *dp = &sd->params; | |
220 | char pbuf[9]; | 220 | char pbuf[9]; | |
221 | 221 | |||
222 | SC_DEBUG(periph, SCSIPI_DB2, ("sdattach: ")); | 222 | SC_DEBUG(periph, SCSIPI_DB2, ("sdattach: ")); | |
223 | 223 | |||
224 | sd->sc_dev = self; | 224 | sd->sc_dev = self; | |
225 | sd->type = (sa->sa_inqbuf.type & SID_TYPE); | 225 | sd->type = (sa->sa_inqbuf.type & SID_TYPE); | |
226 | strncpy(sd->name, sa->sa_inqbuf.product, sizeof(sd->name)); | 226 | strncpy(sd->name, sa->sa_inqbuf.product, sizeof(sd->name)); | |
227 | if (sd->type == T_SIMPLE_DIRECT) | 227 | if (sd->type == T_SIMPLE_DIRECT) | |
228 | periph->periph_quirks |= PQUIRK_ONLYBIG | PQUIRK_NOBIGMODESENSE; | 228 | periph->periph_quirks |= PQUIRK_ONLYBIG | PQUIRK_NOBIGMODESENSE; | |
229 | 229 | |||
230 | if (scsipi_periph_bustype(sa->sa_periph) == SCSIPI_BUSTYPE_SCSI && | 230 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) == | |
231 | periph->periph_version == 0) | 231 | SCSIPI_BUSTYPE_SCSI && periph->periph_version == 0) | |
232 | sd->flags |= SDF_ANCIENT; | 232 | sd->flags |= SDF_ANCIENT; | |
233 | 233 | |||
234 | bufq_alloc(&sd->buf_queue, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK); | 234 | bufq_alloc(&sd->buf_queue, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK); | |
235 | 235 | |||
236 | callout_init(&sd->sc_callout, 0); | 236 | callout_init(&sd->sc_callout, 0); | |
237 | 237 | |||
238 | /* | 238 | /* | |
239 | * Store information needed to contact our base driver | 239 | * Store information needed to contact our base driver | |
240 | */ | 240 | */ | |
241 | sd->sc_periph = periph; | 241 | sd->sc_periph = periph; | |
242 | 242 | |||
243 | periph->periph_dev = sd->sc_dev; | 243 | periph->periph_dev = sd->sc_dev; | |
244 | periph->periph_switch = &sd_switch; | 244 | periph->periph_switch = &sd_switch; | |
@@ -1294,27 +1294,27 @@ sdioctl(dev_t dev, u_long cmd, void *add | @@ -1294,27 +1294,27 @@ sdioctl(dev_t dev, u_long cmd, void *add | |||
1294 | 1294 | |||
1295 | static void | 1295 | static void | |
1296 | sdgetdefaultlabel(struct sd_softc *sd, struct disklabel *lp) | 1296 | sdgetdefaultlabel(struct sd_softc *sd, struct disklabel *lp) | |
1297 | { | 1297 | { | |
1298 | 1298 | |||
1299 | memset(lp, 0, sizeof(struct disklabel)); | 1299 | memset(lp, 0, sizeof(struct disklabel)); | |
1300 | 1300 | |||
1301 | lp->d_secsize = sd->params.blksize; | 1301 | lp->d_secsize = sd->params.blksize; | |
1302 | lp->d_ntracks = sd->params.heads; | 1302 | lp->d_ntracks = sd->params.heads; | |
1303 | lp->d_nsectors = sd->params.sectors; | 1303 | lp->d_nsectors = sd->params.sectors; | |
1304 | lp->d_ncylinders = sd->params.cyls; | 1304 | lp->d_ncylinders = sd->params.cyls; | |
1305 | lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; | 1305 | lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; | |
1306 | 1306 | |||
1307 | switch (scsipi_periph_bustype(sd->sc_periph)) { | 1307 | switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sd->sc_periph))) { | |
1308 | case SCSIPI_BUSTYPE_SCSI: | 1308 | case SCSIPI_BUSTYPE_SCSI: | |
1309 | lp->d_type = DTYPE_SCSI; | 1309 | lp->d_type = DTYPE_SCSI; | |
1310 | break; | 1310 | break; | |
1311 | case SCSIPI_BUSTYPE_ATAPI: | 1311 | case SCSIPI_BUSTYPE_ATAPI: | |
1312 | lp->d_type = DTYPE_ATAPI; | 1312 | lp->d_type = DTYPE_ATAPI; | |
1313 | break; | 1313 | break; | |
1314 | } | 1314 | } | |
1315 | /* | 1315 | /* | |
1316 | * XXX | 1316 | * XXX | |
1317 | * We could probe the mode pages to figure out what kind of disc it is. | 1317 | * We could probe the mode pages to figure out what kind of disc it is. | |
1318 | * Is this worthwhile? | 1318 | * Is this worthwhile? | |
1319 | */ | 1319 | */ | |
1320 | strncpy(lp->d_typename, sd->name, 16); | 1320 | strncpy(lp->d_typename, sd->name, 16); |
--- src/sys/dev/scsipi/st.c 2012/02/28 10:58:10 1.220
+++ src/sys/dev/scsipi/st.c 2012/04/19 17:45:20 1.221
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $ */ | 1 | /* $NetBSD: st.c,v 1.221 2012/04/19 17:45:20 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | * organisations permission to use or modify this software. | 40 | * organisations permission to use or modify this software. | |
41 | * | 41 | * | |
42 | * TFS supplies this software to be publicly redistributed | 42 | * TFS supplies this software to be publicly redistributed | |
43 | * on the understanding that TFS is not responsible for the correct | 43 | * on the understanding that TFS is not responsible for the correct | |
44 | * functioning of this software in any circumstances. | 44 | * functioning of this software in any circumstances. | |
45 | * | 45 | * | |
46 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | 46 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | |
47 | * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 | 47 | * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 | |
48 | * | 48 | * | |
49 | * A lot of rewhacking done by mjacob (mjacob@nas.nasa.gov). | 49 | * A lot of rewhacking done by mjacob (mjacob@nas.nasa.gov). | |
50 | */ | 50 | */ | |
51 | 51 | |||
52 | #include <sys/cdefs.h> | 52 | #include <sys/cdefs.h> | |
53 | __KERNEL_RCSID(0, "$NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $"); | 53 | __KERNEL_RCSID(0, "$NetBSD: st.c,v 1.221 2012/04/19 17:45:20 bouyer Exp $"); | |
54 | 54 | |||
55 | #include "opt_scsi.h" | 55 | #include "opt_scsi.h" | |
56 | 56 | |||
57 | #include <sys/param.h> | 57 | #include <sys/param.h> | |
58 | #include <sys/systm.h> | 58 | #include <sys/systm.h> | |
59 | #include <sys/fcntl.h> | 59 | #include <sys/fcntl.h> | |
60 | #include <sys/errno.h> | 60 | #include <sys/errno.h> | |
61 | #include <sys/ioctl.h> | 61 | #include <sys/ioctl.h> | |
62 | #include <sys/malloc.h> | 62 | #include <sys/malloc.h> | |
63 | #include <sys/buf.h> | 63 | #include <sys/buf.h> | |
64 | #include <sys/bufq.h> | 64 | #include <sys/bufq.h> | |
65 | #include <sys/proc.h> | 65 | #include <sys/proc.h> | |
66 | #include <sys/mtio.h> | 66 | #include <sys/mtio.h> | |
@@ -1725,27 +1725,28 @@ st_write_filemarks(struct st_softc *st, | @@ -1725,27 +1725,28 @@ st_write_filemarks(struct st_softc *st, | |||
1725 | case 1: | 1725 | case 1: | |
1726 | if (st->flags & ST_FM_WRITTEN) /* already have one down */ | 1726 | if (st->flags & ST_FM_WRITTEN) /* already have one down */ | |
1727 | st->flags &= ~ST_WRITTEN; | 1727 | st->flags &= ~ST_WRITTEN; | |
1728 | else | 1728 | else | |
1729 | st->flags |= ST_FM_WRITTEN; | 1729 | st->flags |= ST_FM_WRITTEN; | |
1730 | st->flags &= ~ST_PER_ACTION; | 1730 | st->flags &= ~ST_PER_ACTION; | |
1731 | break; | 1731 | break; | |
1732 | default: | 1732 | default: | |
1733 | st->flags &= ~(ST_PER_ACTION | ST_WRITTEN); | 1733 | st->flags &= ~(ST_PER_ACTION | ST_WRITTEN); | |
1734 | } | 1734 | } | |
1735 | 1735 | |||
1736 | memset(&cmd, 0, sizeof(cmd)); | 1736 | memset(&cmd, 0, sizeof(cmd)); | |
1737 | cmd.opcode = WRITE_FILEMARKS; | 1737 | cmd.opcode = WRITE_FILEMARKS; | |
1738 | if (scsipi_periph_bustype(st->sc_periph) == SCSIPI_BUSTYPE_ATAPI) | 1738 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(st->sc_periph)) == | |
1739 | SCSIPI_BUSTYPE_ATAPI) | |||
1739 | cmd.byte2 = SR_IMMED; | 1740 | cmd.byte2 = SR_IMMED; | |
1740 | /* | 1741 | /* | |
1741 | * The ATAPI Onstream DI-30 doesn't support writing filemarks, but | 1742 | * The ATAPI Onstream DI-30 doesn't support writing filemarks, but | |
1742 | * WRITE_FILEMARKS is still used to flush the buffer | 1743 | * WRITE_FILEMARKS is still used to flush the buffer | |
1743 | */ | 1744 | */ | |
1744 | if ((st->quirks & ST_Q_NOFILEMARKS) == 0) | 1745 | if ((st->quirks & ST_Q_NOFILEMARKS) == 0) | |
1745 | _lto3b(number, cmd.number); | 1746 | _lto3b(number, cmd.number); | |
1746 | 1747 | |||
1747 | /* XXX WE NEED TO BE ABLE TO GET A RESIDIUAL XXX */ | 1748 | /* XXX WE NEED TO BE ABLE TO GET A RESIDIUAL XXX */ | |
1748 | error = scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0, 0, | 1749 | error = scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0, 0, | |
1749 | 0, ST_IO_TIME * 4, NULL, flags); | 1750 | 0, ST_IO_TIME * 4, NULL, flags); | |
1750 | if (error == 0 && st->fileno != -1) | 1751 | if (error == 0 && st->fileno != -1) | |
1751 | st->fileno += number; | 1752 | st->fileno += number; | |
@@ -1801,27 +1802,28 @@ st_load(struct st_softc *st, u_int type, | @@ -1801,27 +1802,28 @@ st_load(struct st_softc *st, u_int type, | |||
1801 | } | 1802 | } | |
1802 | } | 1803 | } | |
1803 | if (st->quirks & ST_Q_IGNORE_LOADS) { | 1804 | if (st->quirks & ST_Q_IGNORE_LOADS) { | |
1804 | if (type == LD_LOAD) | 1805 | if (type == LD_LOAD) | |
1805 | /* | 1806 | /* | |
1806 | * If we ignore loads, at least we should try a rewind. | 1807 | * If we ignore loads, at least we should try a rewind. | |
1807 | */ | 1808 | */ | |
1808 | return st_rewind(st, 0, flags); | 1809 | return st_rewind(st, 0, flags); | |
1809 | /* otherwise, we should do what's asked of us */ | 1810 | /* otherwise, we should do what's asked of us */ | |
1810 | } | 1811 | } | |
1811 | 1812 | |||
1812 | memset(&cmd, 0, sizeof(cmd)); | 1813 | memset(&cmd, 0, sizeof(cmd)); | |
1813 | cmd.opcode = LOAD; | 1814 | cmd.opcode = LOAD; | |
1814 | if (scsipi_periph_bustype(st->sc_periph) == SCSIPI_BUSTYPE_ATAPI) | 1815 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(st->sc_periph)) == | |
1816 | SCSIPI_BUSTYPE_ATAPI) | |||
1815 | cmd.byte2 = SR_IMMED; | 1817 | cmd.byte2 = SR_IMMED; | |
1816 | cmd.how = type; | 1818 | cmd.how = type; | |
1817 | 1819 | |||
1818 | error = scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0, 0, | 1820 | error = scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0, 0, | |
1819 | ST_RETRIES, ST_SPC_TIME, NULL, flags); | 1821 | ST_RETRIES, ST_SPC_TIME, NULL, flags); | |
1820 | if (error) { | 1822 | if (error) { | |
1821 | aprint_error_dev(st->sc_dev, "error %d in st_load (op %d)\n", | 1823 | aprint_error_dev(st->sc_dev, "error %d in st_load (op %d)\n", | |
1822 | error, type); | 1824 | error, type); | |
1823 | } | 1825 | } | |
1824 | return error; | 1826 | return error; | |
1825 | } | 1827 | } | |
1826 | 1828 | |||
1827 | /* Rewind the device */ | 1829 | /* Rewind the device */ |
--- src/sys/dev/scsipi/st_atapi.c 2012/02/28 10:58:11 1.28
+++ src/sys/dev/scsipi/st_atapi.c 2012/04/19 17:45:21 1.29
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: st_atapi.c,v 1.28 2012/02/28 10:58:11 mbalmer Exp $ */ | 1 | /* $NetBSD: st_atapi.c,v 1.29 2012/04/19 17:45:21 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 Manuel Bouyer. | 4 | * Copyright (c) 2001 Manuel Bouyer. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.28 2012/02/28 10:58:11 mbalmer Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.29 2012/04/19 17:45:21 bouyer Exp $"); | |
29 | 29 | |||
30 | #include "opt_scsi.h" | 30 | #include "opt_scsi.h" | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/device.h> | 33 | #include <sys/device.h> | |
34 | #include <sys/buf.h> | 34 | #include <sys/buf.h> | |
35 | #include <sys/bufq.h> | 35 | #include <sys/bufq.h> | |
36 | #include <sys/conf.h> | 36 | #include <sys/conf.h> | |
37 | #include <sys/kernel.h> | 37 | #include <sys/kernel.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | 39 | |||
40 | #include <dev/scsipi/stvar.h> | 40 | #include <dev/scsipi/stvar.h> | |
41 | #include <dev/scsipi/atapi_tape.h> | 41 | #include <dev/scsipi/atapi_tape.h> | |
@@ -55,27 +55,28 @@ CFATTACH_DECL_NEW( | @@ -55,27 +55,28 @@ CFATTACH_DECL_NEW( | |||
55 | ); | 55 | ); | |
56 | 56 | |||
57 | static const struct scsipi_inquiry_pattern st_atapibus_patterns[] = { | 57 | static const struct scsipi_inquiry_pattern st_atapibus_patterns[] = { | |
58 | {T_SEQUENTIAL, T_REMOV, | 58 | {T_SEQUENTIAL, T_REMOV, | |
59 | "", "", ""}, | 59 | "", "", ""}, | |
60 | }; | 60 | }; | |
61 | 61 | |||
62 | static int | 62 | static int | |
63 | st_atapibus_match(device_t parent, cfdata_t match, void *aux) | 63 | st_atapibus_match(device_t parent, cfdata_t match, void *aux) | |
64 | { | 64 | { | |
65 | struct scsipibus_attach_args *sa = aux; | 65 | struct scsipibus_attach_args *sa = aux; | |
66 | int priority; | 66 | int priority; | |
67 | 67 | |||
68 | if (scsipi_periph_bustype(sa->sa_periph) != SCSIPI_BUSTYPE_ATAPI) | 68 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) != | |
69 | SCSIPI_BUSTYPE_ATAPI) | |||
69 | return 0; | 70 | return 0; | |
70 | 71 | |||
71 | (void)scsipi_inqmatch(&sa->sa_inqbuf, | 72 | (void)scsipi_inqmatch(&sa->sa_inqbuf, | |
72 | st_atapibus_patterns, | 73 | st_atapibus_patterns, | |
73 | sizeof(st_atapibus_patterns)/sizeof(st_atapibus_patterns[0]), | 74 | sizeof(st_atapibus_patterns)/sizeof(st_atapibus_patterns[0]), | |
74 | sizeof(st_atapibus_patterns[0]), &priority); | 75 | sizeof(st_atapibus_patterns[0]), &priority); | |
75 | return priority; | 76 | return priority; | |
76 | } | 77 | } | |
77 | 78 | |||
78 | static void | 79 | static void | |
79 | st_atapibus_attach(device_t parent, device_t self, void *aux) | 80 | st_atapibus_attach(device_t parent, device_t self, void *aux) | |
80 | { | 81 | { | |
81 | struct st_softc *st = device_private(self); | 82 | struct st_softc *st = device_private(self); |
--- src/sys/dev/scsipi/st_scsi.c 2012/02/28 10:58:11 1.34
+++ src/sys/dev/scsipi/st_scsi.c 2012/04/19 17:45:21 1.35
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: st_scsi.c,v 1.34 2012/02/28 10:58:11 mbalmer Exp $ */ | 1 | /* $NetBSD: st_scsi.c,v 1.35 2012/04/19 17:45:21 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Charles M. Hannum. | 8 | * by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | * organisations permission to use or modify this software. | 40 | * organisations permission to use or modify this software. | |
41 | * | 41 | * | |
42 | * TFS supplies this software to be publicly redistributed | 42 | * TFS supplies this software to be publicly redistributed | |
43 | * on the understanding that TFS is not responsible for the correct | 43 | * on the understanding that TFS is not responsible for the correct | |
44 | * functioning of this software in any circumstances. | 44 | * functioning of this software in any circumstances. | |
45 | * | 45 | * | |
46 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | 46 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 | |
47 | * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 | 47 | * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 | |
48 | * | 48 | * | |
49 | * A lot of rewhacking done by mjacob (mjacob@nas.nasa.gov). | 49 | * A lot of rewhacking done by mjacob (mjacob@nas.nasa.gov). | |
50 | */ | 50 | */ | |
51 | 51 | |||
52 | #include <sys/cdefs.h> | 52 | #include <sys/cdefs.h> | |
53 | __KERNEL_RCSID(0, "$NetBSD: st_scsi.c,v 1.34 2012/02/28 10:58:11 mbalmer Exp $"); | 53 | __KERNEL_RCSID(0, "$NetBSD: st_scsi.c,v 1.35 2012/04/19 17:45:21 bouyer Exp $"); | |
54 | 54 | |||
55 | #include "opt_scsi.h" | 55 | #include "opt_scsi.h" | |
56 | 56 | |||
57 | #include <sys/param.h> | 57 | #include <sys/param.h> | |
58 | #include <sys/device.h> | 58 | #include <sys/device.h> | |
59 | #include <sys/buf.h> | 59 | #include <sys/buf.h> | |
60 | #include <sys/bufq.h> | 60 | #include <sys/bufq.h> | |
61 | #include <sys/conf.h> | 61 | #include <sys/conf.h> | |
62 | #include <sys/kernel.h> | 62 | #include <sys/kernel.h> | |
63 | #include <sys/systm.h> | 63 | #include <sys/systm.h> | |
64 | 64 | |||
65 | #include <dev/scsipi/scsi_all.h> | 65 | #include <dev/scsipi/scsi_all.h> | |
66 | #include <dev/scsipi/scsi_tape.h> | 66 | #include <dev/scsipi/scsi_tape.h> | |
@@ -83,27 +83,28 @@ CFATTACH_DECL_NEW( | @@ -83,27 +83,28 @@ CFATTACH_DECL_NEW( | |||
83 | ); | 83 | ); | |
84 | 84 | |||
85 | static const struct scsipi_inquiry_pattern st_scsibus_patterns[] = { | 85 | static const struct scsipi_inquiry_pattern st_scsibus_patterns[] = { | |
86 | {T_SEQUENTIAL, T_REMOV, | 86 | {T_SEQUENTIAL, T_REMOV, | |
87 | "", "", ""}, | 87 | "", "", ""}, | |
88 | }; | 88 | }; | |
89 | 89 | |||
90 | static int | 90 | static int | |
91 | st_scsibus_match(device_t parent, cfdata_t match, void *aux) | 91 | st_scsibus_match(device_t parent, cfdata_t match, void *aux) | |
92 | { | 92 | { | |
93 | struct scsipibus_attach_args *sa = aux; | 93 | struct scsipibus_attach_args *sa = aux; | |
94 | int priority; | 94 | int priority; | |
95 | 95 | |||
96 | if (scsipi_periph_bustype(sa->sa_periph) != SCSIPI_BUSTYPE_SCSI) | 96 | if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) != | |
97 | SCSIPI_BUSTYPE_SCSI) | |||
97 | return 0; | 98 | return 0; | |
98 | 99 | |||
99 | (void)scsipi_inqmatch(&sa->sa_inqbuf, | 100 | (void)scsipi_inqmatch(&sa->sa_inqbuf, | |
100 | st_scsibus_patterns, | 101 | st_scsibus_patterns, | |
101 | sizeof(st_scsibus_patterns)/sizeof(st_scsibus_patterns[0]), | 102 | sizeof(st_scsibus_patterns)/sizeof(st_scsibus_patterns[0]), | |
102 | sizeof(st_scsibus_patterns[0]), &priority); | 103 | sizeof(st_scsibus_patterns[0]), &priority); | |
103 | return priority; | 104 | return priority; | |
104 | } | 105 | } | |
105 | 106 | |||
106 | static void | 107 | static void | |
107 | st_scsibus_attach(device_t parent, device_t self, void *aux) | 108 | st_scsibus_attach(device_t parent, device_t self, void *aux) | |
108 | { | 109 | { | |
109 | struct st_softc *st = device_private(self); | 110 | struct st_softc *st = device_private(self); |
--- src/sys/dev/usb/umass_scsipi.c 2012/03/11 01:06:07 1.43
+++ src/sys/dev/usb/umass_scsipi.c 2012/04/19 17:45:21 1.44
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: umass_scsipi.c,v 1.43 2012/03/11 01:06:07 mrg Exp $ */ | 1 | /* $NetBSD: umass_scsipi.c,v 1.44 2012/04/19 17:45:21 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology, Charles M. Hamnnum and Matthew R. Green. | 9 | * Carlstedt Research & Technology, Charles M. Hamnnum and Matthew R. Green. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.43 2012/03/11 01:06:07 mrg Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.44 2012/04/19 17:45:21 bouyer Exp $"); | |
35 | 35 | |||
36 | #ifdef _KERNEL_OPT | 36 | #ifdef _KERNEL_OPT | |
37 | #include "opt_umass.h" | 37 | #include "opt_umass.h" | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include "atapibus.h" | 40 | #include "atapibus.h" | |
41 | #include "scsibus.h" | 41 | #include "scsibus.h" | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/conf.h> | 46 | #include <sys/conf.h> | |
47 | #include <sys/buf.h> | 47 | #include <sys/buf.h> | |
@@ -235,27 +235,28 @@ umass_scsipi_request(struct scsipi_chann | @@ -235,27 +235,28 @@ umass_scsipi_request(struct scsipi_chann | |||
235 | #if defined(USB_DEBUG) && defined(SCSIPI_DEBUG) | 235 | #if defined(USB_DEBUG) && defined(SCSIPI_DEBUG) | |
236 | if (umassdebug & UDMASS_SCSI) | 236 | if (umassdebug & UDMASS_SCSI) | |
237 | show_scsipi_xs(xs); | 237 | show_scsipi_xs(xs); | |
238 | else if (umassdebug & ~UDMASS_CMD) | 238 | else if (umassdebug & ~UDMASS_CMD) | |
239 | show_scsipi_cmd(xs); | 239 | show_scsipi_cmd(xs); | |
240 | #endif | 240 | #endif | |
241 | 241 | |||
242 | if (sc->sc_dying) { | 242 | if (sc->sc_dying) { | |
243 | xs->error = XS_DRIVER_STUFFUP; | 243 | xs->error = XS_DRIVER_STUFFUP; | |
244 | goto done; | 244 | goto done; | |
245 | } | 245 | } | |
246 | 246 | |||
247 | #ifdef UMASS_DEBUG | 247 | #ifdef UMASS_DEBUG | |
248 | if (chan->chan_bustype->bustype_type == SCSIPI_BUSTYPE_ATAPI ? | 248 | if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) == | |
249 | SCSIPI_BUSTYPE_ATAPI ? | |||
249 | periph->periph_target != UMASS_ATAPI_DRIVE : | 250 | periph->periph_target != UMASS_ATAPI_DRIVE : | |
250 | periph->periph_target == chan->chan_id) { | 251 | periph->periph_target == chan->chan_id) { | |
251 | DPRINTF(UDMASS_SCSI, ("%s: wrong SCSI ID %d\n", | 252 | DPRINTF(UDMASS_SCSI, ("%s: wrong SCSI ID %d\n", | |
252 | device_xname(sc->sc_dev), | 253 | device_xname(sc->sc_dev), | |
253 | periph->periph_target)); | 254 | periph->periph_target)); | |
254 | xs->error = XS_DRIVER_STUFFUP; | 255 | xs->error = XS_DRIVER_STUFFUP; | |
255 | goto done; | 256 | goto done; | |
256 | } | 257 | } | |
257 | #endif | 258 | #endif | |
258 | 259 | |||
259 | cmd = xs->cmd; | 260 | cmd = xs->cmd; | |
260 | cmdlen = xs->cmdlen; | 261 | cmdlen = xs->cmdlen; | |
261 | 262 |