Deleted Added
full compact
31c31
< __FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 212991 2010-09-22 05:17:18Z mav $");
---
> __FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 214279 2010-10-24 16:31:57Z brucec $");
42d41
< #include <sys/reboot.h>
156,159d154
< static int xpt_power_down = 0;
< TUNABLE_INT("kern.cam.power_down", &xpt_power_down);
< SYSCTL_INT(_kern_cam, OID_AUTO, power_down, CTLFLAG_RW,
< &xpt_power_down, 0, "Power down devices on shutdown");
253d247
< static void xpt_shutdown(void *arg, int howto);
4541,4546d4534
< /* Register our shutdown event handler */
< if ((EVENTHANDLER_REGISTER(shutdown_final, xpt_shutdown,
< NULL, SHUTDOWN_PRI_FIRST)) == NULL) {
< printf("xpt_config: failed to register shutdown event.\n");
< }
<
4628,4708d4615
< /*
< * Power down all devices when we are going to power down the system.
< */
< static void
< xpt_shutdown_dev_done(struct cam_periph *periph, union ccb *done_ccb)
< {
<
< /* No-op. We're polling. */
< return;
< }
<
< static int
< xpt_shutdown_dev(struct cam_ed *device, void *arg)
< {
< union ccb ccb;
< struct cam_path path;
<
< if (device->flags & CAM_DEV_UNCONFIGURED)
< return (1);
<
< if (device->protocol == PROTO_ATA) {
< /* Only power down device if it supports power management. */
< if ((device->ident_data.support.command1 &
< ATA_SUPPORT_POWERMGT) == 0)
< return (1);
< } else if (device->protocol != PROTO_SCSI)
< return (1);
<
< xpt_compile_path(&path,
< NULL,
< device->target->bus->path_id,
< device->target->target_id,
< device->lun_id);
< xpt_setup_ccb(&ccb.ccb_h, &path, CAM_PRIORITY_NORMAL);
< if (device->protocol == PROTO_ATA) {
< cam_fill_ataio(&ccb.ataio,
< 1,
< xpt_shutdown_dev_done,
< CAM_DIR_NONE,
< 0,
< NULL,
< 0,
< 30*1000);
< ata_28bit_cmd(&ccb.ataio, ATA_SLEEP, 0, 0, 0);
< } else {
< scsi_start_stop(&ccb.csio,
< /*retries*/1,
< xpt_shutdown_dev_done,
< MSG_SIMPLE_Q_TAG,
< /*start*/FALSE,
< /*load/eject*/FALSE,
< /*immediate*/TRUE,
< SSD_FULL_SIZE,
< /*timeout*/50*1000);
< }
< xpt_polled_action(&ccb);
<
< if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
< xpt_print(&path, "Device power down failed\n");
< if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
< cam_release_devq(ccb.ccb_h.path,
< /*relsim_flags*/0,
< /*reduction*/0,
< /*timeout*/0,
< /*getcount_only*/0);
< xpt_release_path(&path);
< return (1);
< }
<
< static void
< xpt_shutdown(void * arg, int howto)
< {
<
< if (!xpt_power_down)
< return;
< if ((howto & RB_POWEROFF) == 0)
< return;
<
< xpt_for_all_devices(xpt_shutdown_dev, NULL);
< }
<