aha.c (122340) | aha.c (122360) |
---|---|
1/* 2 * Generic register and struct definitions for the Adaptech 154x/164x 3 * SCSI host adapters. Product specific probe and attach routines can 4 * be found in: 5 * aha 1540/1542B/1542C/1542CF/1542CP aha_isa.c 6 * 7 * Copyright (c) 1998 M. Warner Losh. 8 * All Rights Reserved. --- 43 unchanged lines hidden (view full) --- 52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 * SUCH DAMAGE. 57 */ 58 59#include <sys/cdefs.h> | 1/* 2 * Generic register and struct definitions for the Adaptech 154x/164x 3 * SCSI host adapters. Product specific probe and attach routines can 4 * be found in: 5 * aha 1540/1542B/1542C/1542CF/1542CP aha_isa.c 6 * 7 * Copyright (c) 1998 M. Warner Losh. 8 * All Rights Reserved. --- 43 unchanged lines hidden (view full) --- 52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 * SUCH DAMAGE. 57 */ 58 59#include <sys/cdefs.h> |
60__FBSDID("$FreeBSD: head/sys/dev/aha/aha.c 122340 2003-11-09 00:51:52Z imp $"); | 60__FBSDID("$FreeBSD: head/sys/dev/aha/aha.c 122360 2003-11-09 17:16:39Z imp $"); |
61 62#include <sys/param.h> 63#include <sys/systm.h> 64#include <sys/malloc.h> 65#include <sys/kernel.h> 66#include <sys/lock.h> 67#include <sys/mutex.h> 68 --- 336 unchanged lines hidden (view full) --- 405 */ 406 if (PROBABLY_NEW_BOARD(aha->boardid) || 407 (aha->boardid == 0x41 408 && aha->fw_major == 0x31 && 409 aha->fw_minor >= 0x34)) { 410 error = aha_cmd(aha, AOP_RETURN_EXT_BIOS_INFO, NULL, 411 /*paramlen*/0, (u_char *)&extbios, sizeof(extbios), 412 DEFAULT_CMD_TIMEOUT); | 61 62#include <sys/param.h> 63#include <sys/systm.h> 64#include <sys/malloc.h> 65#include <sys/kernel.h> 66#include <sys/lock.h> 67#include <sys/mutex.h> 68 --- 336 unchanged lines hidden (view full) --- 405 */ 406 if (PROBABLY_NEW_BOARD(aha->boardid) || 407 (aha->boardid == 0x41 408 && aha->fw_major == 0x31 && 409 aha->fw_minor >= 0x34)) { 410 error = aha_cmd(aha, AOP_RETURN_EXT_BIOS_INFO, NULL, 411 /*paramlen*/0, (u_char *)&extbios, sizeof(extbios), 412 DEFAULT_CMD_TIMEOUT); |
413 if (error != 0) { 414 printf("%s: AOP_RETURN_EXT_BIOS_INFO - Failed.", 415 aha_name(aha)); 416 return (error); 417 } |
|
413 error = aha_cmd(aha, AOP_MBOX_IF_ENABLE, (uint8_t *)&extbios, 414 /*paramlen*/2, NULL, 0, DEFAULT_CMD_TIMEOUT); | 418 error = aha_cmd(aha, AOP_MBOX_IF_ENABLE, (uint8_t *)&extbios, 419 /*paramlen*/2, NULL, 0, DEFAULT_CMD_TIMEOUT); |
420 if (error != 0) { 421 printf("%s: AOP_MBOX_IF_ENABLE - Failed.", 422 aha_name(aha)); 423 return (error); 424 } |
|
415 } 416 if (aha->boardid < 0x41) 417 printf("%s: Warning: aha-1542A won't likely work.\n", 418 aha_name(aha)); 419 420 aha->max_sg = 17; /* Need >= 17 to do 64k I/O */ 421 aha->diff_bus = 0; 422 aha->extended_lun = 0; --- 1049 unchanged lines hidden (view full) --- 1472 1473 if ((status & DATAIN_REG_READY) != 0) 1474 printf("%s: ahareset - Host Adapter Error " 1475 "code = 0x%x\n", aha_name(aha), 1476 aha_inb(aha, DATAIN_REG)); 1477 return (ENXIO); 1478 } 1479 | 425 } 426 if (aha->boardid < 0x41) 427 printf("%s: Warning: aha-1542A won't likely work.\n", 428 aha_name(aha)); 429 430 aha->max_sg = 17; /* Need >= 17 to do 64k I/O */ 431 aha->diff_bus = 0; 432 aha->extended_lun = 0; --- 1049 unchanged lines hidden (view full) --- 1482 1483 if ((status & DATAIN_REG_READY) != 0) 1484 printf("%s: ahareset - Host Adapter Error " 1485 "code = 0x%x\n", aha_name(aha), 1486 aha_inb(aha, DATAIN_REG)); 1487 return (ENXIO); 1488 } 1489 |
1480 /* If we've allocated mailboxes, initialize them */ 1481 if (aha->init_level > 4) 1482 ahainitmboxes(aha); 1483 | |
1484 /* If we've attached to the XPT, tell it about the event */ 1485 if (aha->path != NULL) 1486 xpt_async(AC_BUS_RESET, aha->path, NULL); 1487 1488 /* 1489 * Perform completion processing for all outstanding CCBs. 1490 */ 1491 while ((ccb_h = LIST_FIRST(&aha->pending_ccbs)) != NULL) { 1492 struct aha_ccb *pending_accb; 1493 1494 pending_accb = (struct aha_ccb *)ccb_h->ccb_accb_ptr; 1495 pending_accb->hccb.ahastat = AHASTAT_HA_SCSI_BUS_RESET; 1496 ahadone(aha, pending_accb, AMBI_ERROR); 1497 } 1498 | 1490 /* If we've attached to the XPT, tell it about the event */ 1491 if (aha->path != NULL) 1492 xpt_async(AC_BUS_RESET, aha->path, NULL); 1493 1494 /* 1495 * Perform completion processing for all outstanding CCBs. 1496 */ 1497 while ((ccb_h = LIST_FIRST(&aha->pending_ccbs)) != NULL) { 1498 struct aha_ccb *pending_accb; 1499 1500 pending_accb = (struct aha_ccb *)ccb_h->ccb_accb_ptr; 1501 pending_accb->hccb.ahastat = AHASTAT_HA_SCSI_BUS_RESET; 1502 ahadone(aha, pending_accb, AMBI_ERROR); 1503 } 1504 |
1505 /* If we've allocated mailboxes, initialize them */ 1506 /* Must be done after we've aborted our queue, or aha_cmd fails */ 1507 if (aha->init_level > 4) 1508 ahainitmboxes(aha); 1509 |
|
1499 return (0); 1500} 1501 1502/* 1503 * Send a command to the adapter. 1504 */ 1505int 1506aha_cmd(struct aha_softc *aha, aha_op_t opcode, uint8_t *params, --- 18 unchanged lines hidden (view full) --- 1525 error = 0; 1526 1527 /* 1528 * All commands except for the "start mailbox" and the "enable 1529 * outgoing mailbox read interrupt" commands cannot be issued 1530 * while there are pending transactions. Freeze our SIMQ 1531 * and wait for all completions to occur if necessary. 1532 */ | 1510 return (0); 1511} 1512 1513/* 1514 * Send a command to the adapter. 1515 */ 1516int 1517aha_cmd(struct aha_softc *aha, aha_op_t opcode, uint8_t *params, --- 18 unchanged lines hidden (view full) --- 1536 error = 0; 1537 1538 /* 1539 * All commands except for the "start mailbox" and the "enable 1540 * outgoing mailbox read interrupt" commands cannot be issued 1541 * while there are pending transactions. Freeze our SIMQ 1542 * and wait for all completions to occur if necessary. 1543 */ |
1533 timeout = 100000; | 1544 timeout = 10000; |
1534 s = splcam(); 1535 while (LIST_FIRST(&aha->pending_ccbs) != NULL && --timeout) { 1536 /* Fire the interrupt handler in case interrupts are blocked */ 1537 aha_intr(aha); 1538 splx(s); | 1545 s = splcam(); 1546 while (LIST_FIRST(&aha->pending_ccbs) != NULL && --timeout) { 1547 /* Fire the interrupt handler in case interrupts are blocked */ 1548 aha_intr(aha); 1549 splx(s); |
1539 DELAY(100); | 1550 DELAY(10); |
1540 s = splcam(); 1541 } 1542 splx(s); 1543 1544 if (timeout == 0) { 1545 printf("%s: aha_cmd: Timeout waiting for adapter idle\n", 1546 aha_name(aha)); 1547 return (ETIMEDOUT); --- 287 unchanged lines hidden (view full) --- 1835static void 1836ahatimeout(void *arg) 1837{ 1838 struct aha_ccb *accb; 1839 union ccb *ccb; 1840 struct aha_softc *aha; 1841 int s; 1842 uint32_t paddr; | 1551 s = splcam(); 1552 } 1553 splx(s); 1554 1555 if (timeout == 0) { 1556 printf("%s: aha_cmd: Timeout waiting for adapter idle\n", 1557 aha_name(aha)); 1558 return (ETIMEDOUT); --- 287 unchanged lines hidden (view full) --- 1846static void 1847ahatimeout(void *arg) 1848{ 1849 struct aha_ccb *accb; 1850 union ccb *ccb; 1851 struct aha_softc *aha; 1852 int s; 1853 uint32_t paddr; |
1854 struct ccb_hdr *ccb_h; |
|
1843 1844 accb = (struct aha_ccb *)arg; 1845 ccb = accb->ccb; 1846 aha = (struct aha_softc *)ccb->ccb_h.ccb_aha_ptr; 1847 xpt_print_path(ccb->ccb_h.path); 1848 printf("CCB %p - timed out\n", (void *)accb); 1849 1850 s = splcam(); --- 12 unchanged lines hidden (view full) --- 1863 * the list of pending CCBs and remove their timeouts. This 1864 * means that the driver attempts to clear only one error 1865 * condition at a time. In general, timeouts that occur 1866 * close together are related anyway, so there is no benefit 1867 * in attempting to handle errors in parrallel. Timeouts will 1868 * be reinstated when the recovery process ends. 1869 */ 1870 if ((accb->flags & ACCB_DEVICE_RESET) == 0) { | 1855 1856 accb = (struct aha_ccb *)arg; 1857 ccb = accb->ccb; 1858 aha = (struct aha_softc *)ccb->ccb_h.ccb_aha_ptr; 1859 xpt_print_path(ccb->ccb_h.path); 1860 printf("CCB %p - timed out\n", (void *)accb); 1861 1862 s = splcam(); --- 12 unchanged lines hidden (view full) --- 1875 * the list of pending CCBs and remove their timeouts. This 1876 * means that the driver attempts to clear only one error 1877 * condition at a time. In general, timeouts that occur 1878 * close together are related anyway, so there is no benefit 1879 * in attempting to handle errors in parrallel. Timeouts will 1880 * be reinstated when the recovery process ends. 1881 */ 1882 if ((accb->flags & ACCB_DEVICE_RESET) == 0) { |
1871 struct ccb_hdr *ccb_h; 1872 | |
1873 if ((accb->flags & ACCB_RELEASE_SIMQ) == 0) { 1874 xpt_freeze_simq(aha->sim, /*count*/1); 1875 accb->flags |= ACCB_RELEASE_SIMQ; 1876 } 1877 1878 ccb_h = LIST_FIRST(&aha->pending_ccbs); 1879 while (ccb_h != NULL) { 1880 struct aha_ccb *pending_accb; --- 61 unchanged lines hidden --- | 1883 if ((accb->flags & ACCB_RELEASE_SIMQ) == 0) { 1884 xpt_freeze_simq(aha->sim, /*count*/1); 1885 accb->flags |= ACCB_RELEASE_SIMQ; 1886 } 1887 1888 ccb_h = LIST_FIRST(&aha->pending_ccbs); 1889 while (ccb_h != NULL) { 1890 struct aha_ccb *pending_accb; --- 61 unchanged lines hidden --- |