Deleted Added
full compact
29c29
< * $FreeBSD: head/sys/dev/twa/tw_osl_freebsd.c 208969 2010-06-09 21:40:38Z delphij $
---
> * $FreeBSD: head/sys/dev/twa/tw_osl_freebsd.c 212008 2010-08-30 19:15:04Z delphij $
177a178,180
> static TW_VOID twa_watchdog(TW_VOID *arg);
> int twa_setup_intr(struct twa_softc *sc);
> int twa_teardown_intr(struct twa_softc *sc);
240a244,246
> int twa_setup_intr(struct twa_softc *sc)
> {
> int error = 0;
241a248,255
> if (!(sc->intr_handle) && (sc->irq_res)) {
> error = bus_setup_intr(sc->bus_dev, sc->irq_res,
> INTR_TYPE_CAM | INTR_MPSAFE,
> NULL, twa_pci_intr,
> sc, &sc->intr_handle);
> }
> return( error );
> }
242a257,271
>
> int twa_teardown_intr(struct twa_softc *sc)
> {
> int error = 0;
>
> if ((sc->intr_handle) && (sc->irq_res)) {
> error = bus_teardown_intr(sc->bus_dev,
> sc->irq_res, sc->intr_handle);
> sc->intr_handle = NULL;
> }
> return( error );
> }
>
>
>
357,360c386
< if ((error = bus_setup_intr(sc->bus_dev, sc->irq_res,
< INTR_TYPE_CAM | INTR_MPSAFE,
< NULL, twa_pci_intr,
< sc, &sc->intr_handle))) {
---
> if ((error = twa_setup_intr(sc))) {
414a441,445
> sc->watchdog_index = 0;
> callout_init(&(sc->watchdog_callout[0]), CALLOUT_MPSAFE);
> callout_init(&(sc->watchdog_callout[1]), CALLOUT_MPSAFE);
> callout_reset(&(sc->watchdog_callout[0]), 5*hz, twa_watchdog, &sc->ctlr_handle);
>
418a450,461
> static TW_VOID
> twa_watchdog(TW_VOID *arg)
> {
> struct tw_cl_ctlr_handle *ctlr_handle =
> (struct tw_cl_ctlr_handle *)arg;
> struct twa_softc *sc = ctlr_handle->osl_ctlr_ctxt;
> int i;
> int i_need_a_reset = 0;
> int driver_is_active = 0;
> int my_watchdog_was_pending = 1234;
> TW_UINT64 current_time;
> struct tw_osli_req_context *my_req;
419a463,512
>
> //==============================================================================
> current_time = (TW_UINT64) (tw_osl_get_local_time());
>
> for (i = 0; i < TW_OSLI_MAX_NUM_REQUESTS; i++) {
> my_req = &(sc->req_ctx_buf[i]);
>
> if ((my_req->state == TW_OSLI_REQ_STATE_BUSY) &&
> (my_req->deadline) &&
> (my_req->deadline < current_time)) {
> tw_cl_set_reset_needed(ctlr_handle);
> #ifdef TW_OSL_DEBUG
> device_printf((sc)->bus_dev, "Request %d timed out! d = %p, c = %p\n", i, (void*)my_req->deadline, (void*)current_time);
> #else /* TW_OSL_DEBUG */
> device_printf((sc)->bus_dev, "Request %d timed out!\n", i);
> #endif /* TW_OSL_DEBUG */
> break;
> }
> }
> //==============================================================================
>
> i_need_a_reset = tw_cl_is_reset_needed(ctlr_handle);
>
> i = (int) ((sc->watchdog_index++) & 1);
>
> driver_is_active = tw_cl_is_active(ctlr_handle);
>
> if (i_need_a_reset) {
> #ifdef TW_OSL_DEBUG
> device_printf((sc)->bus_dev, "Watchdog rescheduled in 70 seconds\n");
> #endif /* TW_OSL_DEBUG */
> my_watchdog_was_pending =
> callout_reset(&(sc->watchdog_callout[i]), 70*hz, twa_watchdog, &sc->ctlr_handle);
> tw_cl_reset_ctlr(ctlr_handle);
> #ifdef TW_OSL_DEBUG
> device_printf((sc)->bus_dev, "Watchdog reset completed!\n");
> #endif /* TW_OSL_DEBUG */
> } else if (driver_is_active) {
> my_watchdog_was_pending =
> callout_reset(&(sc->watchdog_callout[i]), 5*hz, twa_watchdog, &sc->ctlr_handle);
> }
> #ifdef TW_OSL_DEBUG
> if (i_need_a_reset || my_watchdog_was_pending)
> device_printf((sc)->bus_dev, "i_need_a_reset = %d, "
> "driver_is_active = %d, my_watchdog_was_pending = %d\n",
> i_need_a_reset, driver_is_active, my_watchdog_was_pending);
> #endif /* TW_OSL_DEBUG */
> }
>
>
718,720c811
< if (sc->intr_handle)
< if ((error = bus_teardown_intr(sc->bus_dev,
< sc->irq_res, sc->intr_handle)))
---
> if ((error = twa_teardown_intr(sc)))
811a903,905
> /* Disconnect interrupts. */
> error = twa_teardown_intr(sc);
>
1000,1005c1094,1110
< tw_osli_printf(sc, "request = %p",
< TW_CL_SEVERITY_ERROR_STRING,
< TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
< 0x2018,
< "Passthru request timed out!",
< req);
---
> if (!(tw_cl_is_reset_needed(&(req->ctlr->ctlr_handle)))) {
> #ifdef TW_OSL_DEBUG
> tw_osli_printf(sc, "request = %p",
> TW_CL_SEVERITY_ERROR_STRING,
> TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
> 0x2018,
> "Passthru request timed out!",
> req);
> #else /* TW_OSL_DEBUG */
> device_printf((sc)->bus_dev, "Passthru request timed out!\n");
> #endif /* TW_OSL_DEBUG */
> tw_cl_reset_ctlr(&(req->ctlr->ctlr_handle));
> }
>
> error = 0;
> end_time = tw_osl_get_local_time() + timeout;
> continue;
1007,1012d1111
< * Should I check here if the timeout happened
< * because of yet another reset, and not do a
< * second reset?
< */
< tw_cl_reset_ctlr(&sc->ctlr_handle);
< /*
1014c1113
< * associated data) will already have been
---
> * associated data) will be
1017,1019d1115
< user_buf->driver_pkt.os_status = error;
< error = ETIMEDOUT;
< goto fw_passthru_err;
1026c1122
< }
---
> } /* End of while loop */
1040,1052d1135
< /*
< * Print the failure message. For some reason, on certain OS versions,
< * printing this error message during reset hangs the display (although
< * the rest of the system is running fine. So, don't print it if the
< * failure was due to a reset.
< */
< if ((error) && (error != TW_CL_ERR_REQ_BUS_RESET))
< tw_osli_printf(sc, "error = %d",
< TW_CL_SEVERITY_ERROR_STRING,
< TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
< 0x201A,
< "Firmware passthru failed!",
< error);
1053a1137,1139
> if (req_pkt->status == TW_CL_ERR_REQ_BUS_RESET)
> error = EBUSY;
>
1075a1162,1163
> struct tw_cl_req_packet *req_pkt =
> (struct tw_cl_req_packet *)(&req->req_pkt);
1122a1211,1213
> if (req_pkt->status == TW_CL_ERR_REQ_BUS_RESET)
> return;
>
1168a1260
> req->deadline = 0;
1209a1302,1306
> if (error == EINVAL) {
> req->error_code = error;
> return;
> }
>
1402a1500,1507
> tw_osli_printf(sc, "error = %d",
> TW_CL_SEVERITY_ERROR_STRING,
> TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
> 0x9999,
> "Failed to map DMA memory "
> "for I/O request",
> error);
> req->flags |= TW_OSLI_REQ_FLAGS_FAILED;