Deleted Added
full compact
mpt.c (241874) mpt.c (274819)
1/*-
2 * Generic routines for LSI Fusion adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 82 unchanged lines hidden (view full) ---

91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98#include <sys/cdefs.h>
1/*-
2 * Generic routines for LSI Fusion adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 82 unchanged lines hidden (view full) ---

91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98#include <sys/cdefs.h>
99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 241874 2012-10-22 10:42:59Z marius $");
99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 274819 2014-11-21 21:01:24Z smh $");
100
101#include <dev/mpt/mpt.h>
102#include <dev/mpt/mpt_cam.h> /* XXX For static handler registration */
103#include <dev/mpt/mpt_raid.h> /* XXX For static handler registration */
104
105#include <dev/mpt/mpilib/mpi.h>
106#include <dev/mpt/mpilib/mpi_ioc.h>
107#include <dev/mpt/mpilib/mpi_fc.h>

--- 1207 unchanged lines hidden (view full) ---

1315 * 0 Request completed
1316 * non-0 Timeout fired before request completion.
1317 */
1318int
1319mpt_wait_req(struct mpt_softc *mpt, request_t *req,
1320 mpt_req_state_t state, mpt_req_state_t mask,
1321 int sleep_ok, int time_ms)
1322{
100
101#include <dev/mpt/mpt.h>
102#include <dev/mpt/mpt_cam.h> /* XXX For static handler registration */
103#include <dev/mpt/mpt_raid.h> /* XXX For static handler registration */
104
105#include <dev/mpt/mpilib/mpi.h>
106#include <dev/mpt/mpilib/mpi_ioc.h>
107#include <dev/mpt/mpilib/mpi_fc.h>

--- 1207 unchanged lines hidden (view full) ---

1315 * 0 Request completed
1316 * non-0 Timeout fired before request completion.
1317 */
1318int
1319mpt_wait_req(struct mpt_softc *mpt, request_t *req,
1320 mpt_req_state_t state, mpt_req_state_t mask,
1321 int sleep_ok, int time_ms)
1322{
1323 int error;
1324 int timeout;
1325 u_int saved_cnt;
1323 int timeout;
1324 u_int saved_cnt;
1325 sbintime_t sbt;
1326
1327 /*
1326
1327 /*
1328 * timeout is in ms. 0 indicates infinite wait.
1329 * Convert to ticks or 500us units depending on
1328 * time_ms is in ms, 0 indicates infinite wait.
1329 * Convert to sbintime_t or 500us units depending on
1330 * our sleep mode.
1331 */
1332 if (sleep_ok != 0) {
1330 * our sleep mode.
1331 */
1332 if (sleep_ok != 0) {
1333 timeout = (time_ms * hz) / 1000;
1333 sbt = SBT_1MS * time_ms;
1334 /* Set timeout as well so final timeout check works. */
1335 timeout = time_ms;
1334 } else {
1335 timeout = time_ms * 2;
1336 }
1337 req->state |= REQ_STATE_NEED_WAKEUP;
1338 mask &= ~REQ_STATE_NEED_WAKEUP;
1339 saved_cnt = mpt->reset_cnt;
1340 while ((req->state & mask) != state && mpt->reset_cnt == saved_cnt) {
1341 if (sleep_ok != 0) {
1336 } else {
1337 timeout = time_ms * 2;
1338 }
1339 req->state |= REQ_STATE_NEED_WAKEUP;
1340 mask &= ~REQ_STATE_NEED_WAKEUP;
1341 saved_cnt = mpt->reset_cnt;
1342 while ((req->state & mask) != state && mpt->reset_cnt == saved_cnt) {
1343 if (sleep_ok != 0) {
1342 error = mpt_sleep(mpt, req, PUSER, "mptreq", timeout);
1343 if (error == EWOULDBLOCK) {
1344 if (mpt_sleep(mpt, req, PUSER, "mptreq", sbt) ==
1345 EWOULDBLOCK) {
1344 timeout = 0;
1345 break;
1346 }
1347 } else {
1348 if (time_ms != 0 && --timeout == 0) {
1349 break;
1350 }
1351 DELAY(500);

--- 1797 unchanged lines hidden ---
1346 timeout = 0;
1347 break;
1348 }
1349 } else {
1350 if (time_ms != 0 && --timeout == 0) {
1351 break;
1352 }
1353 DELAY(500);

--- 1797 unchanged lines hidden ---