49c49
< __FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_cd.c 164906 2006-12-05 07:45:28Z mjacob $");
---
> __FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_cd.c 168752 2007-04-15 08:49:19Z scottl $");
72a73
> #include <cam/cam_sim.h>
106c107,108
< CD_FLAG_SCTX_INIT = 0x1000
---
> CD_FLAG_SCTX_INIT = 0x1000,
> CD_FLAG_OPEN = 0x2000
293,295d294
<
< static int num_changers;
<
322,323c321,322
< struct callout_handle short_handle;
< struct callout_handle long_handle;
---
> struct callout short_handle;
> struct callout long_handle;
328a328
> static struct mtx changerq_mtx;
329a330
> static int num_changers;
331d331
<
337a338,340
> mtx_init(&changerq_mtx, "cdchangerq", "SCSI CD Changer List", MTX_DEF);
> STAILQ_INIT(&changerq);
>
367d369
< int s;
387,393d388
< * Although the oninvalidate() routines are always called at
< * splsoftcam, we need to be at splbio() here to keep the buffer
< * queue from being modified while we traverse it.
< */
< s = splbio();
<
< /*
399d393
< splx(s);
418d411
< int s;
429d421
< s = splsoftcam();
459,460c451
< untimeout(cdshorttimeout, softc->changer,
< softc->changer->short_handle);
---
> callout_stop(&softc->changer->short_handle);
481,482c472
< untimeout(cdrunchangerqueue, softc->changer,
< softc->changer->long_handle);
---
> callout_stop(&softc->changer->long_handle);
487,488c477
< untimeout(cdshorttimeout, softc->changer,
< softc->changer->short_handle);
---
> callout_stop(&softc->changer->short_handle);
491a481
> mtx_lock(&changerq_mtx);
493a484,485
> num_changers--;
> mtx_unlock(&changerq_mtx);
496d487
< num_changers--;
500d490
< splx(s);
547d536
< int s;
550d538
< s = splsoftcam();
558d545
< splx(s);
575c562,563
< softc = (struct cd_softc *)periph->softc;
---
> if (cam_periph_acquire(periph) != CAM_REQ_CMP)
> return;
576a565
> softc = (struct cd_softc *)periph->softc;
590a580
> cam_periph_release(periph);
603a594
> cam_periph_release(periph);
736a728
> cam_periph_unlock(periph);
750c742
< softc->disk->d_flags = DISKFLAG_NEEDSGIANT;
---
> softc->disk->d_flags = 0;
751a744
> cam_periph_lock(periph);
786,788d778
< if (num_changers == 0)
< STAILQ_INIT(&changerq);
<
792a783
> mtx_lock(&changerq_mtx);
802a794
> mtx_unlock(&changerq_mtx);
908,909d899
< num_changers++;
<
917a908,914
> callout_init_mtx(&nchanger->long_handle,
> periph->sim->mtx, 0);
> callout_init_mtx(&nchanger->short_handle,
> periph->sim->mtx, 0);
>
> mtx_lock(&changerq_mtx);
> num_changers++;
919a917
> mtx_unlock(&changerq_mtx);
981,983c979,983
< /* Lock this peripheral until we are setup */
< /* Can't block */
< cam_periph_lock(periph, PRIBIO);
---
> /*
> * Refcount and block open attempts until we are setup
> * Can't block
> */
> (void)cam_periph_hold(periph, PRIBIO);
999d998
< int s;
1007,1010c1006,1010
< /*
< * Grab splsoftcam and hold it until we lock the peripheral.
< */
< s = splsoftcam();
---
> if (cam_periph_acquire(periph) != CAM_REQ_CMP)
> return(ENXIO);
>
> cam_periph_lock(periph);
>
1012c1012,1013
< splx(s);
---
> cam_periph_unlock(periph);
> cam_periph_release(periph);
1016,1017c1017,1019
< if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) {
< splx(s);
---
> if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) {
> cam_periph_unlock(periph);
> cam_periph_release(periph);
1021c1023,1027
< splx(s);
---
> /* Closes aren't symmetrical with opens, so fix up the refcounting. */
> if (softc->flags & CD_FLAG_OPEN)
> cam_periph_release(periph);
> else
> softc->flags |= CD_FLAG_OPEN;
1023,1025d1028
< if (cam_periph_acquire(periph) != CAM_REQ_CMP)
< return(ENXIO);
<
1032a1036,1037
> CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n"));
> cam_periph_unhold(periph);
1035,1037c1040
< CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n"));
<
< return (error);
---
> return (0);
1045d1047
< int error;
1053,1054c1055,1056
< if ((error = cam_periph_lock(periph, PRIBIO)) != 0)
< return (error);
---
> cam_periph_lock(periph);
> cam_periph_hold(periph, PRIBIO);
1068c1070
< softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC);
---
> softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC|CD_FLAG_OPEN);
1069a1072
> cam_periph_unhold(periph);
1080d1082
< int s;
1082,1083d1083
< s = splsoftcam();
<
1098,1099d1097
<
< splx(s);
1109d1106
< int s;
1111,1112d1107
< s = splsoftcam();
<
1150,1152d1144
<
< splx(s);
<
1161d1152
< int s;
1163,1164d1153
< s = splsoftcam();
<
1183d1171
< splx(s);
1192a1181,1188
> /*
> * We always need to reset the frozen count and clear the
> * active flag.
> */
> changer->devq.qfrozen_cnt--;
> changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
> changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
>
1198,1200c1194,1196
< changer->long_handle =
< timeout(cdrunchangerqueue, changer,
< changer_max_busy_seconds * hz);
---
> callout_reset(&changer->long_handle,
> changer_max_busy_seconds * hz,
> cdrunchangerqueue, changer);
1203d1198
< splx(s);
1208,1215d1202
< * We always need to reset the frozen count and clear the
< * active flag.
< */
< changer->devq.qfrozen_cnt--;
< changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
< changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
<
< /*
1245c1232
< untimeout(cdrunchangerqueue, changer, changer->long_handle);
---
> callout_stop(&changer->long_handle);
1250c1237
< untimeout(cdshorttimeout, changer, changer->short_handle);
---
> callout_stop(&changer->short_handle);
1260,1261d1246
<
< splx(s);
1268d1252
< int s;
1270,1271d1253
< s = splsoftcam();
<
1316,1318c1298,1300
< changer->long_handle =
< timeout(cdrunchangerqueue, changer,
< changer_max_busy_seconds * hz);
---
> callout_reset(&changer->long_handle,
> changer_max_busy_seconds * hz,
> cdrunchangerqueue, changer);
1325,1327c1307,1309
< changer->short_handle =
< timeout(cdshorttimeout, changer,
< changer_min_busy_seconds * hz);
---
> callout_reset(&changer->short_handle,
> changer_min_busy_seconds * hz,
> cdshorttimeout, changer);
1340d1321
< splx(s);
1369d1349
< int s;
1374,1376d1353
<
< s = splsoftcam();
<
1399c1376,1377
< tsleep(&softc->changer, PRIBIO, "cgticb", 0);
---
> msleep(&softc->changer, periph->sim->mtx,
> PRIBIO, "cgticb", 0);
1401d1378
< splx(s);
1417d1393
< int s;
1424a1401
> cam_periph_lock(periph);
1430,1436d1406
< * Mask interrupts so that the pack cannot be invalidated until
< * after we are in the queue. Otherwise, we might not properly
< * clean up one of the buffers.
< */
< s = splbio();
<
< /*
1440c1410
< splx(s);
---
> cam_periph_unlock(periph);
1454c1424
< splx(s);
---
> cam_periph_unlock(periph);
1465,1466d1434
< splx(s);
<
1475a1444
> cam_periph_unlock(periph);
1486d1454
< int s;
1495,1497d1462
< int oldspl;
<
< s = splbio();
1505d1469
< splx(s);
1508d1471
< splx(s);
1532,1536d1494
< /*
< * Block out any asyncronous callbacks
< * while we touch the pending ccb list.
< */
< oldspl = splcam();
1540d1497
< splx(oldspl);
1550d1506
< splx(s);
1604d1559
< int oldspl;
1628,1629d1582
< int s;
<
1632d1584
< s = splbio();
1634d1585
< splx(s);
1657,1661d1607
< /*
< * Block out any asyncronous callbacks
< * while we touch the pending ccb list.
< */
< oldspl = splcam();
1664d1609
< splx(oldspl);
1855c1800
< cam_periph_unlock(periph);
---
> cam_periph_unhold(periph);
1908c1853
< int error, nocopyout;
---
> int nocopyout, error = 0;
1913a1859
> cam_periph_lock(periph);
1921c1867,1871
< error = cam_periph_lock(periph, PRIBIO | PCATCH);
---
> if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) {
> cam_periph_unlock(periph);
> cam_periph_release(periph);
> return (error);
> }
1923,1924d1872
< if (error != 0)
< return(error);
1939,1942d1886
< if (error != 0) {
< cam_periph_unlock(periph);
< return (error);
< }
1943a1888,1894
> /*
> * Drop the lock here so later mallocs can use WAITOK. The periph
> * is essentially locked still with the cam_periph_hold call above.
> */
> cam_periph_unlock(periph);
> if (error != 0)
> return (error);
1958a1910
> cam_periph_lock(periph);
1964a1917
> cam_periph_unlock(periph);
1973c1926,1927
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
1974a1929
> }
2035a1991
> cam_periph_unlock(periph);
2048a2005
> cam_periph_lock(periph);
2054a2012
> cam_periph_unlock(periph);
2063c2021,2022
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
2064a2024
> }
2071a2032
> cam_periph_unlock(periph);
2081,2083d2041
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCPLAYBLOCKS\n"));
<
2087a2046,2050
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCPLAYBLOCKS\n"));
>
>
2090a2054
> cam_periph_unlock(periph);
2099c2063,2064
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
2100a2066
> }
2101a2068
> cam_periph_unlock(periph);
2114,2116d2080
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCREADSUBCHANNEL\n"));
<
2119a2084,2087
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCREADSUBCHANNEL\n"));
>
2127a2096
> cam_periph_unlock(periph);
2138a2108
> cam_periph_unlock(periph);
2146a2117
> cam_periph_unlock(periph);
2161a2133,2136
> th = malloc(sizeof(struct ioc_toc_header), M_TEMP,
> M_WAITOK);
>
> cam_periph_lock(periph);
2165,2166d2139
< th = malloc(sizeof(struct ioc_toc_header), M_TEMP,
< M_WAITOK);
2170a2144
> cam_periph_unlock(periph);
2183a2158
> cam_periph_unlock(periph);
2196,2198d2170
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOREADTOCENTRYS\n"));
<
2201a2174,2177
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOREADTOCENTRYS\n"));
>
2210a2187
> cam_periph_unlock(periph);
2219a2197
> cam_periph_unlock(periph);
2241a2220
> cam_periph_unlock(periph);
2262a2242
> cam_periph_unlock(periph);
2275a2256
> cam_periph_unlock(periph);
2291a2273
> cam_periph_unlock(periph);
2303a2286
> cam_periph_unlock(periph);
2316a2300,2302
> data = malloc(sizeof(*data), M_TEMP, M_WAITOK);
>
> cam_periph_lock(periph);
2320,2321d2305
< data = malloc(sizeof(*data), M_TEMP, M_WAITOK);
<
2327a2312
> cam_periph_unlock(periph);
2335a2321
> cam_periph_unlock(periph);
2357a2344
> cam_periph_unlock(periph);
2365a2353
> cam_periph_unlock(periph);
2373a2362
> cam_periph_unlock(periph);
2382,2384d2370
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETPATCH\n"));
<
2387a2374,2378
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETPATCH\n"));
>
2390a2382
> cam_periph_unlock(periph);
2402a2395
> cam_periph_unlock(periph);
2411,2413d2403
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCGETVOL\n"));
<
2416a2407,2411
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCGETVOL\n"));
>
2419a2415
> cam_periph_unlock(periph);
2430a2427
> cam_periph_unlock(periph);
2439,2441d2435
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETVOL\n"));
<
2444a2439,2443
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETVOL\n"));
>
2447a2447
> cam_periph_unlock(periph);
2460a2461
> cam_periph_unlock(periph);
2469,2471d2469
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETMONO\n"));
<
2474a2473,2477
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETMONO\n"));
>
2477a2481
> cam_periph_unlock(periph);
2488a2493
> cam_periph_unlock(periph);
2497,2499d2501
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETSTEREO\n"));
<
2502a2505,2509
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETSTEREO\n"));
>
2505a2513
> cam_periph_unlock(periph);
2517a2526
> cam_periph_unlock(periph);
2525,2527d2533
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETMUTE\n"));
<
2530a2537,2541
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETMUTE\n"));
>
2533a2545
> cam_periph_unlock(periph);
2543a2556
> cam_periph_unlock(periph);
2551,2553d2563
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETLEFT\n"));
<
2557c2567,2571
<
---
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETLEFT\n"));
>
2560a2575
> cam_periph_unlock(periph);
2570a2586
> cam_periph_unlock(periph);
2578,2580d2593
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETRIGHT\n"));
<
2584a2598,2601
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETRIGHT\n"));
>
2587a2605
> cam_periph_unlock(periph);
2597a2616
> cam_periph_unlock(periph);
2600a2620
> cam_periph_lock(periph);
2601a2622
> cam_periph_unlock(periph);
2603a2625
> cam_periph_lock(periph);
2604a2627
> cam_periph_unlock(periph);
2606a2630
> cam_periph_lock(periph);
2607a2632
> cam_periph_unlock(periph);
2609a2635
> cam_periph_lock(periph);
2610a2637
> cam_periph_unlock(periph);
2612a2640
> cam_periph_lock(periph);
2613a2642
> cam_periph_unlock(periph);
2615a2645
> cam_periph_lock(periph);
2616a2647
> cam_periph_unlock(periph);
2618a2650
> cam_periph_lock(periph);
2619a2652
> cam_periph_unlock(periph);
2621a2655
> cam_periph_lock(periph);
2622a2657
> cam_periph_unlock(periph);
2636a2672
> cam_periph_lock(periph);
2637a2674
> cam_periph_unlock(periph);
2639a2677
> cam_periph_lock(periph);
2640a2679
> cam_periph_unlock(periph);
2647a2687
> cam_periph_lock(periph);
2651a2692
> cam_periph_unlock(periph);
2658a2700
> cam_periph_lock(periph);
2659a2702
> cam_periph_unlock(periph);
2663a2707
> cam_periph_lock(periph);
2664a2709
> cam_periph_unlock(periph);
2668,2669c2713,2715
< cam_periph_unlock(periph);
<
---
> cam_periph_lock(periph);
> cam_periph_unhold(periph);
>
2673a2720
> cam_periph_unlock(periph);
2871a2919
> /* XXX Should be M_WAITOK */
2873c2921,2923
< M_TEMP, M_WAITOK);
---
> M_TEMP, M_NOWAIT);
> if (rcap_buf == NULL)
> return (ENOMEM);
< __FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_cd.c 164906 2006-12-05 07:45:28Z mjacob $");
---
> __FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_cd.c 168752 2007-04-15 08:49:19Z scottl $");
72a73
> #include <cam/cam_sim.h>
106c107,108
< CD_FLAG_SCTX_INIT = 0x1000
---
> CD_FLAG_SCTX_INIT = 0x1000,
> CD_FLAG_OPEN = 0x2000
293,295d294
<
< static int num_changers;
<
322,323c321,322
< struct callout_handle short_handle;
< struct callout_handle long_handle;
---
> struct callout short_handle;
> struct callout long_handle;
328a328
> static struct mtx changerq_mtx;
329a330
> static int num_changers;
331d331
<
337a338,340
> mtx_init(&changerq_mtx, "cdchangerq", "SCSI CD Changer List", MTX_DEF);
> STAILQ_INIT(&changerq);
>
367d369
< int s;
387,393d388
< * Although the oninvalidate() routines are always called at
< * splsoftcam, we need to be at splbio() here to keep the buffer
< * queue from being modified while we traverse it.
< */
< s = splbio();
<
< /*
399d393
< splx(s);
418d411
< int s;
429d421
< s = splsoftcam();
459,460c451
< untimeout(cdshorttimeout, softc->changer,
< softc->changer->short_handle);
---
> callout_stop(&softc->changer->short_handle);
481,482c472
< untimeout(cdrunchangerqueue, softc->changer,
< softc->changer->long_handle);
---
> callout_stop(&softc->changer->long_handle);
487,488c477
< untimeout(cdshorttimeout, softc->changer,
< softc->changer->short_handle);
---
> callout_stop(&softc->changer->short_handle);
491a481
> mtx_lock(&changerq_mtx);
493a484,485
> num_changers--;
> mtx_unlock(&changerq_mtx);
496d487
< num_changers--;
500d490
< splx(s);
547d536
< int s;
550d538
< s = splsoftcam();
558d545
< splx(s);
575c562,563
< softc = (struct cd_softc *)periph->softc;
---
> if (cam_periph_acquire(periph) != CAM_REQ_CMP)
> return;
576a565
> softc = (struct cd_softc *)periph->softc;
590a580
> cam_periph_release(periph);
603a594
> cam_periph_release(periph);
736a728
> cam_periph_unlock(periph);
750c742
< softc->disk->d_flags = DISKFLAG_NEEDSGIANT;
---
> softc->disk->d_flags = 0;
751a744
> cam_periph_lock(periph);
786,788d778
< if (num_changers == 0)
< STAILQ_INIT(&changerq);
<
792a783
> mtx_lock(&changerq_mtx);
802a794
> mtx_unlock(&changerq_mtx);
908,909d899
< num_changers++;
<
917a908,914
> callout_init_mtx(&nchanger->long_handle,
> periph->sim->mtx, 0);
> callout_init_mtx(&nchanger->short_handle,
> periph->sim->mtx, 0);
>
> mtx_lock(&changerq_mtx);
> num_changers++;
919a917
> mtx_unlock(&changerq_mtx);
981,983c979,983
< /* Lock this peripheral until we are setup */
< /* Can't block */
< cam_periph_lock(periph, PRIBIO);
---
> /*
> * Refcount and block open attempts until we are setup
> * Can't block
> */
> (void)cam_periph_hold(periph, PRIBIO);
999d998
< int s;
1007,1010c1006,1010
< /*
< * Grab splsoftcam and hold it until we lock the peripheral.
< */
< s = splsoftcam();
---
> if (cam_periph_acquire(periph) != CAM_REQ_CMP)
> return(ENXIO);
>
> cam_periph_lock(periph);
>
1012c1012,1013
< splx(s);
---
> cam_periph_unlock(periph);
> cam_periph_release(periph);
1016,1017c1017,1019
< if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) {
< splx(s);
---
> if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) {
> cam_periph_unlock(periph);
> cam_periph_release(periph);
1021c1023,1027
< splx(s);
---
> /* Closes aren't symmetrical with opens, so fix up the refcounting. */
> if (softc->flags & CD_FLAG_OPEN)
> cam_periph_release(periph);
> else
> softc->flags |= CD_FLAG_OPEN;
1023,1025d1028
< if (cam_periph_acquire(periph) != CAM_REQ_CMP)
< return(ENXIO);
<
1032a1036,1037
> CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n"));
> cam_periph_unhold(periph);
1035,1037c1040
< CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n"));
<
< return (error);
---
> return (0);
1045d1047
< int error;
1053,1054c1055,1056
< if ((error = cam_periph_lock(periph, PRIBIO)) != 0)
< return (error);
---
> cam_periph_lock(periph);
> cam_periph_hold(periph, PRIBIO);
1068c1070
< softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC);
---
> softc->flags &= ~(CD_FLAG_VALID_MEDIA|CD_FLAG_VALID_TOC|CD_FLAG_OPEN);
1069a1072
> cam_periph_unhold(periph);
1080d1082
< int s;
1082,1083d1083
< s = splsoftcam();
<
1098,1099d1097
<
< splx(s);
1109d1106
< int s;
1111,1112d1107
< s = splsoftcam();
<
1150,1152d1144
<
< splx(s);
<
1161d1152
< int s;
1163,1164d1153
< s = splsoftcam();
<
1183d1171
< splx(s);
1192a1181,1188
> /*
> * We always need to reset the frozen count and clear the
> * active flag.
> */
> changer->devq.qfrozen_cnt--;
> changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
> changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
>
1198,1200c1194,1196
< changer->long_handle =
< timeout(cdrunchangerqueue, changer,
< changer_max_busy_seconds * hz);
---
> callout_reset(&changer->long_handle,
> changer_max_busy_seconds * hz,
> cdrunchangerqueue, changer);
1203d1198
< splx(s);
1208,1215d1202
< * We always need to reset the frozen count and clear the
< * active flag.
< */
< changer->devq.qfrozen_cnt--;
< changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
< changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
<
< /*
1245c1232
< untimeout(cdrunchangerqueue, changer, changer->long_handle);
---
> callout_stop(&changer->long_handle);
1250c1237
< untimeout(cdshorttimeout, changer, changer->short_handle);
---
> callout_stop(&changer->short_handle);
1260,1261d1246
<
< splx(s);
1268d1252
< int s;
1270,1271d1253
< s = splsoftcam();
<
1316,1318c1298,1300
< changer->long_handle =
< timeout(cdrunchangerqueue, changer,
< changer_max_busy_seconds * hz);
---
> callout_reset(&changer->long_handle,
> changer_max_busy_seconds * hz,
> cdrunchangerqueue, changer);
1325,1327c1307,1309
< changer->short_handle =
< timeout(cdshorttimeout, changer,
< changer_min_busy_seconds * hz);
---
> callout_reset(&changer->short_handle,
> changer_min_busy_seconds * hz,
> cdshorttimeout, changer);
1340d1321
< splx(s);
1369d1349
< int s;
1374,1376d1353
<
< s = splsoftcam();
<
1399c1376,1377
< tsleep(&softc->changer, PRIBIO, "cgticb", 0);
---
> msleep(&softc->changer, periph->sim->mtx,
> PRIBIO, "cgticb", 0);
1401d1378
< splx(s);
1417d1393
< int s;
1424a1401
> cam_periph_lock(periph);
1430,1436d1406
< * Mask interrupts so that the pack cannot be invalidated until
< * after we are in the queue. Otherwise, we might not properly
< * clean up one of the buffers.
< */
< s = splbio();
<
< /*
1440c1410
< splx(s);
---
> cam_periph_unlock(periph);
1454c1424
< splx(s);
---
> cam_periph_unlock(periph);
1465,1466d1434
< splx(s);
<
1475a1444
> cam_periph_unlock(periph);
1486d1454
< int s;
1495,1497d1462
< int oldspl;
<
< s = splbio();
1505d1469
< splx(s);
1508d1471
< splx(s);
1532,1536d1494
< /*
< * Block out any asyncronous callbacks
< * while we touch the pending ccb list.
< */
< oldspl = splcam();
1540d1497
< splx(oldspl);
1550d1506
< splx(s);
1604d1559
< int oldspl;
1628,1629d1582
< int s;
<
1632d1584
< s = splbio();
1634d1585
< splx(s);
1657,1661d1607
< /*
< * Block out any asyncronous callbacks
< * while we touch the pending ccb list.
< */
< oldspl = splcam();
1664d1609
< splx(oldspl);
1855c1800
< cam_periph_unlock(periph);
---
> cam_periph_unhold(periph);
1908c1853
< int error, nocopyout;
---
> int nocopyout, error = 0;
1913a1859
> cam_periph_lock(periph);
1921c1867,1871
< error = cam_periph_lock(periph, PRIBIO | PCATCH);
---
> if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) {
> cam_periph_unlock(periph);
> cam_periph_release(periph);
> return (error);
> }
1923,1924d1872
< if (error != 0)
< return(error);
1939,1942d1886
< if (error != 0) {
< cam_periph_unlock(periph);
< return (error);
< }
1943a1888,1894
> /*
> * Drop the lock here so later mallocs can use WAITOK. The periph
> * is essentially locked still with the cam_periph_hold call above.
> */
> cam_periph_unlock(periph);
> if (error != 0)
> return (error);
1958a1910
> cam_periph_lock(periph);
1964a1917
> cam_periph_unlock(periph);
1973c1926,1927
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
1974a1929
> }
2035a1991
> cam_periph_unlock(periph);
2048a2005
> cam_periph_lock(periph);
2054a2012
> cam_periph_unlock(periph);
2063c2021,2022
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
2064a2024
> }
2071a2032
> cam_periph_unlock(periph);
2081,2083d2041
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCPLAYBLOCKS\n"));
<
2087a2046,2050
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCPLAYBLOCKS\n"));
>
>
2090a2054
> cam_periph_unlock(periph);
2099c2063,2064
< if (error)
---
> if (error) {
> cam_periph_unlock(periph);
2100a2066
> }
2101a2068
> cam_periph_unlock(periph);
2114,2116d2080
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCREADSUBCHANNEL\n"));
<
2119a2084,2087
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCREADSUBCHANNEL\n"));
>
2127a2096
> cam_periph_unlock(periph);
2138a2108
> cam_periph_unlock(periph);
2146a2117
> cam_periph_unlock(periph);
2161a2133,2136
> th = malloc(sizeof(struct ioc_toc_header), M_TEMP,
> M_WAITOK);
>
> cam_periph_lock(periph);
2165,2166d2139
< th = malloc(sizeof(struct ioc_toc_header), M_TEMP,
< M_WAITOK);
2170a2144
> cam_periph_unlock(periph);
2183a2158
> cam_periph_unlock(periph);
2196,2198d2170
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOREADTOCENTRYS\n"));
<
2201a2174,2177
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOREADTOCENTRYS\n"));
>
2210a2187
> cam_periph_unlock(periph);
2219a2197
> cam_periph_unlock(periph);
2241a2220
> cam_periph_unlock(periph);
2262a2242
> cam_periph_unlock(periph);
2275a2256
> cam_periph_unlock(periph);
2291a2273
> cam_periph_unlock(periph);
2303a2286
> cam_periph_unlock(periph);
2316a2300,2302
> data = malloc(sizeof(*data), M_TEMP, M_WAITOK);
>
> cam_periph_lock(periph);
2320,2321d2305
< data = malloc(sizeof(*data), M_TEMP, M_WAITOK);
<
2327a2312
> cam_periph_unlock(periph);
2335a2321
> cam_periph_unlock(periph);
2357a2344
> cam_periph_unlock(periph);
2365a2353
> cam_periph_unlock(periph);
2373a2362
> cam_periph_unlock(periph);
2382,2384d2370
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETPATCH\n"));
<
2387a2374,2378
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETPATCH\n"));
>
2390a2382
> cam_periph_unlock(periph);
2402a2395
> cam_periph_unlock(periph);
2411,2413d2403
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCGETVOL\n"));
<
2416a2407,2411
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCGETVOL\n"));
>
2419a2415
> cam_periph_unlock(periph);
2430a2427
> cam_periph_unlock(periph);
2439,2441d2435
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETVOL\n"));
<
2444a2439,2443
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETVOL\n"));
>
2447a2447
> cam_periph_unlock(periph);
2460a2461
> cam_periph_unlock(periph);
2469,2471d2469
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETMONO\n"));
<
2474a2473,2477
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETMONO\n"));
>
2477a2481
> cam_periph_unlock(periph);
2488a2493
> cam_periph_unlock(periph);
2497,2499d2501
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETSTEREO\n"));
<
2502a2505,2509
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETSTEREO\n"));
>
2505a2513
> cam_periph_unlock(periph);
2517a2526
> cam_periph_unlock(periph);
2525,2527d2533
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETMUTE\n"));
<
2530a2537,2541
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETMUTE\n"));
>
2533a2545
> cam_periph_unlock(periph);
2543a2556
> cam_periph_unlock(periph);
2551,2553d2563
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETLEFT\n"));
<
2557c2567,2571
<
---
>
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETLEFT\n"));
>
2560a2575
> cam_periph_unlock(periph);
2570a2586
> cam_periph_unlock(periph);
2578,2580d2593
< CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
< ("trying to do CDIOCSETRIGHT\n"));
<
2584a2598,2601
> cam_periph_lock(periph);
> CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
> ("trying to do CDIOCSETRIGHT\n"));
>
2587a2605
> cam_periph_unlock(periph);
2597a2616
> cam_periph_unlock(periph);
2600a2620
> cam_periph_lock(periph);
2601a2622
> cam_periph_unlock(periph);
2603a2625
> cam_periph_lock(periph);
2604a2627
> cam_periph_unlock(periph);
2606a2630
> cam_periph_lock(periph);
2607a2632
> cam_periph_unlock(periph);
2609a2635
> cam_periph_lock(periph);
2610a2637
> cam_periph_unlock(periph);
2612a2640
> cam_periph_lock(periph);
2613a2642
> cam_periph_unlock(periph);
2615a2645
> cam_periph_lock(periph);
2616a2647
> cam_periph_unlock(periph);
2618a2650
> cam_periph_lock(periph);
2619a2652
> cam_periph_unlock(periph);
2621a2655
> cam_periph_lock(periph);
2622a2657
> cam_periph_unlock(periph);
2636a2672
> cam_periph_lock(periph);
2637a2674
> cam_periph_unlock(periph);
2639a2677
> cam_periph_lock(periph);
2640a2679
> cam_periph_unlock(periph);
2647a2687
> cam_periph_lock(periph);
2651a2692
> cam_periph_unlock(periph);
2658a2700
> cam_periph_lock(periph);
2659a2702
> cam_periph_unlock(periph);
2663a2707
> cam_periph_lock(periph);
2664a2709
> cam_periph_unlock(periph);
2668,2669c2713,2715
< cam_periph_unlock(periph);
<
---
> cam_periph_lock(periph);
> cam_periph_unhold(periph);
>
2673a2720
> cam_periph_unlock(periph);
2871a2919
> /* XXX Should be M_WAITOK */
2873c2921,2923
< M_TEMP, M_WAITOK);
---
> M_TEMP, M_NOWAIT);
> if (rcap_buf == NULL)
> return (ENOMEM);