Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/ata/ata_da.c
Show First 20 Lines • Show All 3,605 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
adaspindown(uint8_t cmd, int flags) | adaspindown(uint8_t cmd, int flags) | ||||
{ | { | ||||
struct cam_periph *periph; | struct cam_periph *periph; | ||||
struct ada_softc *softc; | struct ada_softc *softc; | ||||
struct ccb_ataio local_ccb; | struct ccb_ataio local_ccb; | ||||
int error; | int error; | ||||
int mode; | |||||
CAM_PERIPH_FOREACH(periph, &adadriver) { | CAM_PERIPH_FOREACH(periph, &adadriver) { | ||||
/* If we paniced with lock held - not recurse here. */ | /* If we paniced with lock held - not recurse here. */ | ||||
if (cam_periph_owned(periph)) | if (cam_periph_owned(periph)) | ||||
continue; | continue; | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
softc = (struct ada_softc *)periph->softc; | softc = (struct ada_softc *)periph->softc; | ||||
/* | /* | ||||
* We only spin-down the drive if it is capable of it.. | * We only spin-down the drive if it is capable of it.. | ||||
*/ | */ | ||||
if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { | if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { | ||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
continue; | continue; | ||||
} | |||||
/* | |||||
* Additionally check if we would spin up the drive instead of | |||||
* spinning it down. | |||||
*/ | |||||
if (cmd == ATA_IDLE_IMMEDIATE) { | |||||
memset(&local_ccb, 0, sizeof(local_ccb)); | |||||
xpt_setup_ccb(&local_ccb.ccb_h, periph->path, | |||||
CAM_PRIORITY_NORMAL); | |||||
local_ccb.ccb_h.ccb_state = ADA_CCB_DUMP; | |||||
cam_fill_ataio(&local_ccb, 0, NULL, CAM_DIR_NONE, | |||||
0, NULL, 0, ada_default_timeout * 1000); | |||||
ata_28bit_cmd(&local_ccb, ATA_CHECK_POWER_MODE, | |||||
0, 0, 0); | |||||
local_ccb.cmd.flags |= CAM_ATAIO_NEEDRESULT; | |||||
error = cam_periph_runccb((union ccb *)&local_ccb, | |||||
adaerror, /*cam_flags*/0, | |||||
/*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY, | |||||
softc->disk->d_devstat); | |||||
if (error != 0) { | |||||
xpt_print(periph->path, | |||||
"Failed to read current power mode\n"); | |||||
} else { | |||||
mode = local_ccb.res.sector_count; | |||||
#ifdef DIAGNOSTIC | |||||
if (bootverbose) { | |||||
xpt_print(periph->path, | |||||
mav: I am not sure how useful would it be after initial testing. I'd at very least move it lower… | |||||
Done Inline ActionsOkay, will do. avg: Okay, will do. | |||||
"disk power mode 0x%02x\n", mode); | |||||
} | |||||
#endif | |||||
switch (mode) { | |||||
Not Done Inline ActionsAre there defines for these magic numbers? imp: Are there defines for these magic numbers? | |||||
Done Inline ActionsI could not find any. camcontrol also uses literals. smartmontools has them that way as well. avg: I could not find any. camcontrol also uses literals. smartmontools has them that way as well. | |||||
case 0x00: | |||||
case 0x01: | |||||
if (bootverbose) { | |||||
xpt_print(periph->path, | |||||
"already spun down\n"); | |||||
} | |||||
cam_periph_unlock(periph); | |||||
continue; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
} | } | ||||
if (bootverbose) | if (bootverbose) | ||||
xpt_print(periph->path, "spin-down\n"); | xpt_print(periph->path, "spin-down\n"); | ||||
memset(&local_ccb, 0, sizeof(local_ccb)); | memset(&local_ccb, 0, sizeof(local_ccb)); | ||||
xpt_setup_ccb(&local_ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL); | xpt_setup_ccb(&local_ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL); | ||||
local_ccb.ccb_h.ccb_state = ADA_CCB_DUMP; | local_ccb.ccb_h.ccb_state = ADA_CCB_DUMP; | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
I am not sure how useful would it be after initial testing. I'd at very least move it lower into the default case.