Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/cam_xpt.c
Show First 20 Lines • Show All 3,198 Lines • ▼ Show 20 Lines | call_sim: | ||||
} | } | ||||
CAM_DEBUG(path, CAM_DEBUG_TRACE, | CAM_DEBUG(path, CAM_DEBUG_TRACE, | ||||
("xpt_action_default: func= %#x %s status %#x\n", | ("xpt_action_default: func= %#x %s status %#x\n", | ||||
start_ccb->ccb_h.func_code, | start_ccb->ccb_h.func_code, | ||||
xpt_action_name(start_ccb->ccb_h.func_code), | xpt_action_name(start_ccb->ccb_h.func_code), | ||||
start_ccb->ccb_h.status)); | start_ccb->ccb_h.status)); | ||||
} | } | ||||
void | uint32_t | ||||
xpt_polled_action(union ccb *start_ccb) | xpt_poll_setup(union ccb *start_ccb) | ||||
{ | { | ||||
u_int32_t timeout; | u_int32_t timeout; | ||||
struct cam_sim *sim; | struct cam_sim *sim; | ||||
struct cam_devq *devq; | struct cam_devq *devq; | ||||
struct cam_ed *dev; | struct cam_ed *dev; | ||||
struct mtx *mtx; | struct mtx *mtx; | ||||
timeout = start_ccb->ccb_h.timeout * 10; | timeout = start_ccb->ccb_h.timeout * 10; | ||||
sim = start_ccb->ccb_h.path->bus->sim; | sim = start_ccb->ccb_h.path->bus->sim; | ||||
devq = sim->devq; | devq = sim->devq; | ||||
mtx = sim->mtx; | mtx = sim->mtx; | ||||
dev = start_ccb->ccb_h.path->device; | dev = start_ccb->ccb_h.path->device; | ||||
mtx_unlock(&dev->device_mtx); | |||||
/* | /* | ||||
* Steal an opening so that no other queued requests | * Steal an opening so that no other queued requests | ||||
* can get it before us while we simulate interrupts. | * can get it before us while we simulate interrupts. | ||||
*/ | */ | ||||
mtx_lock(&devq->send_mtx); | mtx_lock(&devq->send_mtx); | ||||
dev->ccbq.dev_openings--; | dev->ccbq.dev_openings--; | ||||
while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0) && | while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0) && | ||||
(--timeout > 0)) { | (--timeout > 0)) { | ||||
mtx_unlock(&devq->send_mtx); | mtx_unlock(&devq->send_mtx); | ||||
DELAY(100); | DELAY(100); | ||||
if (mtx) | if (mtx) | ||||
mtx_lock(mtx); | mtx_lock(mtx); | ||||
(*(sim->sim_poll))(sim); | (*(sim->sim_poll))(sim); | ||||
if (mtx) | if (mtx) | ||||
mtx_unlock(mtx); | mtx_unlock(mtx); | ||||
camisr_runqueue(); | camisr_runqueue(); | ||||
mtx_lock(&devq->send_mtx); | mtx_lock(&devq->send_mtx); | ||||
} | } | ||||
dev->ccbq.dev_openings++; | dev->ccbq.dev_openings++; | ||||
mtx_unlock(&devq->send_mtx); | mtx_unlock(&devq->send_mtx); | ||||
if (timeout != 0) { | return (timeout); | ||||
xpt_action(start_ccb); | } | ||||
void | |||||
xpt_pollwait(union ccb *start_ccb, uint32_t timeout) | |||||
{ | |||||
struct cam_sim *sim; | |||||
struct mtx *mtx; | |||||
cem: inconsistent whitespace here | |||||
Not Done Inline Actionsthe whitespace is now consistent, but phab is having fits with tabs. imp: the whitespace is now consistent, but phab is having fits with tabs. | |||||
sim = start_ccb->ccb_h.path->bus->sim; | |||||
Done Inline ActionsWhat's the point of passing a timeout argument if it is immediately overwritten? cem: What's the point of passing a `timeout` argument if it is immediately overwritten? | |||||
mtx = sim->mtx; | |||||
while(--timeout > 0) { | while (--timeout > 0) { | ||||
if (mtx) | if (mtx) | ||||
Done Inline Actionsstyle(9) nit: whitespace cem: style(9) nit: whitespace | |||||
mtx_lock(mtx); | mtx_lock(mtx); | ||||
(*(sim->sim_poll))(sim); | (*(sim->sim_poll))(sim); | ||||
if (mtx) | if (mtx) | ||||
mtx_unlock(mtx); | mtx_unlock(mtx); | ||||
camisr_runqueue(); | camisr_runqueue(); | ||||
if ((start_ccb->ccb_h.status & CAM_STATUS_MASK) | if ((start_ccb->ccb_h.status & CAM_STATUS_MASK) | ||||
!= CAM_REQ_INPROG) | != CAM_REQ_INPROG) | ||||
Done Inline Actionsextra whitespace here cem: extra whitespace here | |||||
break; | break; | ||||
DELAY(100); | DELAY(100); | ||||
} | } | ||||
if (timeout == 0) { | if (timeout == 0) { | ||||
/* | /* | ||||
* XXX Is it worth adding a sim_timeout entry | * XXX Is it worth adding a sim_timeout entry | ||||
* point so we can attempt recovery? If | * point so we can attempt recovery? If | ||||
* this is only used for dumps, I don't think | * this is only used for dumps, I don't think | ||||
* it is. | * it is. | ||||
*/ | */ | ||||
start_ccb->ccb_h.status = CAM_CMD_TIMEOUT; | start_ccb->ccb_h.status = CAM_CMD_TIMEOUT; | ||||
} | } | ||||
} | |||||
void | |||||
xpt_polled_action(union ccb *start_ccb) | |||||
{ | |||||
uint32_t timeout; | |||||
struct cam_ed *dev; | |||||
Done Inline Actionsinconsistent whitespace cem: inconsistent whitespace | |||||
Not Done Inline ActionsIt's now consistent, but again, phab is having rendering issues. imp: It's now consistent, but again, phab is having rendering issues. | |||||
timeout = start_ccb->ccb_h.timeout * 10; | |||||
dev = start_ccb->ccb_h.path->device; | |||||
mtx_unlock(&dev->device_mtx); | |||||
timeout = xpt_poll_setup(start_ccb); | |||||
if (timeout > 0) { | |||||
xpt_action(start_ccb); | |||||
xpt_pollwait(start_ccb, timeout); | |||||
} else { | } else { | ||||
start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; | start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; | ||||
} | } | ||||
mtx_lock(&dev->device_mtx); | mtx_lock(&dev->device_mtx); | ||||
} | } | ||||
/* | /* | ||||
Show All 24 Lines | |||||
static int | static int | ||||
xpt_schedule_dev(struct camq *queue, cam_pinfo *pinfo, | xpt_schedule_dev(struct camq *queue, cam_pinfo *pinfo, | ||||
u_int32_t new_priority) | u_int32_t new_priority) | ||||
{ | { | ||||
int retval; | int retval; | ||||
u_int32_t old_priority; | u_int32_t old_priority; | ||||
CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_schedule_dev\n")); | CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_schedule_dev\n")); | ||||
old_priority = pinfo->priority; | old_priority = pinfo->priority; | ||||
/* | /* | ||||
* Are we already queued? | * Are we already queued? | ||||
*/ | */ | ||||
if (pinfo->index != CAM_UNQUEUED_INDEX) { | if (pinfo->index != CAM_UNQUEUED_INDEX) { | ||||
/* Simply reorder based on new priority */ | /* Simply reorder based on new priority */ | ||||
▲ Show 20 Lines • Show All 2,270 Lines • Show Last 20 Lines |
inconsistent whitespace here