Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6: (23 commits)
[SCSI] sd: Avoid sending extended inquiry to legacy devices
[SCSI] libsas: fix wide port hotplug issues
[SCSI] libfc: fix a circular locking warning during sending RRQ
[SCSI] qla4xxx: Remove hiwat code so scsi eh does not get escalated when we can make progress
[SCSI] qla4xxx: Fix srb lookup in qla4xxx_eh_device_reset
[SCSI] qla4xxx: Fix Driver Fault Recovery Completion
[SCSI] qla4xxx: add timeout handler
[SCSI] qla4xxx: Correct Extended Sense Data Errors
[SCSI] libiscsi: disable bh in and abort handler.
[SCSI] zfcp: Fix tracing of request id for abort requests
[SCSI] zfcp: Fix wka port processing
[SCSI] zfcp: avoid double notify in lowmem scenario
[SCSI] zfcp: Add port only once to FC transport class
[SCSI] zfcp: Recover from stalled outbound queue
[SCSI] zfcp: Fix erp escalation procedure
[SCSI] zfcp: Fix logic for physical port close
[SCSI] zfcp: Use -EIO for SBAL allocation failures
[SCSI] zfcp: Use unchained mode for small ct and els requests
[SCSI] zfcp: Use correct flags for zfcp_erp_notify
[SCSI] zfcp: Return -ENOMEM for allocation failures in zfcp_fsf
...

+465 -273
+36 -32
drivers/s390/scsi/zfcp_erp.c
··· 553 553 _zfcp_erp_unit_reopen(unit, clear, id, ref); 554 554 } 555 555 556 - static void zfcp_erp_strategy_followup_actions(struct zfcp_erp_action *act) 556 + static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) 557 557 { 558 - struct zfcp_adapter *adapter = act->adapter; 559 - struct zfcp_port *port = act->port; 560 - struct zfcp_unit *unit = act->unit; 561 - u32 status = act->status; 562 - 563 - /* initiate follow-up actions depending on success of finished action */ 564 558 switch (act->action) { 565 - 566 559 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 567 - if (status == ZFCP_ERP_SUCCEEDED) 568 - _zfcp_erp_port_reopen_all(adapter, 0, "ersfa_1", NULL); 569 - else 570 - _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_2", NULL); 560 + _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1", NULL); 571 561 break; 572 - 573 562 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 574 - if (status == ZFCP_ERP_SUCCEEDED) 575 - _zfcp_erp_port_reopen(port, 0, "ersfa_3", NULL); 576 - else 577 - _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_4", NULL); 563 + _zfcp_erp_port_forced_reopen(act->port, 0, "ersff_2", NULL); 578 564 break; 579 - 580 565 case ZFCP_ERP_ACTION_REOPEN_PORT: 581 - if (status == ZFCP_ERP_SUCCEEDED) 582 - _zfcp_erp_unit_reopen_all(port, 0, "ersfa_5", NULL); 583 - else 584 - _zfcp_erp_port_forced_reopen(port, 0, "ersfa_6", NULL); 566 + _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL); 585 567 break; 586 - 587 568 case ZFCP_ERP_ACTION_REOPEN_UNIT: 588 - if (status != ZFCP_ERP_SUCCEEDED) 589 - _zfcp_erp_port_reopen(unit->port, 0, "ersfa_7", NULL); 569 + _zfcp_erp_unit_reopen(act->unit, 0, "ersff_4", NULL); 570 + break; 571 + } 572 + } 573 + 574 + static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act) 575 + { 576 + switch (act->action) { 577 + case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 578 + _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1", NULL); 579 + break; 580 + case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 581 + _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL); 582 + break; 583 + case ZFCP_ERP_ACTION_REOPEN_PORT: 584 + _zfcp_erp_unit_reopen_all(act->port, 0, "ersfs_3", NULL); 590 585 break; 591 586 } 592 587 } ··· 796 801 return ZFCP_ERP_FAILED; 797 802 798 803 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: 799 - if (status & ZFCP_STATUS_PORT_PHYS_OPEN) 804 + if (!(status & ZFCP_STATUS_PORT_PHYS_OPEN)) 800 805 return ZFCP_ERP_SUCCEEDED; 801 806 } 802 807 return ZFCP_ERP_FAILED; ··· 848 853 gid_pn_work); 849 854 850 855 retval = zfcp_fc_ns_gid_pn(&port->erp_action); 851 - if (retval == -ENOMEM) 852 - zfcp_erp_notify(&port->erp_action, ZFCP_ERP_NOMEM); 853 - port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; 854 - if (retval) 855 - zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); 856 + if (!retval) { 857 + port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; 858 + goto out; 859 + } 860 + if (retval == -ENOMEM) { 861 + zfcp_erp_notify(&port->erp_action, ZFCP_STATUS_ERP_LOWMEM); 862 + goto out; 863 + } 864 + /* all other error condtions */ 865 + zfcp_erp_notify(&port->erp_action, 0); 866 + out: 856 867 zfcp_port_put(port); 857 868 } 858 869 ··· 1290 1289 retval = zfcp_erp_strategy_statechange(erp_action, retval); 1291 1290 if (retval == ZFCP_ERP_EXIT) 1292 1291 goto unlock; 1293 - zfcp_erp_strategy_followup_actions(erp_action); 1292 + if (retval == ZFCP_ERP_SUCCEEDED) 1293 + zfcp_erp_strategy_followup_success(erp_action); 1294 + if (retval == ZFCP_ERP_FAILED) 1295 + zfcp_erp_strategy_followup_failed(erp_action); 1294 1296 1295 1297 unlock: 1296 1298 write_unlock(&adapter->erp_lock);
+3 -5
drivers/s390/scsi/zfcp_fc.c
··· 79 79 80 80 mutex_unlock(&wka_port->mutex); 81 81 82 - wait_event_timeout( 83 - wka_port->completion_wq, 84 - wka_port->status == ZFCP_WKA_PORT_ONLINE || 85 - wka_port->status == ZFCP_WKA_PORT_OFFLINE, 86 - HZ >> 1); 82 + wait_event(wka_port->completion_wq, 83 + wka_port->status == ZFCP_WKA_PORT_ONLINE || 84 + wka_port->status == ZFCP_WKA_PORT_OFFLINE); 87 85 88 86 if (wka_port->status == ZFCP_WKA_PORT_ONLINE) { 89 87 atomic_inc(&wka_port->refcount);
+38 -18
drivers/s390/scsi/zfcp_fsf.c
··· 670 670 zfcp_fsf_sbal_check(adapter), 5 * HZ); 671 671 if (ret > 0) 672 672 return 0; 673 - if (!ret) 673 + if (!ret) { 674 674 atomic_inc(&adapter->qdio_outb_full); 675 + /* assume hanging outbound queue, try queue recovery */ 676 + zfcp_erp_adapter_reopen(adapter, 0, "fsrsg_1", NULL); 677 + } 675 678 676 679 spin_lock_bh(&adapter->req_q_lock); 677 680 return -EIO; ··· 725 722 req = zfcp_fsf_alloc_qtcb(pool); 726 723 727 724 if (unlikely(!req)) 728 - return ERR_PTR(-EIO); 725 + return ERR_PTR(-ENOMEM); 729 726 730 727 if (adapter->req_no == 0) 731 728 adapter->req_no++; ··· 1013 1010 send_ct->handler(send_ct->handler_data); 1014 1011 } 1015 1012 1013 + static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale, 1014 + struct scatterlist *sg_req, 1015 + struct scatterlist *sg_resp) 1016 + { 1017 + sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; 1018 + sbale[2].addr = sg_virt(sg_req); 1019 + sbale[2].length = sg_req->length; 1020 + sbale[3].addr = sg_virt(sg_resp); 1021 + sbale[3].length = sg_resp->length; 1022 + sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; 1023 + } 1024 + 1025 + static int zfcp_fsf_one_sbal(struct scatterlist *sg) 1026 + { 1027 + return sg_is_last(sg) && sg->length <= PAGE_SIZE; 1028 + } 1029 + 1016 1030 static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, 1017 1031 struct scatterlist *sg_req, 1018 1032 struct scatterlist *sg_resp, ··· 1040 1020 int bytes; 1041 1021 1042 1022 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) { 1043 - if (sg_req->length > PAGE_SIZE || sg_resp->length > PAGE_SIZE || 1044 - !sg_is_last(sg_req) || !sg_is_last(sg_resp)) 1023 + if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp)) 1045 1024 return -EOPNOTSUPP; 1046 1025 1047 - sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; 1048 - sbale[2].addr = sg_virt(sg_req); 1049 - sbale[2].length = sg_req->length; 1050 - sbale[3].addr = sg_virt(sg_resp); 1051 - sbale[3].length = sg_resp->length; 1052 - sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; 1026 + zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 1027 + return 0; 1028 + } 1029 + 1030 + /* use single, unchained SBAL if it can hold the request */ 1031 + if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) { 1032 + zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp); 1053 1033 return 0; 1054 1034 } 1055 1035 1056 1036 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ, 1057 1037 sg_req, max_sbals); 1058 1038 if (bytes <= 0) 1059 - return -ENOMEM; 1039 + return -EIO; 1060 1040 req->qtcb->bottom.support.req_buf_length = bytes; 1061 1041 req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1062 1042 1063 1043 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ, 1064 1044 sg_resp, max_sbals); 1065 1045 if (bytes <= 0) 1066 - return -ENOMEM; 1046 + return -EIO; 1067 1047 req->qtcb->bottom.support.resp_buf_length = bytes; 1068 1048 1069 1049 return 0; ··· 1627 1607 case FSF_ACCESS_DENIED: 1628 1608 wka_port->status = ZFCP_WKA_PORT_OFFLINE; 1629 1609 break; 1630 - case FSF_PORT_ALREADY_OPEN: 1631 - break; 1632 1610 case FSF_GOOD: 1633 1611 wka_port->handle = header->port_handle; 1612 + /* fall through */ 1613 + case FSF_PORT_ALREADY_OPEN: 1634 1614 wka_port->status = ZFCP_WKA_PORT_ONLINE; 1635 1615 } 1636 1616 out: ··· 1751 1731 zfcp_fsf_access_denied_port(req, port); 1752 1732 break; 1753 1733 case FSF_PORT_BOXED: 1754 - zfcp_erp_port_boxed(port, "fscpph2", req); 1755 - req->status |= ZFCP_STATUS_FSFREQ_ERROR | 1756 - ZFCP_STATUS_FSFREQ_RETRY; 1757 1734 /* can't use generic zfcp_erp_modify_port_status because 1758 1735 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ 1759 1736 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); 1760 1737 list_for_each_entry(unit, &port->unit_list_head, list) 1761 1738 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, 1762 1739 &unit->status); 1740 + zfcp_erp_port_boxed(port, "fscpph2", req); 1741 + req->status |= ZFCP_STATUS_FSFREQ_ERROR | 1742 + ZFCP_STATUS_FSFREQ_RETRY; 1743 + 1763 1744 break; 1764 1745 case FSF_ADAPTER_STATUS_AVAILABLE: 1765 1746 switch (header->fsf_status_qual.word[0]) { ··· 2562 2541 bytes = zfcp_qdio_sbals_from_sg(req, direction, fsf_cfdc->sg, 2563 2542 FSF_MAX_SBALS_PER_REQ); 2564 2543 if (bytes != ZFCP_CFDC_MAX_SIZE) { 2565 - retval = -ENOMEM; 2566 2544 zfcp_fsf_req_free(req); 2567 2545 goto out; 2568 2546 }
+16 -9
drivers/s390/scsi/zfcp_scsi.c
··· 167 167 struct zfcp_unit *unit = scpnt->device->hostdata; 168 168 struct zfcp_fsf_req *old_req, *abrt_req; 169 169 unsigned long flags; 170 - unsigned long old_req_id = (unsigned long) scpnt->host_scribble; 170 + unsigned long old_reqid = (unsigned long) scpnt->host_scribble; 171 171 int retval = SUCCESS; 172 172 int retry = 3; 173 + char *dbf_tag; 173 174 174 175 /* avoid race condition between late normal completion and abort */ 175 176 write_lock_irqsave(&adapter->abort_lock, flags); 176 177 177 178 spin_lock(&adapter->req_list_lock); 178 - old_req = zfcp_reqlist_find(adapter, old_req_id); 179 + old_req = zfcp_reqlist_find(adapter, old_reqid); 179 180 spin_unlock(&adapter->req_list_lock); 180 181 if (!old_req) { 181 182 write_unlock_irqrestore(&adapter->abort_lock, flags); 182 183 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL, 183 - old_req_id); 184 + old_reqid); 184 185 return FAILED; /* completion could be in progress */ 185 186 } 186 187 old_req->data = NULL; ··· 190 189 write_unlock_irqrestore(&adapter->abort_lock, flags); 191 190 192 191 while (retry--) { 193 - abrt_req = zfcp_fsf_abort_fcp_command(old_req_id, unit); 192 + abrt_req = zfcp_fsf_abort_fcp_command(old_reqid, unit); 194 193 if (abrt_req) 195 194 break; 196 195 ··· 198 197 if (!(atomic_read(&adapter->status) & 199 198 ZFCP_STATUS_COMMON_RUNNING)) { 200 199 zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL, 201 - old_req_id); 200 + old_reqid); 202 201 return SUCCESS; 203 202 } 204 203 } ··· 209 208 abrt_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 210 209 211 210 if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) 212 - zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, abrt_req, 0); 211 + dbf_tag = "okay"; 213 212 else if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) 214 - zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, abrt_req, 0); 213 + dbf_tag = "lte2"; 215 214 else { 216 - zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, abrt_req, 0); 215 + dbf_tag = "fail"; 217 216 retval = FAILED; 218 217 } 218 + zfcp_scsi_dbf_event_abort(dbf_tag, adapter, scpnt, abrt_req, old_reqid); 219 219 zfcp_fsf_req_free(abrt_req); 220 220 return retval; 221 221 } ··· 536 534 struct fc_rport_identifiers ids; 537 535 struct fc_rport *rport; 538 536 537 + if (port->rport) 538 + return; 539 + 539 540 ids.node_name = port->wwnn; 540 541 ids.port_name = port->wwpn; 541 542 ids.port_id = port->d_id; ··· 562 557 { 563 558 struct fc_rport *rport = port->rport; 564 559 565 - if (rport) 560 + if (rport) { 566 561 fc_remote_port_delete(rport); 562 + port->rport = NULL; 563 + } 567 564 } 568 565 569 566 void zfcp_scsi_schedule_rport_register(struct zfcp_port *port)
+6 -1
drivers/s390/scsi/zfcp_sysfs.c
··· 494 494 struct Scsi_Host *scsi_host = class_to_shost(dev); 495 495 struct zfcp_adapter *adapter = 496 496 (struct zfcp_adapter *) scsi_host->hostdata[0]; 497 + u64 util; 498 + 499 + spin_lock_bh(&adapter->qdio_stat_lock); 500 + util = adapter->req_q_util; 501 + spin_unlock_bh(&adapter->qdio_stat_lock); 497 502 498 503 return sprintf(buf, "%d %llu\n", atomic_read(&adapter->qdio_outb_full), 499 - (unsigned long long)adapter->req_q_util); 504 + (unsigned long long)util); 500 505 } 501 506 static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL); 502 507
+15 -8
drivers/scsi/libfc/fc_exch.c
··· 415 415 e_stat = ep->esb_stat; 416 416 if (e_stat & ESB_ST_COMPLETE) { 417 417 ep->esb_stat = e_stat & ~ESB_ST_REC_QUAL; 418 + spin_unlock_bh(&ep->ex_lock); 418 419 if (e_stat & ESB_ST_REC_QUAL) 419 420 fc_exch_rrq(ep); 420 - spin_unlock_bh(&ep->ex_lock); 421 421 goto done; 422 422 } else { 423 423 resp = ep->resp; ··· 1624 1624 struct fc_lport *lp; 1625 1625 struct fc_els_rrq *rrq; 1626 1626 struct fc_frame *fp; 1627 - struct fc_seq *rrq_sp; 1628 1627 u32 did; 1629 1628 1630 1629 lp = ep->lp; 1631 1630 1632 1631 fp = fc_frame_alloc(lp, sizeof(*rrq)); 1633 1632 if (!fp) 1634 - return; 1633 + goto retry; 1634 + 1635 1635 rrq = fc_frame_payload_get(fp, sizeof(*rrq)); 1636 1636 memset(rrq, 0, sizeof(*rrq)); 1637 1637 rrq->rrq_cmd = ELS_RRQ; ··· 1647 1647 fc_host_port_id(lp->host), FC_TYPE_ELS, 1648 1648 FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); 1649 1649 1650 - rrq_sp = fc_exch_seq_send(lp, fp, fc_exch_rrq_resp, NULL, ep, 1651 - lp->e_d_tov); 1652 - if (!rrq_sp) { 1653 - ep->esb_stat |= ESB_ST_REC_QUAL; 1654 - fc_exch_timer_set_locked(ep, ep->r_a_tov); 1650 + if (fc_exch_seq_send(lp, fp, fc_exch_rrq_resp, NULL, ep, lp->e_d_tov)) 1651 + return; 1652 + 1653 + retry: 1654 + spin_lock_bh(&ep->ex_lock); 1655 + if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) { 1656 + spin_unlock_bh(&ep->ex_lock); 1657 + /* drop hold for rec qual */ 1658 + fc_exch_release(ep); 1655 1659 return; 1656 1660 } 1661 + ep->esb_stat |= ESB_ST_REC_QUAL; 1662 + fc_exch_timer_set_locked(ep, ep->r_a_tov); 1663 + spin_unlock_bh(&ep->ex_lock); 1657 1664 } 1658 1665 1659 1666
+2 -2
drivers/scsi/libiscsi.c
··· 1974 1974 * good and have never sent us a successful tmf response 1975 1975 * then sent more data for the cmd. 1976 1976 */ 1977 - spin_lock(&session->lock); 1977 + spin_lock_bh(&session->lock); 1978 1978 fail_scsi_task(task, DID_ABORT); 1979 1979 conn->tmf_state = TMF_INITIAL; 1980 - spin_unlock(&session->lock); 1980 + spin_unlock_bh(&session->lock); 1981 1981 iscsi_start_tx(conn); 1982 1982 goto success_unlocked; 1983 1983 case TMF_TIMEDOUT:
+107 -40
drivers/scsi/libsas/sas_expander.c
··· 766 766 if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, 767 767 SAS_ADDR_SIZE) && ephy->port) { 768 768 sas_port_add_phy(ephy->port, phy->phy); 769 + phy->port = ephy->port; 769 770 phy->phy_state = PHY_DEVICE_DISCOVERED; 770 771 return 0; 771 772 } ··· 946 945 if (ex->ex_phy[i].phy_state == PHY_VACANT || 947 946 ex->ex_phy[i].phy_state == PHY_NOT_PRESENT) 948 947 continue; 949 - 948 + /* 949 + * Due to races, the phy might not get added to the 950 + * wide port, so we add the phy to the wide port here. 951 + */ 950 952 if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) == 951 - SAS_ADDR(child->sas_addr)) 953 + SAS_ADDR(child->sas_addr)) { 952 954 ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED; 955 + res = sas_ex_join_wide_port(dev, i); 956 + if (!res) 957 + SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n", 958 + i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr)); 959 + 960 + } 953 961 } 962 + res = 0; 954 963 } 955 964 956 965 return res; ··· 1609 1598 } 1610 1599 1611 1600 static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id, 1612 - int from_phy) 1601 + int from_phy, bool update) 1613 1602 { 1614 1603 struct expander_device *ex = &dev->ex_dev; 1615 1604 int res = 0; ··· 1622 1611 if (res) 1623 1612 goto out; 1624 1613 else if (phy_change_count != ex->ex_phy[i].phy_change_count) { 1625 - ex->ex_phy[i].phy_change_count = phy_change_count; 1614 + if (update) 1615 + ex->ex_phy[i].phy_change_count = 1616 + phy_change_count; 1626 1617 *phy_id = i; 1627 1618 return 0; 1628 1619 } ··· 1666 1653 kfree(rg_req); 1667 1654 return res; 1668 1655 } 1656 + /** 1657 + * sas_find_bcast_dev - find the device issue BROADCAST(CHANGE). 1658 + * @dev:domain device to be detect. 1659 + * @src_dev: the device which originated BROADCAST(CHANGE). 1660 + * 1661 + * Add self-configuration expander suport. Suppose two expander cascading, 1662 + * when the first level expander is self-configuring, hotplug the disks in 1663 + * second level expander, BROADCAST(CHANGE) will not only be originated 1664 + * in the second level expander, but also be originated in the first level 1665 + * expander (see SAS protocol SAS 2r-14, 7.11 for detail), it is to say, 1666 + * expander changed count in two level expanders will all increment at least 1667 + * once, but the phy which chang count has changed is the source device which 1668 + * we concerned. 1669 + */ 1669 1670 1670 1671 static int sas_find_bcast_dev(struct domain_device *dev, 1671 1672 struct domain_device **src_dev) 1672 1673 { 1673 1674 struct expander_device *ex = &dev->ex_dev; 1674 1675 int ex_change_count = -1; 1676 + int phy_id = -1; 1675 1677 int res; 1678 + struct domain_device *ch; 1676 1679 1677 1680 res = sas_get_ex_change_count(dev, &ex_change_count); 1678 1681 if (res) 1679 1682 goto out; 1680 - if (ex_change_count != -1 && 1681 - ex_change_count != ex->ex_change_count) { 1682 - *src_dev = dev; 1683 - ex->ex_change_count = ex_change_count; 1684 - } else { 1685 - struct domain_device *ch; 1686 - 1687 - list_for_each_entry(ch, &ex->children, siblings) { 1688 - if (ch->dev_type == EDGE_DEV || 1689 - ch->dev_type == FANOUT_DEV) { 1690 - res = sas_find_bcast_dev(ch, src_dev); 1691 - if (src_dev) 1692 - return res; 1693 - } 1683 + if (ex_change_count != -1 && ex_change_count != ex->ex_change_count) { 1684 + /* Just detect if this expander phys phy change count changed, 1685 + * in order to determine if this expander originate BROADCAST, 1686 + * and do not update phy change count field in our structure. 1687 + */ 1688 + res = sas_find_bcast_phy(dev, &phy_id, 0, false); 1689 + if (phy_id != -1) { 1690 + *src_dev = dev; 1691 + ex->ex_change_count = ex_change_count; 1692 + SAS_DPRINTK("Expander phy change count has changed\n"); 1693 + return res; 1694 + } else 1695 + SAS_DPRINTK("Expander phys DID NOT change\n"); 1696 + } 1697 + list_for_each_entry(ch, &ex->children, siblings) { 1698 + if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) { 1699 + res = sas_find_bcast_dev(ch, src_dev); 1700 + if (src_dev) 1701 + return res; 1694 1702 } 1695 1703 } 1696 1704 out: ··· 1734 1700 } 1735 1701 1736 1702 static void sas_unregister_devs_sas_addr(struct domain_device *parent, 1737 - int phy_id) 1703 + int phy_id, bool last) 1738 1704 { 1739 1705 struct expander_device *ex_dev = &parent->ex_dev; 1740 1706 struct ex_phy *phy = &ex_dev->ex_phy[phy_id]; 1741 1707 struct domain_device *child, *n; 1742 - 1743 - list_for_each_entry_safe(child, n, &ex_dev->children, siblings) { 1744 - if (SAS_ADDR(child->sas_addr) == 1745 - SAS_ADDR(phy->attached_sas_addr)) { 1746 - if (child->dev_type == EDGE_DEV || 1747 - child->dev_type == FANOUT_DEV) 1748 - sas_unregister_ex_tree(child); 1749 - else 1750 - sas_unregister_dev(child); 1751 - break; 1708 + if (last) { 1709 + list_for_each_entry_safe(child, n, 1710 + &ex_dev->children, siblings) { 1711 + if (SAS_ADDR(child->sas_addr) == 1712 + SAS_ADDR(phy->attached_sas_addr)) { 1713 + if (child->dev_type == EDGE_DEV || 1714 + child->dev_type == FANOUT_DEV) 1715 + sas_unregister_ex_tree(child); 1716 + else 1717 + sas_unregister_dev(child); 1718 + break; 1719 + } 1752 1720 } 1721 + sas_disable_routing(parent, phy->attached_sas_addr); 1753 1722 } 1754 - sas_disable_routing(parent, phy->attached_sas_addr); 1755 1723 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 1756 1724 sas_port_delete_phy(phy->port, phy->phy); 1757 1725 if (phy->port->num_phys == 0) ··· 1806 1770 { 1807 1771 struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id]; 1808 1772 struct domain_device *child; 1809 - int res; 1773 + bool found = false; 1774 + int res, i; 1810 1775 1811 1776 SAS_DPRINTK("ex %016llx phy%d new device attached\n", 1812 1777 SAS_ADDR(dev->sas_addr), phy_id); 1813 1778 res = sas_ex_phy_discover(dev, phy_id); 1814 1779 if (res) 1815 1780 goto out; 1781 + /* to support the wide port inserted */ 1782 + for (i = 0; i < dev->ex_dev.num_phys; i++) { 1783 + struct ex_phy *ex_phy_temp = &dev->ex_dev.ex_phy[i]; 1784 + if (i == phy_id) 1785 + continue; 1786 + if (SAS_ADDR(ex_phy_temp->attached_sas_addr) == 1787 + SAS_ADDR(ex_phy->attached_sas_addr)) { 1788 + found = true; 1789 + break; 1790 + } 1791 + } 1792 + if (found) { 1793 + sas_ex_join_wide_port(dev, phy_id); 1794 + return 0; 1795 + } 1816 1796 res = sas_ex_discover_devices(dev, phy_id); 1817 - if (res) 1797 + if (!res) 1818 1798 goto out; 1819 1799 list_for_each_entry(child, &dev->ex_dev.children, siblings) { 1820 1800 if (SAS_ADDR(child->sas_addr) == ··· 1845 1793 return res; 1846 1794 } 1847 1795 1848 - static int sas_rediscover_dev(struct domain_device *dev, int phy_id) 1796 + static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) 1849 1797 { 1850 1798 struct expander_device *ex = &dev->ex_dev; 1851 1799 struct ex_phy *phy = &ex->ex_phy[phy_id]; ··· 1856 1804 switch (res) { 1857 1805 case SMP_RESP_NO_PHY: 1858 1806 phy->phy_state = PHY_NOT_PRESENT; 1859 - sas_unregister_devs_sas_addr(dev, phy_id); 1807 + sas_unregister_devs_sas_addr(dev, phy_id, last); 1860 1808 goto out; break; 1861 1809 case SMP_RESP_PHY_VACANT: 1862 1810 phy->phy_state = PHY_VACANT; 1863 - sas_unregister_devs_sas_addr(dev, phy_id); 1811 + sas_unregister_devs_sas_addr(dev, phy_id, last); 1864 1812 goto out; break; 1865 1813 case SMP_RESP_FUNC_ACC: 1866 1814 break; ··· 1868 1816 1869 1817 if (SAS_ADDR(attached_sas_addr) == 0) { 1870 1818 phy->phy_state = PHY_EMPTY; 1871 - sas_unregister_devs_sas_addr(dev, phy_id); 1819 + sas_unregister_devs_sas_addr(dev, phy_id, last); 1872 1820 } else if (SAS_ADDR(attached_sas_addr) == 1873 1821 SAS_ADDR(phy->attached_sas_addr)) { 1874 1822 SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter\n", ··· 1880 1828 return res; 1881 1829 } 1882 1830 1831 + /** 1832 + * sas_rediscover - revalidate the domain. 1833 + * @dev:domain device to be detect. 1834 + * @phy_id: the phy id will be detected. 1835 + * 1836 + * NOTE: this process _must_ quit (return) as soon as any connection 1837 + * errors are encountered. Connection recovery is done elsewhere. 1838 + * Discover process only interrogates devices in order to discover the 1839 + * domain.For plugging out, we un-register the device only when it is 1840 + * the last phy in the port, for other phys in this port, we just delete it 1841 + * from the port.For inserting, we do discovery when it is the 1842 + * first phy,for other phys in this port, we add it to the port to 1843 + * forming the wide-port. 1844 + */ 1883 1845 static int sas_rediscover(struct domain_device *dev, const int phy_id) 1884 1846 { 1885 1847 struct expander_device *ex = &dev->ex_dev; 1886 1848 struct ex_phy *changed_phy = &ex->ex_phy[phy_id]; 1887 1849 int res = 0; 1888 1850 int i; 1851 + bool last = true; /* is this the last phy of the port */ 1889 1852 1890 1853 SAS_DPRINTK("ex %016llx phy%d originated BROADCAST(CHANGE)\n", 1891 1854 SAS_ADDR(dev->sas_addr), phy_id); ··· 1915 1848 SAS_ADDR(changed_phy->attached_sas_addr)) { 1916 1849 SAS_DPRINTK("phy%d part of wide port with " 1917 1850 "phy%d\n", phy_id, i); 1918 - goto out; 1851 + last = false; 1852 + break; 1919 1853 } 1920 1854 } 1921 - res = sas_rediscover_dev(dev, phy_id); 1855 + res = sas_rediscover_dev(dev, phy_id, last); 1922 1856 } else 1923 1857 res = sas_discover_new(dev, phy_id); 1924 - out: 1925 1858 return res; 1926 1859 } 1927 1860 ··· 1948 1881 1949 1882 do { 1950 1883 phy_id = -1; 1951 - res = sas_find_bcast_phy(dev, &phy_id, i); 1884 + res = sas_find_bcast_phy(dev, &phy_id, i, true); 1952 1885 if (phy_id == -1) 1953 1886 break; 1954 1887 res = sas_rediscover(dev, phy_id);
+15 -4
drivers/scsi/libsas/sas_port.c
··· 56 56 } 57 57 } 58 58 59 - /* find a port */ 59 + /* see if the phy should be part of a wide port */ 60 60 spin_lock_irqsave(&sas_ha->phy_port_lock, flags); 61 61 for (i = 0; i < sas_ha->num_phys; i++) { 62 62 port = sas_ha->sas_port[i]; ··· 69 69 SAS_DPRINTK("phy%d matched wide port%d\n", phy->id, 70 70 port->id); 71 71 break; 72 - } else if (*(u64 *) port->sas_addr == 0 && port->num_phys==0) { 73 - memcpy(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE); 74 - break; 75 72 } 76 73 spin_unlock(&port->phy_list_lock); 74 + } 75 + /* The phy does not match any existing port, create a new one */ 76 + if (i == sas_ha->num_phys) { 77 + for (i = 0; i < sas_ha->num_phys; i++) { 78 + port = sas_ha->sas_port[i]; 79 + spin_lock(&port->phy_list_lock); 80 + if (*(u64 *)port->sas_addr == 0 81 + && port->num_phys == 0) { 82 + memcpy(port->sas_addr, phy->sas_addr, 83 + SAS_ADDR_SIZE); 84 + break; 85 + } 86 + spin_unlock(&port->phy_list_lock); 87 + } 77 88 } 78 89 79 90 if (i >= sas_ha->num_phys) {
+7 -8
drivers/scsi/qla4xxx/ql4_dbg.c
··· 15 15 uint32_t cnt; 16 16 uint8_t *c = b; 17 17 18 - printk(" 0 1 2 3 4 5 6 7 8 9 Ah Bh Ch Dh Eh " 18 + printk(" 0 1 2 3 4 5 6 7 8 9 Ah Bh Ch Dh Eh " 19 19 "Fh\n"); 20 20 printk("------------------------------------------------------------" 21 21 "--\n"); 22 - for (cnt = 0; cnt < size; cnt++, c++) { 23 - printk(KERN_DEBUG "%02x", *c); 24 - if (!(cnt % 16)) 25 - printk(KERN_DEBUG "\n"); 22 + for (cnt = 0; cnt < size; c++) { 23 + printk(KERN_INFO "%02x", *c); 24 + if (!(++cnt % 16)) 25 + printk(KERN_INFO "\n"); 26 26 27 27 else 28 - printk(KERN_DEBUG " "); 28 + printk(KERN_INFO " "); 29 29 } 30 - if (cnt % 16) 31 - printk(KERN_DEBUG "\n"); 30 + printk(KERN_INFO "\n"); 32 31 } 33 32
+7 -2
drivers/scsi/qla4xxx/ql4_def.h
··· 100 100 #define MAX_SRBS MAX_CMDS_TO_RISC 101 101 #define MBOX_AEN_REG_COUNT 5 102 102 #define MAX_INIT_RETRIES 5 103 - #define IOCB_HIWAT_CUSHION 16 104 103 105 104 /* 106 105 * Buffer sizes ··· 183 184 uint16_t cc_stat; 184 185 u_long r_start; /* Time we recieve a cmd from OS */ 185 186 u_long u_start; /* Time when we handed the cmd to F/W */ 187 + 188 + /* Used for extended sense / status continuation */ 189 + uint8_t *req_sense_ptr; 190 + uint16_t req_sense_len; 191 + uint16_t reserved2; 186 192 }; 187 193 188 194 /* ··· 306 302 uint32_t tot_ddbs; 307 303 308 304 uint16_t iocb_cnt; 309 - uint16_t iocb_hiwat; 310 305 311 306 /* SRB cache. */ 312 307 #define SRB_MIN_REQ 128 ··· 439 436 /* Map ddb_list entry by FW ddb index */ 440 437 struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES]; 441 438 439 + /* Saved srb for status continuation entry processing */ 440 + struct srb *status_srb; 442 441 }; 443 442 444 443 static inline int is_qla4010(struct scsi_qla_host *ha)
+7
drivers/scsi/qla4xxx/ql4_fw.h
··· 572 572 *************************************************************************/ 573 573 #define IOCB_MAX_CDB_LEN 16 /* Bytes in a CBD */ 574 574 #define IOCB_MAX_SENSEDATA_LEN 32 /* Bytes of sense data */ 575 + #define IOCB_MAX_EXT_SENSEDATA_LEN 60 /* Bytes of extended sense data */ 575 576 576 577 /* IOCB header structure */ 577 578 struct qla4_header { ··· 732 731 uint32_t maxCmdSeqNum; /* 1C-1F */ 733 732 uint8_t senseData[IOCB_MAX_SENSEDATA_LEN]; /* 20-3F */ 734 733 734 + }; 735 + 736 + /* Status Continuation entry */ 737 + struct status_cont_entry { 738 + struct qla4_header hdr; /* 00-03 */ 739 + uint8_t ext_sense_data[IOCB_MAX_EXT_SENSEDATA_LEN]; /* 04-63 */ 735 740 }; 736 741 737 742 struct passthru0 {
+60 -73
drivers/scsi/qla4xxx/ql4_iocb.c
··· 10 10 #include "ql4_dbg.h" 11 11 #include "ql4_inline.h" 12 12 13 - 14 13 #include <scsi/scsi_tcq.h> 14 + 15 + static int 16 + qla4xxx_space_in_req_ring(struct scsi_qla_host *ha, uint16_t req_cnt) 17 + { 18 + uint16_t cnt; 19 + 20 + /* Calculate number of free request entries. */ 21 + if ((req_cnt + 2) >= ha->req_q_count) { 22 + cnt = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out); 23 + if (ha->request_in < cnt) 24 + ha->req_q_count = cnt - ha->request_in; 25 + else 26 + ha->req_q_count = REQUEST_QUEUE_DEPTH - 27 + (ha->request_in - cnt); 28 + } 29 + 30 + /* Check if room for request in request ring. */ 31 + if ((req_cnt + 2) < ha->req_q_count) 32 + return 1; 33 + else 34 + return 0; 35 + } 36 + 37 + static void qla4xxx_advance_req_ring_ptr(struct scsi_qla_host *ha) 38 + { 39 + /* Advance request queue pointer */ 40 + if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) { 41 + ha->request_in = 0; 42 + ha->request_ptr = ha->request_ring; 43 + } else { 44 + ha->request_in++; 45 + ha->request_ptr++; 46 + } 47 + } 15 48 16 49 /** 17 50 * qla4xxx_get_req_pkt - returns a valid entry in request queue. ··· 59 26 static int qla4xxx_get_req_pkt(struct scsi_qla_host *ha, 60 27 struct queue_entry **queue_entry) 61 28 { 62 - uint16_t request_in; 63 - uint8_t status = QLA_SUCCESS; 29 + uint16_t req_cnt = 1; 64 30 65 - *queue_entry = ha->request_ptr; 66 - 67 - /* get the latest request_in and request_out index */ 68 - request_in = ha->request_in; 69 - ha->request_out = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out); 70 - 71 - /* Advance request queue pointer and check for queue full */ 72 - if (request_in == (REQUEST_QUEUE_DEPTH - 1)) { 73 - request_in = 0; 74 - ha->request_ptr = ha->request_ring; 75 - } else { 76 - request_in++; 77 - ha->request_ptr++; 78 - } 79 - 80 - /* request queue is full, try again later */ 81 - if ((ha->iocb_cnt + 1) >= ha->iocb_hiwat) { 82 - /* restore request pointer */ 83 - ha->request_ptr = *queue_entry; 84 - status = QLA_ERROR; 85 - } else { 86 - ha->request_in = request_in; 31 + if (qla4xxx_space_in_req_ring(ha, req_cnt)) { 32 + *queue_entry = ha->request_ptr; 87 33 memset(*queue_entry, 0, sizeof(**queue_entry)); 34 + 35 + qla4xxx_advance_req_ring_ptr(ha); 36 + ha->req_q_count -= req_cnt; 37 + return QLA_SUCCESS; 88 38 } 89 39 90 - return status; 40 + return QLA_ERROR; 91 41 } 92 42 93 43 /** ··· 116 100 return status; 117 101 } 118 102 119 - static struct continuation_t1_entry* qla4xxx_alloc_cont_entry( 120 - struct scsi_qla_host *ha) 103 + static struct continuation_t1_entry * 104 + qla4xxx_alloc_cont_entry(struct scsi_qla_host *ha) 121 105 { 122 106 struct continuation_t1_entry *cont_entry; 123 107 124 108 cont_entry = (struct continuation_t1_entry *)ha->request_ptr; 125 109 126 - /* Advance request queue pointer */ 127 - if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) { 128 - ha->request_in = 0; 129 - ha->request_ptr = ha->request_ring; 130 - } else { 131 - ha->request_in++; 132 - ha->request_ptr++; 133 - } 110 + qla4xxx_advance_req_ring_ptr(ha); 134 111 135 112 /* Load packet defaults */ 136 113 cont_entry->hdr.entryType = ET_CONTINUE; ··· 206 197 struct scsi_cmnd *cmd = srb->cmd; 207 198 struct ddb_entry *ddb_entry; 208 199 struct command_t3_entry *cmd_entry; 209 - 210 200 int nseg; 211 201 uint16_t tot_dsds; 212 202 uint16_t req_cnt; 213 - 214 203 unsigned long flags; 215 - uint16_t cnt; 216 204 uint32_t index; 217 205 char tag[2]; 218 206 ··· 223 217 224 218 index = (uint32_t)cmd->request->tag; 225 219 220 + /* 221 + * Check to see if adapter is online before placing request on 222 + * request queue. If a reset occurs and a request is in the queue, 223 + * the firmware will still attempt to process the request, retrieving 224 + * garbage for pointers. 225 + */ 226 + if (!test_bit(AF_ONLINE, &ha->flags)) { 227 + DEBUG2(printk("scsi%ld: %s: Adapter OFFLINE! " 228 + "Do not issue command.\n", 229 + ha->host_no, __func__)); 230 + goto queuing_error; 231 + } 232 + 226 233 /* Calculate the number of request entries needed. */ 227 234 nseg = scsi_dma_map(cmd); 228 235 if (nseg < 0) ··· 243 224 tot_dsds = nseg; 244 225 245 226 req_cnt = qla4xxx_calc_request_entries(tot_dsds); 246 - 247 - if (ha->req_q_count < (req_cnt + 2)) { 248 - cnt = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out); 249 - if (ha->request_in < cnt) 250 - ha->req_q_count = cnt - ha->request_in; 251 - else 252 - ha->req_q_count = REQUEST_QUEUE_DEPTH - 253 - (ha->request_in - cnt); 254 - } 255 - 256 - if (ha->req_q_count < (req_cnt + 2)) 227 + if (!qla4xxx_space_in_req_ring(ha, req_cnt)) 257 228 goto queuing_error; 258 229 259 230 /* total iocbs active */ ··· 295 286 break; 296 287 } 297 288 298 - 299 - /* Advance request queue pointer */ 300 - ha->request_in++; 301 - if (ha->request_in == REQUEST_QUEUE_DEPTH) { 302 - ha->request_in = 0; 303 - ha->request_ptr = ha->request_ring; 304 - } else 305 - ha->request_ptr++; 306 - 307 - 289 + qla4xxx_advance_req_ring_ptr(ha); 308 290 qla4xxx_build_scsi_iocbs(srb, cmd_entry, tot_dsds); 309 291 wmb(); 310 - 311 - /* 312 - * Check to see if adapter is online before placing request on 313 - * request queue. If a reset occurs and a request is in the queue, 314 - * the firmware will still attempt to process the request, retrieving 315 - * garbage for pointers. 316 - */ 317 - if (!test_bit(AF_ONLINE, &ha->flags)) { 318 - DEBUG2(printk("scsi%ld: %s: Adapter OFFLINE! " 319 - "Do not issue command.\n", 320 - ha->host_no, __func__)); 321 - goto queuing_error; 322 - } 323 292 324 293 srb->cmd->host_scribble = (unsigned char *)srb; 325 294
+100 -45
drivers/scsi/qla4xxx/ql4_isr.c
··· 11 11 #include "ql4_inline.h" 12 12 13 13 /** 14 + * qla4xxx_copy_sense - copy sense data into cmd sense buffer 15 + * @ha: Pointer to host adapter structure. 16 + * @sts_entry: Pointer to status entry structure. 17 + * @srb: Pointer to srb structure. 18 + **/ 19 + static void qla4xxx_copy_sense(struct scsi_qla_host *ha, 20 + struct status_entry *sts_entry, 21 + struct srb *srb) 22 + { 23 + struct scsi_cmnd *cmd = srb->cmd; 24 + uint16_t sense_len; 25 + 26 + memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 27 + sense_len = le16_to_cpu(sts_entry->senseDataByteCnt); 28 + if (sense_len == 0) 29 + return; 30 + 31 + /* Save total available sense length, 32 + * not to exceed cmd's sense buffer size */ 33 + sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE); 34 + srb->req_sense_ptr = cmd->sense_buffer; 35 + srb->req_sense_len = sense_len; 36 + 37 + /* Copy sense from sts_entry pkt */ 38 + sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN); 39 + memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len); 40 + 41 + DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, " 42 + "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no, 43 + cmd->device->channel, cmd->device->id, 44 + cmd->device->lun, __func__, 45 + sts_entry->senseData[2] & 0x0f, 46 + sts_entry->senseData[7], 47 + sts_entry->senseData[12], 48 + sts_entry->senseData[13])); 49 + 50 + DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len)); 51 + srb->flags |= SRB_GOT_SENSE; 52 + 53 + /* Update srb, in case a sts_cont pkt follows */ 54 + srb->req_sense_ptr += sense_len; 55 + srb->req_sense_len -= sense_len; 56 + if (srb->req_sense_len != 0) 57 + ha->status_srb = srb; 58 + else 59 + ha->status_srb = NULL; 60 + } 61 + 62 + /** 63 + * qla4xxx_status_cont_entry - Process a Status Continuations entry. 64 + * @ha: SCSI driver HA context 65 + * @sts_cont: Entry pointer 66 + * 67 + * Extended sense data. 68 + */ 69 + static void 70 + qla4xxx_status_cont_entry(struct scsi_qla_host *ha, 71 + struct status_cont_entry *sts_cont) 72 + { 73 + struct srb *srb = ha->status_srb; 74 + struct scsi_cmnd *cmd; 75 + uint8_t sense_len; 76 + 77 + if (srb == NULL) 78 + return; 79 + 80 + cmd = srb->cmd; 81 + if (cmd == NULL) { 82 + DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned " 83 + "back to OS srb=%p srb->state:%d\n", ha->host_no, 84 + __func__, srb, srb->state)); 85 + ha->status_srb = NULL; 86 + return; 87 + } 88 + 89 + /* Copy sense data. */ 90 + sense_len = min_t(uint16_t, srb->req_sense_len, 91 + IOCB_MAX_EXT_SENSEDATA_LEN); 92 + memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len); 93 + DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len)); 94 + 95 + srb->req_sense_ptr += sense_len; 96 + srb->req_sense_len -= sense_len; 97 + 98 + /* Place command on done queue. */ 99 + if (srb->req_sense_len == 0) { 100 + qla4xxx_srb_compl(ha, srb); 101 + ha->status_srb = NULL; 102 + } 103 + } 104 + 105 + /** 14 106 * qla4xxx_status_entry - processes status IOCBs 15 107 * @ha: Pointer to host adapter structure. 16 108 * @sts_entry: Pointer to status entry structure. ··· 115 23 struct srb *srb; 116 24 struct ddb_entry *ddb_entry; 117 25 uint32_t residual; 118 - uint16_t sensebytecnt; 119 26 120 27 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle)); 121 28 if (!srb) { ··· 183 92 break; 184 93 185 94 /* Copy Sense Data into sense buffer. */ 186 - memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 187 - 188 - sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt); 189 - if (sensebytecnt == 0) 190 - break; 191 - 192 - memcpy(cmd->sense_buffer, sts_entry->senseData, 193 - min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE)); 194 - 195 - DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, " 196 - "ASC/ASCQ = %02x/%02x\n", ha->host_no, 197 - cmd->device->channel, cmd->device->id, 198 - cmd->device->lun, __func__, 199 - sts_entry->senseData[2] & 0x0f, 200 - sts_entry->senseData[12], 201 - sts_entry->senseData[13])); 202 - 203 - srb->flags |= SRB_GOT_SENSE; 95 + qla4xxx_copy_sense(ha, sts_entry, srb); 204 96 break; 205 97 206 98 case SCS_INCOMPLETE: ··· 250 176 break; 251 177 252 178 /* Copy Sense Data into sense buffer. */ 253 - memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 254 - 255 - sensebytecnt = 256 - le16_to_cpu(sts_entry->senseDataByteCnt); 257 - if (sensebytecnt == 0) 258 - break; 259 - 260 - memcpy(cmd->sense_buffer, sts_entry->senseData, 261 - min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE)); 262 - 263 - DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, " 264 - "ASC/ASCQ = %02x/%02x\n", ha->host_no, 265 - cmd->device->channel, cmd->device->id, 266 - cmd->device->lun, __func__, 267 - sts_entry->senseData[2] & 0x0f, 268 - sts_entry->senseData[12], 269 - sts_entry->senseData[13])); 179 + qla4xxx_copy_sense(ha, sts_entry, srb); 270 180 } else { 271 181 /* 272 182 * If RISC reports underrun and target does not ··· 326 268 327 269 status_entry_exit: 328 270 329 - /* complete the request */ 271 + /* complete the request, if not waiting for status_continuation pkt */ 330 272 srb->cc_stat = sts_entry->completionStatus; 331 - qla4xxx_srb_compl(ha, srb); 273 + if (ha->status_srb == NULL) 274 + qla4xxx_srb_compl(ha, srb); 332 275 } 333 276 334 277 /** ··· 364 305 /* process entry */ 365 306 switch (sts_entry->hdr.entryType) { 366 307 case ET_STATUS: 367 - /* 368 - * Common status - Single completion posted in single 369 - * IOSB. 370 - */ 308 + /* Common status */ 371 309 qla4xxx_status_entry(ha, sts_entry); 372 310 break; 373 311 ··· 372 316 break; 373 317 374 318 case ET_STATUS_CONTINUATION: 375 - /* Just throw away the status continuation entries */ 376 - DEBUG2(printk("scsi%ld: %s: Status Continuation entry " 377 - "- ignoring\n", ha->host_no, __func__)); 319 + qla4xxx_status_cont_entry(ha, 320 + (struct status_cont_entry *) sts_entry); 378 321 break; 379 322 380 323 case ET_COMMAND:
-10
drivers/scsi/qla4xxx/ql4_mbx.c
··· 385 385 mbox_sts[0])); 386 386 return QLA_ERROR; 387 387 } 388 - 389 - /* High-water mark of IOCBs */ 390 - ha->iocb_hiwat = mbox_sts[2]; 391 - if (ha->iocb_hiwat > IOCB_HIWAT_CUSHION) 392 - ha->iocb_hiwat -= IOCB_HIWAT_CUSHION; 393 - else 394 - dev_info(&ha->pdev->dev, "WARNING!!! You have less than %d " 395 - "firmware IOCBs available (%d).\n", 396 - IOCB_HIWAT_CUSHION, ha->iocb_hiwat); 397 - 398 388 return QLA_SUCCESS; 399 389 } 400 390
+27 -13
drivers/scsi/qla4xxx/ql4_os.c
··· 66 66 static int qla4xxx_host_get_param(struct Scsi_Host *shost, 67 67 enum iscsi_host_param param, char *buf); 68 68 static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session); 69 + static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc); 69 70 70 71 /* 71 72 * SCSI host template entry points ··· 90 89 .eh_device_reset_handler = qla4xxx_eh_device_reset, 91 90 .eh_target_reset_handler = qla4xxx_eh_target_reset, 92 91 .eh_host_reset_handler = qla4xxx_eh_host_reset, 92 + .eh_timed_out = qla4xxx_eh_cmd_timed_out, 93 93 94 94 .slave_configure = qla4xxx_slave_configure, 95 95 .slave_alloc = qla4xxx_slave_alloc, ··· 125 123 }; 126 124 127 125 static struct scsi_transport_template *qla4xxx_scsi_transport; 126 + 127 + static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc) 128 + { 129 + struct iscsi_cls_session *session; 130 + struct ddb_entry *ddb_entry; 131 + 132 + session = starget_to_session(scsi_target(sc->device)); 133 + ddb_entry = session->dd_data; 134 + 135 + /* if we are not logged in then the LLD is going to clean up the cmd */ 136 + if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) 137 + return BLK_EH_RESET_TIMER; 138 + else 139 + return BLK_EH_NOT_HANDLED; 140 + } 128 141 129 142 static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session) 130 143 { ··· 921 904 /* Flush any pending ddb changed AENs */ 922 905 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); 923 906 907 + qla4xxx_flush_active_srbs(ha); 908 + 924 909 /* Reset the firmware. If successful, function 925 910 * returns with ISP interrupts enabled. 926 911 */ 927 - if (status == QLA_SUCCESS) { 928 - DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 929 - ha->host_no, __func__)); 930 - qla4xxx_flush_active_srbs(ha); 931 - if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) 932 - status = qla4xxx_soft_reset(ha); 933 - else 934 - status = QLA_ERROR; 935 - } 912 + DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 913 + ha->host_no, __func__)); 914 + if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) 915 + status = qla4xxx_soft_reset(ha); 916 + else 917 + status = QLA_ERROR; 936 918 937 919 /* Flush any pending ddb changed AENs */ 938 920 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); ··· 1543 1527 { 1544 1528 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); 1545 1529 struct ddb_entry *ddb_entry = cmd->device->hostdata; 1546 - struct srb *sp; 1547 1530 int ret = FAILED, stat; 1548 1531 1549 - sp = (struct srb *) cmd->SCp.ptr; 1550 - if (!sp || !ddb_entry) 1532 + if (!ddb_entry) 1551 1533 return ret; 1552 1534 1553 1535 dev_info(&ha->pdev->dev, ··· 1658 1644 ha = (struct scsi_qla_host *) cmd->device->host->hostdata; 1659 1645 1660 1646 dev_info(&ha->pdev->dev, 1661 - "scsi(%ld:%d:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, 1647 + "scsi(%ld:%d:%d:%d): HOST RESET ISSUED.\n", ha->host_no, 1662 1648 cmd->device->channel, cmd->device->id, cmd->device->lun); 1663 1649 1664 1650 if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
+1 -1
drivers/scsi/qla4xxx/ql4_version.h
··· 5 5 * See LICENSE.qla4xxx for copyright and licensing details. 6 6 */ 7 7 8 - #define QLA4XXX_DRIVER_VERSION "5.01.00-k8" 8 + #define QLA4XXX_DRIVER_VERSION "5.01.00-k9" 9 9
+18 -2
drivers/scsi/sd.c
··· 1840 1840 kfree(buffer); 1841 1841 } 1842 1842 1843 + static int sd_try_extended_inquiry(struct scsi_device *sdp) 1844 + { 1845 + /* 1846 + * Although VPD inquiries can go to SCSI-2 type devices, 1847 + * some USB ones crash on receiving them, and the pages 1848 + * we currently ask for are for SPC-3 and beyond 1849 + */ 1850 + if (sdp->scsi_level > SCSI_SPC_2) 1851 + return 1; 1852 + return 0; 1853 + } 1854 + 1843 1855 /** 1844 1856 * sd_revalidate_disk - called the first time a new disk is seen, 1845 1857 * performs disk spin up, read_capacity, etc. ··· 1889 1877 */ 1890 1878 if (sdkp->media_present) { 1891 1879 sd_read_capacity(sdkp, buffer); 1892 - sd_read_block_limits(sdkp); 1893 - sd_read_block_characteristics(sdkp); 1880 + 1881 + if (sd_try_extended_inquiry(sdp)) { 1882 + sd_read_block_limits(sdkp); 1883 + sd_read_block_characteristics(sdkp); 1884 + } 1885 + 1894 1886 sd_read_write_protect_flag(sdkp, buffer); 1895 1887 sd_read_cache_type(sdkp, buffer); 1896 1888 sd_read_app_tag_own(sdkp, buffer);