| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: atapiconf.c,v 1.83.14.2 2012/04/23 16:28:30 riz Exp $ */ | | 1 | /* $NetBSD: atapiconf.c,v 1.83.14.3 2012/07/02 21:11:50 jdc 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.83.14.2 2012/04/23 16:28:30 riz Exp $"); | | 28 | __KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.83.14.3 2012/07/02 21:11:50 jdc 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 | |
| @@ -184,46 +184,53 @@ atapibuschilddet(device_t self, device_t | | | @@ -184,46 +184,53 @@ atapibuschilddet(device_t self, device_t |
184 | break; | | 184 | break; |
185 | } | | 185 | } |
186 | | | 186 | |
187 | /* XXXSMP scsipi */ | | 187 | /* XXXSMP scsipi */ |
188 | KERNEL_UNLOCK_ONE(curlwp); | | 188 | KERNEL_UNLOCK_ONE(curlwp); |
189 | } | | 189 | } |
190 | | | 190 | |
191 | static int | | 191 | static int |
192 | atapibusdetach(device_t self, int flags) | | 192 | atapibusdetach(device_t self, int flags) |
193 | { | | 193 | { |
194 | struct atapibus_softc *sc = device_private(self); | | 194 | struct atapibus_softc *sc = device_private(self); |
195 | struct scsipi_channel *chan = sc->sc_channel; | | 195 | struct scsipi_channel *chan = sc->sc_channel; |
196 | struct scsipi_periph *periph; | | 196 | struct scsipi_periph *periph; |
197 | int target, error; | | 197 | int target, error = 0; |
198 | | | 198 | |
199 | /* | | 199 | /* |
200 | * Shut down the channel. | | 200 | * Shut down the channel. |
201 | */ | | 201 | */ |
202 | scsipi_channel_shutdown(chan); | | 202 | scsipi_channel_shutdown(chan); |
203 | | | 203 | |
| | | 204 | /* XXXSMP scsipi */ |
| | | 205 | KERNEL_LOCK(1, curlwp); |
| | | 206 | |
204 | /* | | 207 | /* |
205 | * Now detach all of the periphs. | | 208 | * Now detach all of the periphs. |
206 | */ | | 209 | */ |
207 | for (target = 0; target < chan->chan_ntargets; target++) { | | 210 | for (target = 0; target < chan->chan_ntargets; target++) { |
208 | periph = scsipi_lookup_periph(chan, target, 0); | | 211 | periph = scsipi_lookup_periph(chan, target, 0); |
209 | if (periph == NULL) | | 212 | if (periph == NULL) |
210 | continue; | | 213 | continue; |
211 | error = config_detach(periph->periph_dev, flags); | | 214 | error = config_detach(periph->periph_dev, flags); |
212 | if (error) | | 215 | if (error) |
213 | return (error); | | 216 | goto out; |
214 | KASSERT(scsipi_lookup_periph(chan, target, 0) == NULL); | | 217 | KASSERT(scsipi_lookup_periph(chan, target, 0) == NULL); |
215 | } | | 218 | } |
216 | return (0); | | 219 | |
| | | 220 | out: |
| | | 221 | /* XXXSMP scsipi */ |
| | | 222 | KERNEL_UNLOCK_ONE(curlwp); |
| | | 223 | return error; |
217 | } | | 224 | } |
218 | | | 225 | |
219 | static int | | 226 | static int |
220 | atapi_probe_bus(struct atapibus_softc *sc, int target) | | 227 | atapi_probe_bus(struct atapibus_softc *sc, int target) |
221 | { | | 228 | { |
222 | struct scsipi_channel *chan = sc->sc_channel; | | 229 | struct scsipi_channel *chan = sc->sc_channel; |
223 | int maxtarget, mintarget; | | 230 | int maxtarget, mintarget; |
224 | int error; | | 231 | int error; |
225 | struct atapi_adapter *atapi_adapter; | | 232 | struct atapi_adapter *atapi_adapter; |
226 | | | 233 | |
227 | if (target == -1) { | | 234 | if (target == -1) { |
228 | maxtarget = 1; | | 235 | maxtarget = 1; |
229 | mintarget = 0; | | 236 | mintarget = 0; |