2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
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
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
36 #include <sys/sysctl.h>
37 #include <sys/taskqueue.h>
39 #include <sys/mutex.h>
41 #include <sys/devicestat.h>
42 #include <sys/eventhandler.h>
43 #include <sys/malloc.h>
45 #include <geom/geom_disk.h>
54 #include <cam/cam_ccb.h>
55 #include <cam/cam_periph.h>
56 #include <cam/cam_xpt_periph.h>
57 #include <cam/cam_xpt_internal.h>
58 #include <cam/cam_sim.h>
60 #include <cam/ata/ata_all.h>
67 PMP_STATE_PM_QUIRKS_1,
68 PMP_STATE_PM_QUIRKS_2,
69 PMP_STATE_PM_QUIRKS_3,
80 PMP_FLAG_SCTX_INIT = 0x200
87 /* Offsets into our private area for storing information */
88 #define ccb_state ppriv_field0
89 #define ccb_bp ppriv_ptr1
92 SLIST_ENTRY(pmp_softc) links;
105 #define PMP_EV_RESET 1
106 #define PMP_EV_RESCAN 2
108 struct task sysctl_task;
109 struct sysctl_ctx_list sysctl_ctx;
110 struct sysctl_oid *sysctl_tree;
113 static periph_init_t pmpinit;
114 static void pmpasync(void *callback_arg, u_int32_t code,
115 struct cam_path *path, void *arg);
116 static void pmpsysctlinit(void *context, int pending);
117 static periph_ctor_t pmpregister;
118 static periph_dtor_t pmpcleanup;
119 static periph_start_t pmpstart;
120 static periph_oninv_t pmponinvalidate;
121 static void pmpdone(struct cam_periph *periph,
122 union ccb *done_ccb);
124 #ifndef PMP_DEFAULT_TIMEOUT
125 #define PMP_DEFAULT_TIMEOUT 30 /* Timeout in seconds */
128 #ifndef PMP_DEFAULT_RETRY
129 #define PMP_DEFAULT_RETRY 1
132 #ifndef PMP_DEFAULT_HIDE_SPECIAL
133 #define PMP_DEFAULT_HIDE_SPECIAL 1
136 static int pmp_retry_count = PMP_DEFAULT_RETRY;
137 static int pmp_default_timeout = PMP_DEFAULT_TIMEOUT;
138 static int pmp_hide_special = PMP_DEFAULT_HIDE_SPECIAL;
140 static SYSCTL_NODE(_kern_cam, OID_AUTO, pmp, CTLFLAG_RD, 0,
141 "CAM Direct Access Disk driver");
142 SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RWTUN,
143 &pmp_retry_count, 0, "Normal I/O retry count");
144 SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RWTUN,
145 &pmp_default_timeout, 0, "Normal I/O timeout (in seconds)");
146 SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RWTUN,
147 &pmp_hide_special, 0, "Hide extra ports");
149 static struct periph_driver pmpdriver =
152 TAILQ_HEAD_INITIALIZER(pmpdriver.units), /* generation */ 0,
156 PERIPHDRIVER_DECLARE(pmp, pmpdriver);
164 * Install a global async callback. This callback will
165 * receive async callbacks like "new device found".
167 status = xpt_register_async(AC_FOUND_DEVICE, pmpasync, NULL, NULL);
169 if (status != CAM_REQ_CMP) {
170 printf("pmp: Failed to attach master async callback "
171 "due to status 0x%x!\n", status);
176 pmpfreeze(struct cam_periph *periph, int mask)
178 struct pmp_softc *softc = (struct pmp_softc *)periph->softc;
179 struct cam_path *dpath;
182 mask &= ~softc->frozen;
183 for (i = 0; i < 15; i++) {
184 if ((mask & (1 << i)) == 0)
186 if (xpt_create_path(&dpath, periph,
187 xpt_path_path_id(periph->path),
188 i, 0) == CAM_REQ_CMP) {
189 softc->frozen |= (1 << i);
190 xpt_acquire_device(dpath->device);
191 cam_freeze_devq(dpath);
192 xpt_free_path(dpath);
198 pmprelease(struct cam_periph *periph, int mask)
200 struct pmp_softc *softc = (struct pmp_softc *)periph->softc;
201 struct cam_path *dpath;
204 mask &= softc->frozen;
205 for (i = 0; i < 15; i++) {
206 if ((mask & (1 << i)) == 0)
208 if (xpt_create_path(&dpath, periph,
209 xpt_path_path_id(periph->path),
210 i, 0) == CAM_REQ_CMP) {
211 softc->frozen &= ~(1 << i);
212 cam_release_devq(dpath, 0, 0, 0, FALSE);
213 xpt_release_device(dpath->device);
214 xpt_free_path(dpath);
220 pmponinvalidate(struct cam_periph *periph)
222 struct cam_path *dpath;
226 * De-register any async callbacks.
228 xpt_register_async(0, pmpasync, periph, periph->path);
230 for (i = 0; i < 15; i++) {
231 if (xpt_create_path(&dpath, periph,
232 xpt_path_path_id(periph->path),
233 i, 0) == CAM_REQ_CMP) {
234 xpt_async(AC_LOST_DEVICE, dpath, NULL);
235 xpt_free_path(dpath);
238 pmprelease(periph, -1);
242 pmpcleanup(struct cam_periph *periph)
244 struct pmp_softc *softc;
246 softc = (struct pmp_softc *)periph->softc;
248 cam_periph_unlock(periph);
251 * If we can't free the sysctl tree, oh well...
253 if ((softc->flags & PMP_FLAG_SCTX_INIT) != 0
254 && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
255 xpt_print(periph->path, "can't remove sysctl context\n");
258 free(softc, M_DEVBUF);
259 cam_periph_lock(periph);
263 pmpasync(void *callback_arg, u_int32_t code,
264 struct cam_path *path, void *arg)
266 struct cam_periph *periph;
267 struct pmp_softc *softc;
269 periph = (struct cam_periph *)callback_arg;
271 case AC_FOUND_DEVICE:
273 struct ccb_getdev *cgd;
276 cgd = (struct ccb_getdev *)arg;
280 if (cgd->protocol != PROTO_SATAPM)
284 * Allocate a peripheral instance for
285 * this device and start the probe
288 status = cam_periph_alloc(pmpregister, pmponinvalidate,
289 pmpcleanup, pmpstart,
290 "pmp", CAM_PERIPH_BIO,
292 AC_FOUND_DEVICE, cgd);
294 if (status != CAM_REQ_CMP
295 && status != CAM_REQ_INPROG)
296 printf("pmpasync: Unable to attach to new device "
297 "due to status 0x%x\n", status);
303 softc = (struct pmp_softc *)periph->softc;
304 cam_periph_async(periph, code, path, arg);
305 if (code == AC_SCSI_AEN)
306 softc->events |= PMP_EV_RESCAN;
308 softc->events |= PMP_EV_RESET;
309 if (code == AC_SCSI_AEN && softc->state != PMP_STATE_NORMAL)
312 pmpfreeze(periph, softc->found);
313 if (code == AC_SENT_BDR || code == AC_BUS_RESET)
314 softc->found = 0; /* We have to reset everything. */
315 if (softc->state == PMP_STATE_NORMAL) {
316 if (cam_periph_acquire(periph) == CAM_REQ_CMP) {
317 if (softc->pm_pid == 0x37261095 ||
318 softc->pm_pid == 0x38261095)
319 softc->state = PMP_STATE_PM_QUIRKS_1;
321 softc->state = PMP_STATE_PRECONFIG;
322 xpt_schedule(periph, CAM_PRIORITY_DEV);
324 pmprelease(periph, softc->found);
331 cam_periph_async(periph, code, path, arg);
337 pmpsysctlinit(void *context, int pending)
339 struct cam_periph *periph;
340 struct pmp_softc *softc;
341 char tmpstr[80], tmpstr2[80];
343 periph = (struct cam_periph *)context;
344 if (cam_periph_acquire(periph) != CAM_REQ_CMP)
347 softc = (struct pmp_softc *)periph->softc;
348 snprintf(tmpstr, sizeof(tmpstr), "CAM PMP unit %d", periph->unit_number);
349 snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
351 sysctl_ctx_init(&softc->sysctl_ctx);
352 softc->flags |= PMP_FLAG_SCTX_INIT;
353 softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx,
354 SYSCTL_STATIC_CHILDREN(_kern_cam_pmp), OID_AUTO, tmpstr2,
355 CTLFLAG_RD, 0, tmpstr, "device_index");
356 if (softc->sysctl_tree == NULL) {
357 printf("pmpsysctlinit: unable to allocate sysctl tree\n");
358 cam_periph_release(periph);
362 cam_periph_release(periph);
366 pmpregister(struct cam_periph *periph, void *arg)
368 struct pmp_softc *softc;
369 struct ccb_getdev *cgd;
371 cgd = (struct ccb_getdev *)arg;
373 printf("pmpregister: no getdev CCB, can't register device\n");
374 return(CAM_REQ_CMP_ERR);
377 softc = (struct pmp_softc *)malloc(sizeof(*softc), M_DEVBUF,
381 printf("pmpregister: Unable to probe new device. "
382 "Unable to allocate softc\n");
383 return(CAM_REQ_CMP_ERR);
385 periph->softc = softc;
387 softc->pm_pid = ((uint32_t *)&cgd->ident_data)[0];
388 softc->pm_prv = ((uint32_t *)&cgd->ident_data)[1];
389 TASK_INIT(&softc->sysctl_task, 0, pmpsysctlinit, periph);
391 xpt_announce_periph(periph, NULL);
394 * Add async callbacks for bus reset and
395 * bus device reset calls. I don't bother
396 * checking if this fails as, in most cases,
397 * the system will function just fine without
398 * them and the only alternative would be to
399 * not attach the device on failure.
401 xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE |
402 AC_SCSI_AEN, pmpasync, periph, periph->path);
405 * Take an exclusive refcount on the periph while pmpstart is called
406 * to finish the probe. The reference will be dropped in pmpdone at
409 (void)cam_periph_acquire(periph);
411 softc->state = PMP_STATE_PORTS;
412 softc->events = PMP_EV_RESCAN;
413 xpt_schedule(periph, CAM_PRIORITY_DEV);
419 pmpstart(struct cam_periph *periph, union ccb *start_ccb)
421 struct ccb_trans_settings cts;
422 struct ccb_ataio *ataio;
423 struct pmp_softc *softc;
424 struct cam_path *dpath;
427 softc = (struct pmp_softc *)periph->softc;
428 ataio = &start_ccb->ataio;
430 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("pmpstart\n"));
432 if (softc->restart) {
434 if (softc->pm_pid == 0x37261095 || softc->pm_pid == 0x38261095)
435 softc->state = min(softc->state, PMP_STATE_PM_QUIRKS_1);
437 softc->state = min(softc->state, PMP_STATE_PRECONFIG);
439 /* Fetch user wanted device speed. */
440 if (softc->state == PMP_STATE_RESET ||
441 softc->state == PMP_STATE_CONNECT) {
442 if (xpt_create_path(&dpath, periph,
443 xpt_path_path_id(periph->path),
444 softc->pm_step, 0) == CAM_REQ_CMP) {
445 bzero(&cts, sizeof(cts));
446 xpt_setup_ccb(&cts.ccb_h, dpath, CAM_PRIORITY_NONE);
447 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
448 cts.type = CTS_TYPE_USER_SETTINGS;
449 xpt_action((union ccb *)&cts);
450 if (cts.xport_specific.sata.valid & CTS_SATA_VALID_REVISION)
451 revision = cts.xport_specific.sata.revision;
452 xpt_free_path(dpath);
455 switch (softc->state) {
456 case PMP_STATE_PORTS:
457 cam_fill_ataio(ataio,
460 /*flags*/CAM_DIR_NONE,
464 pmp_default_timeout * 1000);
465 ata_pm_read_cmd(ataio, 2, 15);
468 case PMP_STATE_PM_QUIRKS_1:
469 case PMP_STATE_PM_QUIRKS_3:
470 cam_fill_ataio(ataio,
473 /*flags*/CAM_DIR_NONE,
477 pmp_default_timeout * 1000);
478 ata_pm_read_cmd(ataio, 129, 15);
481 case PMP_STATE_PM_QUIRKS_2:
482 cam_fill_ataio(ataio,
485 /*flags*/CAM_DIR_NONE,
489 pmp_default_timeout * 1000);
490 ata_pm_write_cmd(ataio, 129, 15, softc->caps & ~0x1);
493 case PMP_STATE_PRECONFIG:
494 /* Get/update host SATA capabilities. */
495 bzero(&cts, sizeof(cts));
496 xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NONE);
497 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
498 cts.type = CTS_TYPE_CURRENT_SETTINGS;
499 xpt_action((union ccb *)&cts);
500 if (cts.xport_specific.sata.valid & CTS_SATA_VALID_CAPS)
501 softc->caps = cts.xport_specific.sata.caps;
504 cam_fill_ataio(ataio,
507 /*flags*/CAM_DIR_NONE,
511 pmp_default_timeout * 1000);
512 ata_pm_write_cmd(ataio, 0x60, 15, 0x0);
514 case PMP_STATE_RESET:
515 cam_fill_ataio(ataio,
518 /*flags*/CAM_DIR_NONE,
522 pmp_default_timeout * 1000);
523 ata_pm_write_cmd(ataio, 2, softc->pm_step,
525 ((softc->found & (1 << softc->pm_step)) ? 0 : 1));
527 case PMP_STATE_CONNECT:
528 cam_fill_ataio(ataio,
531 /*flags*/CAM_DIR_NONE,
535 pmp_default_timeout * 1000);
536 ata_pm_write_cmd(ataio, 2, softc->pm_step,
539 case PMP_STATE_CHECK:
540 cam_fill_ataio(ataio,
543 /*flags*/CAM_DIR_NONE,
547 pmp_default_timeout * 1000);
548 ata_pm_read_cmd(ataio, 0, softc->pm_step);
550 case PMP_STATE_CLEAR:
552 cam_fill_ataio(ataio,
555 /*flags*/CAM_DIR_NONE,
559 pmp_default_timeout * 1000);
560 ata_pm_write_cmd(ataio, 1, softc->pm_step, 0xFFFFFFFF);
562 case PMP_STATE_CONFIG:
563 cam_fill_ataio(ataio,
566 /*flags*/CAM_DIR_NONE,
570 pmp_default_timeout * 1000);
571 ata_pm_write_cmd(ataio, 0x60, 15, 0x07 |
572 ((softc->caps & CTS_SATA_CAPS_H_AN) ? 0x08 : 0));
577 xpt_action(start_ccb);
581 pmpdone(struct cam_periph *periph, union ccb *done_ccb)
583 struct ccb_trans_settings cts;
584 struct pmp_softc *softc;
585 struct ccb_ataio *ataio;
586 struct cam_path *dpath;
587 u_int32_t priority, res;
590 softc = (struct pmp_softc *)periph->softc;
591 ataio = &done_ccb->ataio;
593 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("pmpdone\n"));
595 priority = done_ccb->ccb_h.pinfo.priority;
597 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
598 if (cam_periph_error(done_ccb, 0, 0, NULL) == ERESTART) {
600 } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
601 cam_release_devq(done_ccb->ccb_h.path,
610 if (softc->restart) {
612 xpt_release_ccb(done_ccb);
613 if (softc->pm_pid == 0x37261095 || softc->pm_pid == 0x38261095)
614 softc->state = min(softc->state, PMP_STATE_PM_QUIRKS_1);
616 softc->state = min(softc->state, PMP_STATE_PRECONFIG);
617 xpt_schedule(periph, priority);
621 switch (softc->state) {
622 case PMP_STATE_PORTS:
623 softc->pm_ports = (ataio->res.lba_high << 24) +
624 (ataio->res.lba_mid << 16) +
625 (ataio->res.lba_low << 8) +
626 ataio->res.sector_count;
627 if (pmp_hide_special) {
629 * This PMP declares 6 ports, while only 5 of them
630 * are real. Port 5 is a SEMB port, probing which
631 * causes timeouts if external SEP is not connected
634 if ((softc->pm_pid == 0x37261095 ||
635 softc->pm_pid == 0x38261095) &&
636 softc->pm_ports == 6)
640 * This PMP declares 7 ports, while only 5 of them
641 * are real. Port 5 is a fake "Config Disk" with
642 * 640 sectors size. Port 6 is a SEMB port.
644 if (softc->pm_pid == 0x47261095 && softc->pm_ports == 7)
648 * These PMPs have extra configuration port.
650 if (softc->pm_pid == 0x57231095 ||
651 softc->pm_pid == 0x57331095 ||
652 softc->pm_pid == 0x57341095 ||
653 softc->pm_pid == 0x57441095)
656 printf("%s%d: %d fan-out ports\n",
657 periph->periph_name, periph->unit_number,
659 if (softc->pm_pid == 0x37261095 || softc->pm_pid == 0x38261095)
660 softc->state = PMP_STATE_PM_QUIRKS_1;
662 softc->state = PMP_STATE_PRECONFIG;
663 xpt_release_ccb(done_ccb);
664 xpt_schedule(periph, priority);
667 case PMP_STATE_PM_QUIRKS_1:
668 softc->caps = (ataio->res.lba_high << 24) +
669 (ataio->res.lba_mid << 16) +
670 (ataio->res.lba_low << 8) +
671 ataio->res.sector_count;
672 if (softc->caps & 0x1)
673 softc->state = PMP_STATE_PM_QUIRKS_2;
675 softc->state = PMP_STATE_PRECONFIG;
676 xpt_release_ccb(done_ccb);
677 xpt_schedule(periph, priority);
680 case PMP_STATE_PM_QUIRKS_2:
682 softc->state = PMP_STATE_PM_QUIRKS_3;
684 softc->state = PMP_STATE_PRECONFIG;
685 xpt_release_ccb(done_ccb);
686 xpt_schedule(periph, priority);
689 case PMP_STATE_PM_QUIRKS_3:
690 res = (ataio->res.lba_high << 24) +
691 (ataio->res.lba_mid << 16) +
692 (ataio->res.lba_low << 8) +
693 ataio->res.sector_count;
694 printf("%s%d: Disabling SiI3x26 R_OK in GSCR_POLL: %x->%x\n",
695 periph->periph_name, periph->unit_number, softc->caps, res);
696 softc->state = PMP_STATE_PRECONFIG;
697 xpt_release_ccb(done_ccb);
698 xpt_schedule(periph, priority);
701 case PMP_STATE_PRECONFIG:
703 softc->state = PMP_STATE_RESET;
704 softc->reset |= ~softc->found;
705 xpt_release_ccb(done_ccb);
706 xpt_schedule(periph, priority);
708 case PMP_STATE_RESET:
710 if (softc->pm_step >= softc->pm_ports) {
712 cam_freeze_devq(periph->path);
713 cam_release_devq(periph->path,
714 RELSIM_RELEASE_AFTER_TIMEOUT,
718 softc->state = PMP_STATE_CONNECT;
720 xpt_release_ccb(done_ccb);
721 xpt_schedule(periph, priority);
723 case PMP_STATE_CONNECT:
725 if (softc->pm_step >= softc->pm_ports) {
728 cam_freeze_devq(periph->path);
729 cam_release_devq(periph->path,
730 RELSIM_RELEASE_AFTER_TIMEOUT,
734 softc->state = PMP_STATE_CHECK;
736 xpt_release_ccb(done_ccb);
737 xpt_schedule(periph, priority);
739 case PMP_STATE_CHECK:
740 res = (ataio->res.lba_high << 24) +
741 (ataio->res.lba_mid << 16) +
742 (ataio->res.lba_low << 8) +
743 ataio->res.sector_count;
744 if (((res & 0xf0f) == 0x103 && (res & 0x0f0) != 0) ||
745 (res & 0x600) != 0) {
747 printf("%s%d: port %d status: %08x\n",
748 periph->periph_name, periph->unit_number,
749 softc->pm_step, res);
751 /* Report device speed if it is online. */
752 if ((res & 0xf0f) == 0x103 &&
753 xpt_create_path(&dpath, periph,
754 xpt_path_path_id(periph->path),
755 softc->pm_step, 0) == CAM_REQ_CMP) {
756 bzero(&cts, sizeof(cts));
757 xpt_setup_ccb(&cts.ccb_h, dpath, CAM_PRIORITY_NONE);
758 cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
759 cts.type = CTS_TYPE_CURRENT_SETTINGS;
760 cts.xport_specific.sata.revision = (res & 0x0f0) >> 4;
761 cts.xport_specific.sata.valid = CTS_SATA_VALID_REVISION;
762 cts.xport_specific.sata.caps = softc->caps &
763 (CTS_SATA_CAPS_H_PMREQ |
764 CTS_SATA_CAPS_H_DMAAA |
766 cts.xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
767 xpt_action((union ccb *)&cts);
768 xpt_free_path(dpath);
770 softc->found |= (1 << softc->pm_step);
773 if (softc->pm_try < 10) {
774 cam_freeze_devq(periph->path);
775 cam_release_devq(periph->path,
776 RELSIM_RELEASE_AFTER_TIMEOUT,
783 printf("%s%d: port %d status: %08x\n",
784 periph->periph_name, periph->unit_number,
785 softc->pm_step, res);
787 softc->found &= ~(1 << softc->pm_step);
788 if (xpt_create_path(&dpath, periph,
789 done_ccb->ccb_h.path_id,
790 softc->pm_step, 0) == CAM_REQ_CMP) {
791 xpt_async(AC_LOST_DEVICE, dpath, NULL);
792 xpt_free_path(dpath);
797 if (softc->pm_step >= softc->pm_ports) {
798 if (softc->reset & softc->found) {
799 cam_freeze_devq(periph->path);
800 cam_release_devq(periph->path,
801 RELSIM_RELEASE_AFTER_TIMEOUT,
806 softc->state = PMP_STATE_CLEAR;
809 xpt_release_ccb(done_ccb);
810 xpt_schedule(periph, priority);
812 case PMP_STATE_CLEAR:
814 if (softc->pm_step >= softc->pm_ports) {
815 softc->state = PMP_STATE_CONFIG;
818 xpt_release_ccb(done_ccb);
819 xpt_schedule(periph, priority);
821 case PMP_STATE_CONFIG:
822 for (i = 0; i < softc->pm_ports; i++) {
825 if ((softc->found & (1 << i)) == 0)
827 if (xpt_create_path(&dpath, periph,
828 xpt_path_path_id(periph->path),
829 i, 0) != CAM_REQ_CMP) {
830 printf("pmpdone: xpt_create_path failed\n");
833 /* If we did hard reset to this device, inform XPT. */
834 if ((softc->reset & softc->found & (1 << i)) != 0)
835 xpt_async(AC_SENT_BDR, dpath, NULL);
836 /* If rescan requested, scan this device. */
837 if (softc->events & PMP_EV_RESCAN) {
838 ccb = xpt_alloc_ccb_nowait();
840 xpt_free_path(dpath);
843 xpt_setup_ccb(&ccb->ccb_h, dpath, CAM_PRIORITY_XPT);
846 xpt_free_path(dpath);
853 xpt_release_ccb(done_ccb);
854 softc->state = PMP_STATE_NORMAL;
857 pmprelease(periph, -1);
858 cam_periph_release_locked(periph);