/** * lpm_adjust - adjust path mask * @lpm: path mask to adjust * @mask: mask of available paths * * Shift @lpm right until @lpm and @mask have at least one bit in common or * until @lpm is zero. Return the resulting lpm.
*/ int lpm_adjust(int lpm, int mask)
{ while (lpm && ((lpm & mask) == 0))
lpm >>= 1; return lpm;
}
/* * Adjust path mask to use next path and reset retry count. Return resulting * path mask.
*/ static u16 ccwreq_next_path(struct ccw_device *cdev)
{ struct ccw_request *req = &cdev->private->req;
/* * Clean up device state and report to callback.
*/ staticvoid ccwreq_stop(struct ccw_device *cdev, int rc)
{ struct ccw_request *req = &cdev->private->req;
/** * ccw_request_cancel - cancel running I/O request * @cdev: ccw device * * Cancel the I/O request specified by cdev->req. Return non-zero if request * has already finished, zero otherwise.
*/ int ccw_request_cancel(struct ccw_device *cdev)
{ struct subchannel *sch = to_subchannel(cdev->dev.parent); struct ccw_request *req = &cdev->private->req; int rc;
if (req->done) return 1;
req->cancel = 1;
rc = cio_clear(sch); if (rc)
ccwreq_stop(cdev, rc); return 0;
}
/* * Return the status of the internal I/O started on the specified ccw device. * Perform BASIC SENSE if required.
*/ staticenum io_status ccwreq_status(struct ccw_device *cdev, struct irb *lcirb)
{ struct irb *irb = &cdev->private->dma_area->irb; struct cmd_scsw *scsw = &irb->scsw.cmd; enum uc_todo todo;
/* Perform BASIC SENSE if needed. */ if (ccw_device_accumulate_and_sense(cdev, lcirb)) return IO_RUNNING; /* Check for halt/clear interrupt. */ if (scsw->fctl & (SCSW_FCTL_HALT_FUNC | SCSW_FCTL_CLEAR_FUNC)) return IO_KILLED; /* Check for path error. */ if (scsw->cc == 3 || scsw->pno) return IO_PATH_ERROR; /* Handle BASIC SENSE data. */ if (irb->esw.esw0.erw.cons) {
CIO_TRACE_EVENT(2, "sensedata");
CIO_HEX_EVENT(2, &cdev->private->dev_id, sizeof(struct ccw_dev_id));
CIO_HEX_EVENT(2, &cdev->private->dma_area->irb.ecw,
SENSE_MAX_COUNT); /* Check for command reject. */ if (irb->ecw[0] & SNS0_CMD_REJECT) return IO_REJECTED; /* Ask the driver what to do */ if (cdev->drv && cdev->drv->uc_handler) {
todo = cdev->drv->uc_handler(cdev, lcirb);
CIO_TRACE_EVENT(2, "uc_response");
CIO_HEX_EVENT(2, &todo, sizeof(todo)); switch (todo) { case UC_TODO_RETRY: return IO_STATUS_ERROR; case UC_TODO_RETRY_ON_NEW_PATH: return IO_PATH_ERROR; case UC_TODO_STOP: return IO_REJECTED; default: return IO_STATUS_ERROR;
}
} /* Assume that unexpected SENSE data implies an error. */ return IO_STATUS_ERROR;
} /* Check for channel errors. */ if (scsw->cstat != 0) return IO_STATUS_ERROR; /* Check for device errors. */ if (scsw->dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) return IO_STATUS_ERROR; /* Check for final state. */ if (!(scsw->dstat & DEV_STAT_DEV_END)) return IO_RUNNING; /* Check for other improper status. */ if (scsw->cc == 1 && (scsw->stctl & SCSW_STCTL_ALERT_STATUS)) return IO_STATUS_ERROR; return IO_DONE;
}
/* Check status of I/O request. */
status = ccwreq_status(cdev, irb); if (req->filter)
status = req->filter(cdev, req->data, irb, status); if (status != IO_RUNNING)
ccw_device_set_timeout(cdev, 0); if (status != IO_DONE && status != IO_RUNNING)
ccwreq_log_status(cdev, status); switch (status) { case IO_DONE: break; case IO_RUNNING: return; case IO_REJECTED: goto err; case IO_PATH_ERROR: goto out_next_path; case IO_STATUS_ERROR: goto out_restart; case IO_KILLED: /* Check if request was cancelled on purpose. */ if (req->cancel) {
rc = -EIO; goto err;
} goto out_restart;
} /* Check back with request initiator. */ if (!req->check) goto out; switch (req->check(cdev, req->data)) { case 0: break; case -EAGAIN: goto out_restart; case -EACCES: goto out_next_path; default: goto err;
}
out:
ccwreq_stop(cdev, 0); return;
out_next_path: /* Try next path and restart I/O. */ if (!ccwreq_next_path(cdev)) {
rc = -EACCES; goto err;
}
out_restart: /* Restart. */
ccwreq_do(cdev); return;
err:
ccwreq_stop(cdev, rc);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.