Deleted Added
full compact
34c34
< * $FreeBSD: head/sys/dev/firewire/sbp.c 266270 2014-05-16 21:19:17Z brueffer $
---
> * $FreeBSD: head/sys/dev/firewire/sbp.c 266772 2014-05-27 19:56:02Z jhb $
180c180
< struct callout_handle timeout_ch;
---
> struct callout timer;
253,254c253,255
< #define SBP_LOCK(sbp) mtx_lock(&(sbp)->mtx)
< #define SBP_UNLOCK(sbp) mtx_unlock(&(sbp)->mtx)
---
> #define SBP_LOCK(sbp) mtx_lock(&(sbp)->mtx)
> #define SBP_UNLOCK(sbp) mtx_unlock(&(sbp)->mtx)
> #define SBP_LOCK_ASSERT(sbp) mtx_assert(&(sbp)->mtx, MA_OWNED)
268d268
< static struct fw_xfer * sbp_write_cmd_locked (struct sbp_dev *, int, int);
340c340,341
< BUS_ADD_CHILD(parent, 0, "sbp", device_get_unit(parent));
---
> if (device_find_child(parent, "sbp", -1) == NULL)
> BUS_ADD_CHILD(parent, 0, "sbp", -1);
349d349
< device_t pa;
355,359d354
< pa = device_get_parent(dev);
< if(device_get_unit(dev) != device_get_unit(pa)){
< return(ENXIO);
< }
<
462a458
> SBP_LOCK_ASSERT(sbp);
479,480c475
< printf("%s:%d no LUN found\n",
< device_get_nameunit(target->sbp->fd.dev),
---
> device_printf(target->sbp->fd.dev, "%d no LUN found\n",
551c546
< CALLOUT_INIT(&sdev->login_callout);
---
> callout_init_mtx(&sdev->login_callout, &sbp->mtx, 0);
595c590
< callout_handle_init(&ocb->timeout_ch);
---
> callout_init_mtx(&ocb->timer, &sbp->mtx, 0);
651,652c646,647
< CALLOUT_INIT(&target->mgm_ocb_timeout);
< CALLOUT_INIT(&target->scan_callout);
---
> callout_init_mtx(&target->mgm_ocb_timeout, &sbp->mtx, 0);
> callout_init_mtx(&target->scan_callout, &sbp->mtx, 0);
695a691
> SBP_LOCK_ASSERT(sdev->target->sbp);
739a736
> SBP_LOCK_ASSERT(sbp);
749d745
< SBP_LOCK(sbp);
752d747
< SBP_UNLOCK(sbp);
781d775
< SBP_LOCK(sbp);
784d777
< SBP_UNLOCK(sbp);
812a806
> SBP_LOCK(sbp);
814d807
< SBP_LOCK(sbp);
817d809
< SBP_UNLOCK(sbp);
819a812
> SBP_UNLOCK(sbp);
839a833
> SBP_LOCK(sbp);
890d883
< SBP_LOCK(sbp);
899d891
< int s;
906c898
< s = splfw();
---
> SBP_LOCK(sdev->target->sbp);
908c900
< splx(s);
---
> SBP_UNLOCK(sdev->target->sbp);
917d908
< int s;
921,922c912
< s = splfw();
< SBP_LOCK(sdev->target->sbp);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
924,925d913
< SBP_UNLOCK(sdev->target->sbp);
< splx(s);
939a928
> SBP_LOCK(target->sbp);
944a934
> SBP_UNLOCK(target->sbp);
979a970
> SBP_LOCK(sdev->target->sbp);
981c972
< return;
---
> SBP_UNLOCK(sdev->target->sbp);
1005a997
> SBP_LOCK_ASSERT(target->sbp);
1035a1028
> SBP_LOCK_ASSERT(target->sbp);
1059d1051
< SBP_LOCK(target->sbp);
1063d1054
< SBP_UNLOCK(target->sbp);
1083a1075
> SBP_LOCK(sbp);
1098c1090
< * if LUN 0 doesn't exists.
---
> * if LUN 0 doesn't exist.
1101a1094
> SBP_UNLOCK(sbp);
1106c1099
< return;
---
> SBP_UNLOCK(sbp);
1123a1117
> SBP_LOCK(sdev->target->sbp);
1126d1119
< SBP_LOCK(sdev->target->sbp);
1129d1121
< SBP_UNLOCK(sdev->target->sbp);
1130a1123
> SBP_UNLOCK(sdev->target->sbp);
1138a1132
> SBP_LOCK_ASSERT(sdev->target->sbp);
1165a1160
> SBP_LOCK(sdev->target->sbp);
1167a1163
> SBP_UNLOCK(sdev->target->sbp);
1202a1199
> SBP_LOCK(sdev->target->sbp);
1205d1201
< SBP_LOCK(sdev->target->sbp);
1232c1228
< mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
1243c1239
< xfer = sbp_write_cmd_locked(sdev, FWTCODE_WREQB, 0x08);
---
> xfer = sbp_write_cmd(sdev, FWTCODE_WREQB, 0x08);
1255,1264c1251,1254
< /*
< * sbp_xfer_free() will attempt to acquire
< * the SBP lock on entrance. Also, this removes
< * a LOR between the firewire layer and sbp
< */
< SBP_UNLOCK(sdev->target->sbp);
< if(fw_asyreq(xfer->fc, -1, xfer) != 0){
< sbp_xfer_free(xfer);
< ocb->ccb->ccb_h.status = CAM_REQ_INVALID;
< xpt_done(ocb->ccb);
---
> if (fw_asyreq(xfer->fc, -1, xfer) != 0) {
> sbp_xfer_free(xfer);
> ocb->ccb->ccb_h.status = CAM_REQ_INVALID;
> xpt_done(ocb->ccb);
1266d1255
< SBP_LOCK(sdev->target->sbp);
1283a1273
> SBP_LOCK(sdev->target->sbp);
1288d1277
< SBP_LOCK(sdev->target->sbp);
1290d1278
< SBP_UNLOCK(sdev->target->sbp);
1292c1280
< return;
---
> SBP_UNLOCK(sdev->target->sbp);
1310c1298
< xfer = sbp_write_cmd_locked(sdev, FWTCODE_WREQQ, 0x10);
---
> xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x10);
1320c1308
< sbp_write_cmd_locked(struct sbp_dev *sdev, int tcode, int offset)
---
> sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
1325c1313
< int s, new = 0;
---
> int new = 0;
1327c1315
< mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
1330d1317
< s = splfw();
1335d1321
< splx(s);
1341d1326
< splx(s);
1351d1335
< splx(s);
1374d1357
<
1377,1389d1359
< static struct fw_xfer *
< sbp_write_cmd(struct sbp_dev *sdev, int tcode, int offset)
< {
< struct sbp_softc *sbp = sdev->target->sbp;
< struct fw_xfer *xfer;
<
< SBP_LOCK(sbp);
< xfer = sbp_write_cmd_locked(sdev, tcode, offset);
< SBP_UNLOCK(sbp);
<
< return (xfer);
< }
<
1397c1367
< int s, nid;
---
> int nid;
1402,1403c1372
< s = splfw();
< SBP_LOCK(target->sbp);
---
> SBP_LOCK_ASSERT(target->sbp);
1407,1408d1375
< SBP_UNLOCK(target->sbp);
< splx(s);
1412d1378
< SBP_UNLOCK(target->sbp);
1416,1417d1381
< SBP_UNLOCK(target->sbp);
< splx(s);
1421d1384
< SBP_UNLOCK(target->sbp);
1461d1423
< SBP_LOCK(target->sbp);
1463,1464d1424
< SBP_UNLOCK(target->sbp);
< splx(s);
1469d1428
< splx(s);
1679a1639
> SBP_LOCK_ASSERT(sbp);
1799d1758
< SBP_LOCK(sbp);
1802d1760
< SBP_UNLOCK(sbp);
1907d1864
< SBP_LOCK(sbp);
1909d1865
< SBP_UNLOCK(sbp);
1948d1903
< /* we don't need a lock here because bottom half is serialized */
1951,1953d1905
<
< return;
<
1959c1911
< int s;
---
> struct sbp_softc *sbp;
1961c1913,1914
< s = splcam();
---
> sbp = (struct sbp_softc *)xfer->sc;
> SBP_LOCK(sbp);
1963c1916
< splx(s);
---
> SBP_UNLOCK(sbp);
1974c1927
< int i, s, error;
---
> int i, error;
1990,1991c1943
< sbp = ((struct sbp_softc *)device_get_softc(dev));
< bzero(sbp, sizeof(struct sbp_softc));
---
> sbp = device_get_softc(dev);
2067d2018
< s = splfw();
2070d2020
< splx(s);
2092a2043
> SBP_LOCK_ASSERT(sbp);
2115a2067
> SBP_LOCK(sbp);
2116a2069
> SBP_UNLOCK(sbp);
2122a2076
> struct sbp_softc *sbp;
2127,2130c2081,2088
< for (i = 0; i < SBP_QUEUE_LEN; i++)
< bus_dmamap_destroy(sdev->target->sbp->dmat,
< sdev->ocb[i].dmamap);
< fwdma_free(sdev->target->sbp->fd.fc, &sdev->dma);
---
> sbp = sdev->target->sbp;
> SBP_UNLOCK(sbp);
> callout_drain(&sdev->login_callout);
> for (i = 0; i < SBP_QUEUE_LEN; i++) {
> callout_drain(&sdev->ocb[i].timer);
> bus_dmamap_destroy(sbp->dmat, sdev->ocb[i].dmamap);
> }
> fwdma_free(sbp->fd.fc, &sdev->dma);
2132c2090
< sdev = NULL;
---
> SBP_LOCK(sbp);
2144d2101
< callout_stop(&target->mgm_ocb_timeout);
2145a2103,2107
> SBP_LOCK_ASSERT(sbp);
> SBP_UNLOCK(sbp);
> callout_drain(&target->mgm_ocb_timeout);
> callout_drain(&target->scan_callout);
> SBP_LOCK(sbp);
2149,2151c2111
< for (xfer = STAILQ_FIRST(&target->xferlist);
< xfer != NULL; xfer = next) {
< next = STAILQ_NEXT(xfer, link);
---
> STAILQ_FOREACH_SAFE(xfer, &target->xferlist, link, next) {
2171a2132
> SBP_LOCK(sbp);
2175d2135
< SBP_LOCK(sbp);
2180d2139
< SBP_UNLOCK(sbp);
2182a2142
> SBP_UNLOCK(sbp);
2186a2147
> SBP_LOCK(sbp);
2188a2150
> SBP_UNLOCK(sbp);
2207a2170
> SBP_LOCK_ASSERT(sdev->target->sbp);
2210d2172
< SBP_LOCK(sdev->target->sbp);
2217d2178
< SBP_UNLOCK(sdev->target->sbp);
2225a2187
> SBP_LOCK_ASSERT(target->sbp);
2242a2205
> SBP_LOCK_ASSERT(target->sbp);
2251d2213
< SBP_LOCK(target->sbp);
2254d2215
< SBP_UNLOCK(target->sbp);
2278a2240
> SBP_LOCK_ASSERT(target->sbp);
2304a2267
> SBP_LOCK_ASSERT(sdev->target->sbp);
2309d2271
< SBP_LOCK(sdev->target->sbp);
2312d2273
< SBP_UNLOCK(sdev->target->sbp);
2334c2295
< sbp_action1(struct cam_sim *sim, union ccb *ccb)
---
> sbp_action(struct cam_sim *sim, union ccb *ccb)
2340a2302,2303
> if (sbp != NULL)
> SBP_LOCK_ASSERT(sbp);
2462d2424
< SBP_LOCK(sdev->target->sbp);
2465d2426
< SBP_UNLOCK(sdev->target->sbp);
2521c2482
< printf("sbp_action1: block_size is 0.\n");
---
> printf("sbp_action: block_size is 0.\n");
2646,2655d2606
< sbp_action(struct cam_sim *sim, union ccb *ccb)
< {
< int s;
<
< s = splfw();
< sbp_action1(sim, ccb);
< splx(s);
< }
<
< static void
2750c2701
< int s = splfw(), order = 0;
---
> int order = 0;
2761,2763c2712,2713
< SBP_LOCK(sdev->target->sbp);
< for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) {
< next = STAILQ_NEXT(ocb, ocb);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
> STAILQ_FOREACH_SAFE(ocb, &sdev->ocbs, ocb, next) {
2768,2769c2718
< untimeout(sbp_timeout, (caddr_t)ocb,
< ocb->timeout_ch);
---
> callout_stop(&ocb->timer);
2798d2746
< SBP_UNLOCK(sdev->target->sbp);
2800d2747
< SBP_LOCK(sdev->target->sbp);
2811,2812d2757
< SBP_UNLOCK(sdev->target->sbp);
< splx(s);
2826d2770
< int s = splfw();
2829c2773
< mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
2842,2843c2786,2787
< ocb->timeout_ch = timeout(sbp_timeout, (caddr_t)ocb,
< (ocb->ccb->ccb_h.timeout * hz) / 1000);
---
> callout_reset(&ocb->timer, (ocb->ccb->ccb_h.timeout * hz) / 1000,
> sbp_timeout, ocb);
2866d2809
< splx(s);
2875d2817
< int s = splfw();
2877c2819
< mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
2882d2823
< splx(s);
2886d2826
< splx(s);
2897c2837
< SBP_LOCK(sdev->target->sbp);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
2907d2846
< SBP_UNLOCK(sdev->target->sbp);
2915a2855
> SBP_LOCK_ASSERT(sdev->target->sbp);
2935,2936c2875
< untimeout(sbp_timeout, (caddr_t)ocb,
< ocb->timeout_ch);
---
> callout_stop(&ocb->timer);
2938d2876
< SBP_LOCK(sdev->target->sbp);
2940d2877
< SBP_UNLOCK(sdev->target->sbp);
2948d2884
< int s;
2952,2953d2887
< s = splfw();
<
2955c2889
< SBP_LOCK(sdev->target->sbp);
---
> SBP_LOCK_ASSERT(sdev->target->sbp);
2958d2891
< SBP_UNLOCK(sdev->target->sbp);
2960,2961c2893
< for (ocb = STAILQ_FIRST(&temp); ocb != NULL; ocb = next) {
< next = STAILQ_NEXT(ocb, ocb);
---
> STAILQ_FOREACH_SAFE(ocb, &temp, ocb, next) {
2968,2969d2899
<
< splx(s);