Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull more SCSI updates from James Bottomley:
"This series is all the stragglers that didn't quite make the first
merge window pull. It's mostly minor updates and bug fixes of merge
window code but it also has two driver updates: ufs and qla2xxx"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (46 commits)
scsi: scsi_debug: Don't call kcalloc() if size arg is zero
scsi: core: Remove command size deduction from scsi_setup_scsi_cmnd()
scsi: scsi_ioctl: Validate command size
scsi: ufs: ufshpb: Properly handle max-single-cmd
scsi: core: Avoid leaving shost->last_reset with stale value if EH does not run
scsi: bsg: Fix errno when scsi_bsg_register_queue() fails
scsi: sr: Remove duplicate assignment
scsi: ufs: ufs-exynos: Introduce ExynosAuto v9 virtual host
scsi: ufs: ufs-exynos: Multi-host configuration for ExynosAuto v9
scsi: ufs: ufs-exynos: Support ExynosAuto v9 UFS
scsi: ufs: ufs-exynos: Add pre/post_hce_enable drv callbacks
scsi: ufs: ufs-exynos: Factor out priv data init
scsi: ufs: ufs-exynos: Add EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR option
scsi: ufs: ufs-exynos: Support custom version of ufs_hba_variant_ops
scsi: ufs: ufs-exynos: Add setup_clocks callback
scsi: ufs: ufs-exynos: Add refclkout_stop control
scsi: ufs: ufs-exynos: Simplify drv_data retrieval
scsi: ufs: ufs-exynos: Change pclk available max value
scsi: ufs: Add quirk to enable host controller without PH configuration
scsi: ufs: Add quirk to handle broken UIC command
...

+916 -379
+4 -5
drivers/scsi/elx/libefc_sli/sli4.c
··· 4145 4145 sli_get_read_config(struct sli4 *sli4) 4146 4146 { 4147 4147 struct sli4_rsp_read_config *conf = sli4->bmbx.virt; 4148 - u32 i, total, total_size; 4148 + u32 i, total; 4149 4149 u32 *base; 4150 4150 4151 4151 if (sli_cmd_read_config(sli4, sli4->bmbx.virt)) { ··· 4203 4203 4204 4204 for (i = 0; i < SLI4_RSRC_MAX; i++) { 4205 4205 total = sli4->ext[i].number * sli4->ext[i].size; 4206 - total_size = BITS_TO_LONGS(total) * sizeof(long); 4207 - sli4->ext[i].use_map = kzalloc(total_size, GFP_KERNEL); 4206 + sli4->ext[i].use_map = bitmap_zalloc(total, GFP_KERNEL); 4208 4207 if (!sli4->ext[i].use_map) { 4209 4208 efc_log_err(sli4, "bitmap memory allocation failed %d\n", 4210 4209 i); ··· 4742 4743 sli4->ext[0].base = NULL; 4743 4744 4744 4745 for (i = 0; i < SLI4_RSRC_MAX; i++) { 4745 - kfree(sli4->ext[i].use_map); 4746 + bitmap_free(sli4->ext[i].use_map); 4746 4747 sli4->ext[i].use_map = NULL; 4747 4748 sli4->ext[i].base = NULL; 4748 4749 } ··· 4783 4784 for (i = 0; i < SLI4_RSRC_MAX; i++) { 4784 4785 sli4->ext[i].base = NULL; 4785 4786 4786 - kfree(sli4->ext[i].use_map); 4787 + bitmap_free(sli4->ext[i].use_map); 4787 4788 sli4->ext[i].use_map = NULL; 4788 4789 } 4789 4790
+1
drivers/scsi/hosts.c
··· 388 388 shost->shost_state = SHOST_CREATED; 389 389 INIT_LIST_HEAD(&shost->__devices); 390 390 INIT_LIST_HEAD(&shost->__targets); 391 + INIT_LIST_HEAD(&shost->eh_abort_list); 391 392 INIT_LIST_HEAD(&shost->eh_cmd_q); 392 393 INIT_LIST_HEAD(&shost->starved_list); 393 394 init_waitqueue_head(&shost->host_wait);
+6 -1
drivers/scsi/qla2xxx/qla_attr.c
··· 2762 2762 if (fcport->loop_id != FC_NO_LOOP_ID) 2763 2763 fcport->logout_on_delete = 1; 2764 2764 2765 - qlt_schedule_sess_for_deletion(fcport); 2765 + if (!EDIF_NEGOTIATION_PENDING(fcport)) { 2766 + ql_dbg(ql_dbg_disc, fcport->vha, 0x911e, 2767 + "%s %d schedule session deletion\n", __func__, 2768 + __LINE__); 2769 + qlt_schedule_sess_for_deletion(fcport); 2770 + } 2766 2771 } else { 2767 2772 qla2x00_port_logout(fcport->vha, fcport); 2768 2773 }
+2 -2
drivers/scsi/qla2xxx/qla_def.h
··· 639 639 u8 els_opcode; 640 640 u8 vp_idx; 641 641 __le16 nport_handle; 642 - u16 control_flags; 642 + u16 control_flags, ox_id; 643 643 __le32 rx_xchg_address; 644 - port_id_t did; 644 + port_id_t did, sid; 645 645 u32 tx_len, tx_byte_count, rx_len, rx_byte_count; 646 646 dma_addr_t tx_addr, rx_addr; 647 647
+171 -155
drivers/scsi/qla2xxx/qla_edif.c
··· 218 218 "%s edif not enabled\n", __func__); 219 219 goto done; 220 220 } 221 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 221 + if (DBELL_INACTIVE(vha)) { 222 222 ql_dbg(ql_dbg_edif, vha, 0x09102, 223 223 "%s doorbell not enabled\n", __func__); 224 224 goto done; ··· 288 288 __func__, appid.app_vid); 289 289 290 290 return false; 291 - } 292 - 293 - static void qla_edif_reset_auth_wait(struct fc_port *fcport, int state, 294 - int waitonly) 295 - { 296 - int cnt, max_cnt = 200; 297 - bool traced = false; 298 - 299 - fcport->keep_nport_handle = 1; 300 - 301 - if (!waitonly) { 302 - qla2x00_set_fcport_disc_state(fcport, state); 303 - qlt_schedule_sess_for_deletion(fcport); 304 - } else { 305 - qla2x00_set_fcport_disc_state(fcport, state); 306 - } 307 - 308 - ql_dbg(ql_dbg_edif, fcport->vha, 0xf086, 309 - "%s: waiting for session, max_cnt=%u\n", 310 - __func__, max_cnt); 311 - 312 - cnt = 0; 313 - 314 - if (waitonly) { 315 - /* Marker wait min 10 msecs. */ 316 - msleep(50); 317 - cnt += 50; 318 - } 319 - while (1) { 320 - if (!traced) { 321 - ql_dbg(ql_dbg_edif, fcport->vha, 0xf086, 322 - "%s: session sleep.\n", 323 - __func__); 324 - traced = true; 325 - } 326 - msleep(20); 327 - cnt++; 328 - if (waitonly && (fcport->disc_state == state || 329 - fcport->disc_state == DSC_LOGIN_COMPLETE)) 330 - break; 331 - if (fcport->disc_state == DSC_LOGIN_AUTH_PEND) 332 - break; 333 - if (cnt > max_cnt) 334 - break; 335 - } 336 - 337 - if (!waitonly) { 338 - ql_dbg(ql_dbg_edif, fcport->vha, 0xf086, 339 - "%s: waited for session - %8phC, loopid=%x portid=%06x fcport=%p state=%u, cnt=%u\n", 340 - __func__, fcport->port_name, fcport->loop_id, 341 - fcport->d_id.b24, fcport, fcport->disc_state, cnt); 342 - } else { 343 - ql_dbg(ql_dbg_edif, fcport->vha, 0xf086, 344 - "%s: waited ONLY for session - %8phC, loopid=%x portid=%06x fcport=%p state=%u, cnt=%u\n", 345 - __func__, fcport->port_name, fcport->loop_id, 346 - fcport->d_id.b24, fcport, fcport->disc_state, cnt); 347 - } 348 291 } 349 292 350 293 static void ··· 472 529 struct app_start_reply appreply; 473 530 struct fc_port *fcport, *tf; 474 531 475 - ql_dbg(ql_dbg_edif, vha, 0x911d, "%s app start\n", __func__); 532 + ql_log(ql_log_info, vha, 0x1313, 533 + "EDIF application registration with driver, FC device connections will be re-established.\n"); 476 534 477 535 sg_copy_to_buffer(bsg_job->request_payload.sg_list, 478 536 bsg_job->request_payload.sg_cnt, &appstart, ··· 482 538 ql_dbg(ql_dbg_edif, vha, 0x911d, "%s app_vid=%x app_start_flags %x\n", 483 539 __func__, appstart.app_info.app_vid, appstart.app_start_flags); 484 540 485 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 541 + if (DBELL_INACTIVE(vha)) { 486 542 /* mark doorbell as active since an app is now present */ 487 - vha->e_dbell.db_flags = EDB_ACTIVE; 543 + vha->e_dbell.db_flags |= EDB_ACTIVE; 488 544 } else { 489 545 ql_dbg(ql_dbg_edif, vha, 0x911e, "%s doorbell already active\n", 490 546 __func__); ··· 498 554 qla2xxx_wake_dpc(vha); 499 555 } else { 500 556 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { 557 + ql_dbg(ql_dbg_edif, vha, 0x2058, 558 + "FCSP - nn %8phN pn %8phN portid=%06x.\n", 559 + fcport->node_name, fcport->port_name, 560 + fcport->d_id.b24); 501 561 ql_dbg(ql_dbg_edif, vha, 0xf084, 502 - "%s: sess %p %8phC lid %#04x s_id %06x logout %d\n", 503 - __func__, fcport, fcport->port_name, 504 - fcport->loop_id, fcport->d_id.b24, 505 - fcport->logout_on_delete); 506 - 507 - ql_dbg(ql_dbg_edif, vha, 0xf084, 508 - "keep %d els_logo %d disc state %d auth state %d stop state %d\n", 509 - fcport->keep_nport_handle, 510 - fcport->send_els_logo, fcport->disc_state, 511 - fcport->edif.auth_state, fcport->edif.app_stop); 562 + "%s: se_sess %p / sess %p from port %8phC " 563 + "loop_id %#04x s_id %06x logout %d " 564 + "keep %d els_logo %d disc state %d auth state %d" 565 + "stop state %d\n", 566 + __func__, fcport->se_sess, fcport, 567 + fcport->port_name, fcport->loop_id, 568 + fcport->d_id.b24, fcport->logout_on_delete, 569 + fcport->keep_nport_handle, fcport->send_els_logo, 570 + fcport->disc_state, fcport->edif.auth_state, 571 + fcport->edif.app_stop); 512 572 513 573 if (atomic_read(&vha->loop_state) == LOOP_DOWN) 514 574 break; 515 - if (!(fcport->flags & FCF_FCSP_DEVICE)) 516 - continue; 517 575 518 576 fcport->edif.app_started = 1; 519 - if (fcport->edif.app_stop || 520 - (fcport->disc_state != DSC_LOGIN_COMPLETE && 521 - fcport->disc_state != DSC_LOGIN_PEND && 522 - fcport->disc_state != DSC_DELETED)) { 523 - /* no activity */ 524 - fcport->edif.app_stop = 0; 577 + fcport->login_retry = vha->hw->login_retry_count; 525 578 526 - ql_dbg(ql_dbg_edif, vha, 0x911e, 527 - "%s wwpn %8phC calling qla_edif_reset_auth_wait\n", 528 - __func__, fcport->port_name); 529 - fcport->edif.app_sess_online = 1; 530 - qla_edif_reset_auth_wait(fcport, DSC_LOGIN_PEND, 0); 531 - } 579 + /* no activity */ 580 + fcport->edif.app_stop = 0; 581 + 582 + ql_dbg(ql_dbg_edif, vha, 0x911e, 583 + "%s wwpn %8phC calling qla_edif_reset_auth_wait\n", 584 + __func__, fcport->port_name); 585 + fcport->edif.app_sess_online = 0; 586 + qlt_schedule_sess_for_deletion(fcport); 532 587 qla_edif_sa_ctl_init(vha, fcport); 533 588 } 534 589 } ··· 544 601 appreply.edif_enode_active = vha->pur_cinfo.enode_flags; 545 602 appreply.edif_edb_active = vha->e_dbell.db_flags; 546 603 547 - bsg_job->reply_len = sizeof(struct fc_bsg_reply) + 548 - sizeof(struct app_start_reply); 604 + bsg_job->reply_len = sizeof(struct fc_bsg_reply); 549 605 550 606 SET_DID_STATUS(bsg_reply->result, DID_OK); 551 607 552 - sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 553 - bsg_job->reply_payload.sg_cnt, &appreply, 554 - sizeof(struct app_start_reply)); 608 + bsg_reply->reply_payload_rcv_len = sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 609 + bsg_job->reply_payload.sg_cnt, 610 + &appreply, 611 + sizeof(struct app_start_reply)); 555 612 556 613 ql_dbg(ql_dbg_edif, vha, 0x911d, 557 614 "%s app start completed with 0x%x\n", ··· 743 800 ql_dbg(ql_dbg_edif, vha, 0x911e, 744 801 "%s AUTH complete - RESUME with prli for wwpn %8phC\n", 745 802 __func__, fcport->port_name); 746 - qla_edif_reset_auth_wait(fcport, DSC_LOGIN_PEND, 1); 747 803 qla24xx_post_prli_work(vha, fcport); 748 804 } 749 805 750 806 errstate_exit: 751 807 bsg_job->reply_len = sizeof(struct fc_bsg_reply); 752 - sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 753 - bsg_job->reply_payload.sg_cnt, &appplogireply, 754 - sizeof(struct app_plogi_reply)); 808 + bsg_reply->reply_payload_rcv_len = sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 809 + bsg_job->reply_payload.sg_cnt, 810 + &appplogireply, 811 + sizeof(struct app_plogi_reply)); 755 812 756 813 return rval; 757 814 } ··· 816 873 817 874 if (qla_ini_mode_enabled(fcport->vha)) { 818 875 fcport->send_els_logo = 1; 819 - qla_edif_reset_auth_wait(fcport, DSC_LOGIN_PEND, 0); 876 + qlt_schedule_sess_for_deletion(fcport); 820 877 } 821 878 } 822 879 ··· 834 891 qla_edif_app_getfcinfo(scsi_qla_host_t *vha, struct bsg_job *bsg_job) 835 892 { 836 893 int32_t rval = 0; 837 - int32_t num_cnt; 894 + int32_t pcnt = 0; 838 895 struct fc_bsg_reply *bsg_reply = bsg_job->reply; 839 896 struct app_pinfo_req app_req; 840 897 struct app_pinfo_reply *app_reply; ··· 846 903 bsg_job->request_payload.sg_cnt, &app_req, 847 904 sizeof(struct app_pinfo_req)); 848 905 849 - num_cnt = app_req.num_ports; /* num of ports alloc'd by app */ 850 - 851 906 app_reply = kzalloc((sizeof(struct app_pinfo_reply) + 852 - sizeof(struct app_pinfo) * num_cnt), GFP_KERNEL); 907 + sizeof(struct app_pinfo) * app_req.num_ports), GFP_KERNEL); 908 + 853 909 if (!app_reply) { 854 910 SET_DID_STATUS(bsg_reply->result, DID_ERROR); 855 911 rval = -1; 856 912 } else { 857 913 struct fc_port *fcport = NULL, *tf; 858 - uint32_t pcnt = 0; 859 914 860 915 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { 861 916 if (!(fcport->flags & FCF_FCSP_DEVICE)) ··· 922 981 SET_DID_STATUS(bsg_reply->result, DID_OK); 923 982 } 924 983 925 - sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 926 - bsg_job->reply_payload.sg_cnt, app_reply, 927 - sizeof(struct app_pinfo_reply) + sizeof(struct app_pinfo) * num_cnt); 984 + bsg_job->reply_len = sizeof(struct fc_bsg_reply); 985 + bsg_reply->reply_payload_rcv_len = sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 986 + bsg_job->reply_payload.sg_cnt, 987 + app_reply, 988 + sizeof(struct app_pinfo_reply) + sizeof(struct app_pinfo) * pcnt); 928 989 929 990 kfree(app_reply); 930 991 ··· 943 1000 { 944 1001 int32_t rval = 0; 945 1002 struct fc_bsg_reply *bsg_reply = bsg_job->reply; 946 - uint32_t ret_size, size; 1003 + uint32_t size; 947 1004 948 1005 struct app_sinfo_req app_req; 949 1006 struct app_stats_reply *app_reply; 1007 + uint32_t pcnt = 0; 950 1008 951 1009 sg_copy_to_buffer(bsg_job->request_payload.sg_list, 952 1010 bsg_job->request_payload.sg_cnt, &app_req, ··· 963 1019 size = sizeof(struct app_stats_reply) + 964 1020 (sizeof(struct app_sinfo) * app_req.num_ports); 965 1021 966 - if (size > bsg_job->reply_payload.payload_len) 967 - ret_size = bsg_job->reply_payload.payload_len; 968 - else 969 - ret_size = size; 970 - 971 1022 app_reply = kzalloc(size, GFP_KERNEL); 972 1023 if (!app_reply) { 973 1024 SET_DID_STATUS(bsg_reply->result, DID_ERROR); 974 1025 rval = -1; 975 1026 } else { 976 1027 struct fc_port *fcport = NULL, *tf; 977 - uint32_t pcnt = 0; 978 1028 979 1029 list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) { 980 1030 if (fcport->edif.enable) { ··· 992 1054 SET_DID_STATUS(bsg_reply->result, DID_OK); 993 1055 } 994 1056 1057 + bsg_job->reply_len = sizeof(struct fc_bsg_reply); 995 1058 bsg_reply->reply_payload_rcv_len = 996 1059 sg_copy_from_buffer(bsg_job->reply_payload.sg_list, 997 - bsg_job->reply_payload.sg_cnt, app_reply, ret_size); 1060 + bsg_job->reply_payload.sg_cnt, app_reply, 1061 + sizeof(struct app_stats_reply) + (sizeof(struct app_sinfo) * pcnt)); 998 1062 999 1063 kfree(app_reply); 1000 1064 ··· 1070 1130 __func__, 1071 1131 bsg_request->rqst_data.h_vendor.vendor_cmd[1]); 1072 1132 rval = EXT_STATUS_INVALID_PARAM; 1073 - bsg_job->reply_len = sizeof(struct fc_bsg_reply); 1074 - SET_DID_STATUS(bsg_reply->result, DID_ERROR); 1133 + done = false; 1075 1134 break; 1076 1135 } 1077 1136 ··· 1269 1330 goto done; 1270 1331 } 1271 1332 1272 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 1333 + if (DBELL_INACTIVE(vha)) { 1273 1334 ql_log(ql_log_warn, vha, 0x70a1, "App not started\n"); 1274 1335 rval = -EIO; 1275 1336 SET_DID_STATUS(bsg_reply->result, DID_ERROR); ··· 1590 1651 spin_unlock_irqrestore(&vha->pur_cinfo.pur_lock, flags); 1591 1652 } 1592 1653 1654 + static void qla_enode_clear(scsi_qla_host_t *vha, port_id_t portid) 1655 + { 1656 + unsigned long flags; 1657 + struct enode *e, *tmp; 1658 + struct purexevent *purex; 1659 + LIST_HEAD(enode_list); 1660 + 1661 + if (vha->pur_cinfo.enode_flags != ENODE_ACTIVE) { 1662 + ql_dbg(ql_dbg_edif, vha, 0x09102, 1663 + "%s enode not active\n", __func__); 1664 + return; 1665 + } 1666 + spin_lock_irqsave(&vha->pur_cinfo.pur_lock, flags); 1667 + list_for_each_entry_safe(e, tmp, &vha->pur_cinfo.head, list) { 1668 + purex = &e->u.purexinfo; 1669 + if (purex->pur_info.pur_sid.b24 == portid.b24) { 1670 + ql_dbg(ql_dbg_edif, vha, 0x911d, 1671 + "%s free ELS sid=%06x. xchg %x, nb=%xh\n", 1672 + __func__, portid.b24, 1673 + purex->pur_info.pur_rx_xchg_address, 1674 + purex->pur_info.pur_bytes_rcvd); 1675 + 1676 + list_del_init(&e->list); 1677 + list_add_tail(&e->list, &enode_list); 1678 + } 1679 + } 1680 + spin_unlock_irqrestore(&vha->pur_cinfo.pur_lock, flags); 1681 + 1682 + list_for_each_entry_safe(e, tmp, &enode_list, list) { 1683 + list_del_init(&e->list); 1684 + qla_enode_free(vha, e); 1685 + } 1686 + } 1687 + 1593 1688 /* 1594 1689 * allocate enode struct and populate buffer 1595 1690 * returns: enode pointer with buffers ··· 1668 1695 qla_enode_find(scsi_qla_host_t *vha, uint32_t ntype, uint32_t p1, uint32_t p2) 1669 1696 { 1670 1697 struct enode *node_rtn = NULL; 1671 - struct enode *list_node = NULL; 1698 + struct enode *list_node, *q; 1672 1699 unsigned long flags; 1673 - struct list_head *pos, *q; 1674 1700 uint32_t sid; 1675 - uint32_t rw_flag; 1676 1701 struct purexevent *purex; 1677 1702 1678 1703 /* secure the list from moving under us */ 1679 1704 spin_lock_irqsave(&vha->pur_cinfo.pur_lock, flags); 1680 1705 1681 - list_for_each_safe(pos, q, &vha->pur_cinfo.head) { 1682 - list_node = list_entry(pos, struct enode, list); 1706 + list_for_each_entry_safe(list_node, q, &vha->pur_cinfo.head, list) { 1683 1707 1684 1708 /* node type determines what p1 and p2 are */ 1685 1709 purex = &list_node->u.purexinfo; 1686 1710 sid = p1; 1687 - rw_flag = p2; 1688 1711 1689 1712 if (purex->pur_info.pur_sid.b24 == sid) { 1690 - if (purex->pur_info.pur_pend == 1 && 1691 - rw_flag == PUR_GET) { 1692 - /* 1693 - * if the receive is in progress 1694 - * and its a read/get then can't 1695 - * transfer yet 1696 - */ 1697 - ql_dbg(ql_dbg_edif, vha, 0x9106, 1698 - "%s purex xfer in progress for sid=%x\n", 1699 - __func__, sid); 1700 - } else { 1701 - /* found it and its complete */ 1702 - node_rtn = list_node; 1703 - list_del(pos); 1704 - break; 1705 - } 1713 + /* found it and its complete */ 1714 + node_rtn = list_node; 1715 + list_del(&list_node->list); 1716 + break; 1706 1717 } 1707 1718 } 1708 1719 ··· 1759 1802 qla_els_pt_iocb(vha, els_iocb, a); 1760 1803 1761 1804 ql_dbg(ql_dbg_edif, vha, 0x0183, 1762 - "Sending ELS reject...\n"); 1805 + "Sending ELS reject ox_id %04x s:%06x -> d:%06x\n", 1806 + a->ox_id, a->sid.b24, a->did.b24); 1763 1807 ql_dump_buffer(ql_dbg_edif + ql_dbg_verbose, vha, 0x0185, 1764 1808 vha->hw->elsrej.c, sizeof(*vha->hw->elsrej.c)); 1765 1809 /* flush iocb to mem before notifying hw doorbell */ ··· 1772 1814 void 1773 1815 qla_edb_init(scsi_qla_host_t *vha) 1774 1816 { 1775 - if (vha->e_dbell.db_flags == EDB_ACTIVE) { 1817 + if (DBELL_ACTIVE(vha)) { 1776 1818 /* list already init'd - error */ 1777 1819 ql_dbg(ql_dbg_edif, vha, 0x09102, 1778 1820 "edif db already initialized, cannot reinit\n"); ··· 1808 1850 node->ntype = N_UNDEF; 1809 1851 } 1810 1852 1853 + static void qla_edb_clear(scsi_qla_host_t *vha, port_id_t portid) 1854 + { 1855 + unsigned long flags; 1856 + struct edb_node *e, *tmp; 1857 + port_id_t sid; 1858 + LIST_HEAD(edb_list); 1859 + 1860 + if (DBELL_INACTIVE(vha)) { 1861 + /* doorbell list not enabled */ 1862 + ql_dbg(ql_dbg_edif, vha, 0x09102, 1863 + "%s doorbell not enabled\n", __func__); 1864 + return; 1865 + } 1866 + 1867 + /* grab lock so list doesn't move */ 1868 + spin_lock_irqsave(&vha->e_dbell.db_lock, flags); 1869 + list_for_each_entry_safe(e, tmp, &vha->e_dbell.head, list) { 1870 + switch (e->ntype) { 1871 + case VND_CMD_AUTH_STATE_NEEDED: 1872 + case VND_CMD_AUTH_STATE_SESSION_SHUTDOWN: 1873 + sid = e->u.plogi_did; 1874 + break; 1875 + case VND_CMD_AUTH_STATE_ELS_RCVD: 1876 + sid = e->u.els_sid; 1877 + break; 1878 + case VND_CMD_AUTH_STATE_SAUPDATE_COMPL: 1879 + /* app wants to see this */ 1880 + continue; 1881 + default: 1882 + ql_log(ql_log_warn, vha, 0x09102, 1883 + "%s unknown node type: %x\n", __func__, e->ntype); 1884 + sid.b24 = 0; 1885 + break; 1886 + } 1887 + if (sid.b24 == portid.b24) { 1888 + ql_dbg(ql_dbg_edif, vha, 0x910f, 1889 + "%s free doorbell event : node type = %x %p\n", 1890 + __func__, e->ntype, e); 1891 + list_del_init(&e->list); 1892 + list_add_tail(&e->list, &edb_list); 1893 + } 1894 + } 1895 + spin_unlock_irqrestore(&vha->e_dbell.db_lock, flags); 1896 + 1897 + list_for_each_entry_safe(e, tmp, &edb_list, list) { 1898 + qla_edb_node_free(vha, e); 1899 + list_del_init(&e->list); 1900 + kfree(e); 1901 + } 1902 + } 1903 + 1811 1904 /* function called when app is stopping */ 1812 1905 1813 1906 void ··· 1867 1858 unsigned long flags; 1868 1859 struct edb_node *node, *q; 1869 1860 1870 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 1861 + if (DBELL_INACTIVE(vha)) { 1871 1862 /* doorbell list not enabled */ 1872 1863 ql_dbg(ql_dbg_edif, vha, 0x09102, 1873 1864 "%s doorbell not enabled\n", __func__); ··· 1918 1909 { 1919 1910 unsigned long flags; 1920 1911 1921 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 1912 + if (DBELL_INACTIVE(vha)) { 1922 1913 /* doorbell list not enabled */ 1923 1914 ql_dbg(ql_dbg_edif, vha, 0x09102, 1924 1915 "%s doorbell not enabled\n", __func__); ··· 1949 1940 return; 1950 1941 } 1951 1942 1952 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 1943 + if (DBELL_INACTIVE(vha)) { 1953 1944 if (fcport) 1954 1945 fcport->edif.auth_state = dbtype; 1955 1946 /* doorbell list not enabled */ ··· 2044 2035 struct qla_hw_data *ha = vha->hw; 2045 2036 2046 2037 if (!vha->vp_idx && N2N_TOPO(ha) && ha->flags.n2n_fw_acc_sec) { 2047 - if (vha->e_dbell.db_flags != EDB_ACTIVE && 2038 + if (DBELL_INACTIVE(vha) && 2048 2039 ha->edif_post_stop_cnt_down) { 2049 2040 ha->edif_post_stop_cnt_down--; 2050 2041 ··· 2082 2073 sz = 256; 2083 2074 2084 2075 /* stop new threads from waiting if we're not init'd */ 2085 - if (vha->e_dbell.db_flags != EDB_ACTIVE) { 2076 + if (DBELL_INACTIVE(vha)) { 2086 2077 ql_dbg(ql_dbg_edif + ql_dbg_verbose, vha, 0x09122, 2087 2078 "%s error - edif db not enabled\n", __func__); 2088 2079 return 0; ··· 2355 2346 a.tx_addr = vha->hw->elsrej.cdma; 2356 2347 a.vp_idx = vha->vp_idx; 2357 2348 a.control_flags = EPD_ELS_RJT; 2349 + a.ox_id = le16_to_cpu(p->ox_id); 2358 2350 2359 2351 sid = p->s_id[0] | (p->s_id[1] << 8) | (p->s_id[2] << 16); 2360 2352 ··· 2367 2357 return; 2368 2358 } 2369 2359 2370 - if (totlen > MAX_PAYLOAD) { 2360 + if (totlen > ELS_MAX_PAYLOAD) { 2371 2361 ql_dbg(ql_dbg_edif, vha, 0x0910d, 2372 2362 "%s WARNING: verbose ELS frame received (totlen=%x)\n", 2373 2363 __func__, totlen); ··· 2397 2387 2398 2388 purex = &ptr->u.purexinfo; 2399 2389 purex->pur_info.pur_sid = a.did; 2400 - purex->pur_info.pur_pend = 0; 2401 2390 purex->pur_info.pur_bytes_rcvd = totlen; 2402 2391 purex->pur_info.pur_rx_xchg_address = le32_to_cpu(p->rx_xchg_addr); 2403 2392 purex->pur_info.pur_nphdl = le16_to_cpu(p->nport_handle); ··· 2404 2395 purex->pur_info.pur_did.b.area = p->d_id[1]; 2405 2396 purex->pur_info.pur_did.b.al_pa = p->d_id[0]; 2406 2397 purex->pur_info.vp_idx = p->vp_idx; 2398 + 2399 + a.sid = purex->pur_info.pur_did; 2407 2400 2408 2401 rc = __qla_copy_purex_to_buffer(vha, pkt, rsp, purex->msgp, 2409 2402 purex->msgp_len); ··· 2430 2419 2431 2420 fcport = qla2x00_find_fcport_by_pid(host, &purex->pur_info.pur_sid); 2432 2421 2433 - if (host->e_dbell.db_flags != EDB_ACTIVE || 2422 + if (DBELL_INACTIVE(vha) || 2434 2423 (fcport && EDIF_SESSION_DOWN(fcport))) { 2435 2424 ql_dbg(ql_dbg_edif, host, 0x0910c, "%s e_dbell.db_flags =%x %06x\n", 2436 2425 __func__, host->e_dbell.db_flags, ··· 2447 2436 ql_dbg(ql_dbg_edif, host, 0x0910c, 2448 2437 "%s COMPLETE purex->pur_info.pur_bytes_rcvd =%xh s:%06x -> d:%06x xchg=%xh\n", 2449 2438 __func__, purex->pur_info.pur_bytes_rcvd, purex->pur_info.pur_sid.b24, 2450 - purex->pur_info.pur_did.b24, p->rx_xchg_addr); 2439 + purex->pur_info.pur_did.b24, purex->pur_info.pur_rx_xchg_address); 2451 2440 2452 2441 qla_edb_eventcreate(host, VND_CMD_AUTH_STATE_ELS_RCVD, sid, 0, NULL); 2453 2442 } ··· 3150 3139 /* release any sadb entries -- only done at teardown */ 3151 3140 void qla_edif_sadb_release(struct qla_hw_data *ha) 3152 3141 { 3153 - struct list_head *pos; 3154 - struct list_head *tmp; 3155 - struct edif_sa_index_entry *entry; 3142 + struct edif_sa_index_entry *entry, *tmp; 3156 3143 3157 - list_for_each_safe(pos, tmp, &ha->sadb_rx_index_list) { 3158 - entry = list_entry(pos, struct edif_sa_index_entry, next); 3144 + list_for_each_entry_safe(entry, tmp, &ha->sadb_rx_index_list, next) { 3159 3145 list_del(&entry->next); 3160 3146 kfree(entry); 3161 3147 } 3162 3148 3163 - list_for_each_safe(pos, tmp, &ha->sadb_tx_index_list) { 3164 - entry = list_entry(pos, struct edif_sa_index_entry, next); 3149 + list_for_each_entry_safe(entry, tmp, &ha->sadb_tx_index_list, next) { 3165 3150 list_del(&entry->next); 3166 3151 kfree(entry); 3167 3152 } ··· 3456 3449 3457 3450 void qla_edif_sess_down(struct scsi_qla_host *vha, struct fc_port *sess) 3458 3451 { 3459 - if (sess->edif.app_sess_online && vha->e_dbell.db_flags & EDB_ACTIVE) { 3452 + if (sess->edif.app_sess_online && DBELL_ACTIVE(vha)) { 3460 3453 ql_dbg(ql_dbg_disc, vha, 0xf09c, 3461 3454 "%s: sess %8phN send port_offline event\n", 3462 3455 __func__, sess->port_name); ··· 3465 3458 sess->d_id.b24, 0, sess); 3466 3459 qla2x00_post_aen_work(vha, FCH_EVT_PORT_OFFLINE, sess->d_id.b24); 3467 3460 } 3461 + } 3462 + 3463 + void qla_edif_clear_appdata(struct scsi_qla_host *vha, struct fc_port *fcport) 3464 + { 3465 + if (!(fcport->flags & FCF_FCSP_DEVICE)) 3466 + return; 3467 + 3468 + qla_edb_clear(vha, fcport->d_id); 3469 + qla_enode_clear(vha, fcport->d_id); 3468 3470 }
+10 -3
drivers/scsi/qla2xxx/qla_edif.h
··· 41 41 }; 42 42 43 43 enum db_flags_t { 44 - EDB_ACTIVE = 0x1, 44 + EDB_ACTIVE = BIT_0, 45 45 }; 46 + 47 + #define DBELL_ACTIVE(_v) (_v->e_dbell.db_flags & EDB_ACTIVE) 48 + #define DBELL_INACTIVE(_v) (!(_v->e_dbell.db_flags & EDB_ACTIVE)) 46 49 47 50 struct edif_dbell { 48 51 enum db_flags_t db_flags; ··· 96 93 }; 97 94 98 95 #define NUM_ENTRIES 256 99 - #define MAX_PAYLOAD 1024 100 96 #define PUR_GET 1 101 97 102 98 struct dinfo { ··· 104 102 }; 105 103 106 104 struct pur_ninfo { 107 - unsigned int pur_pend:1; 108 105 port_id_t pur_sid; 109 106 port_id_t pur_did; 110 107 uint8_t vp_idx; ··· 129 128 } u; 130 129 }; 131 130 131 + #define RX_ELS_SIZE (roundup(sizeof(struct enode) + ELS_MAX_PAYLOAD, SMP_CACHE_BYTES)) 132 + 132 133 #define EDIF_SESSION_DOWN(_s) \ 133 134 (qla_ini_mode_enabled(_s->vha) && (_s->disc_state == DSC_DELETE_PEND || \ 134 135 _s->disc_state == DSC_DELETED || \ 135 136 !_s->edif.app_sess_online)) 137 + 138 + #define EDIF_NEGOTIATION_PENDING(_fcport) \ 139 + (DBELL_ACTIVE(_fcport->vha) && \ 140 + (_fcport->disc_state == DSC_LOGIN_AUTH_PEND)) 136 141 137 142 #endif /* __QLA_EDIF_H */
+1 -1
drivers/scsi/qla2xxx/qla_edif_bsg.h
··· 8 8 #define __QLA_EDIF_BSG_H 9 9 10 10 /* BSG Vendor specific commands */ 11 - #define ELS_MAX_PAYLOAD 1024 11 + #define ELS_MAX_PAYLOAD 2112 12 12 #ifndef WWN_SIZE 13 13 #define WWN_SIZE 8 14 14 #endif
+2 -2
drivers/scsi/qla2xxx/qla_gbl.h
··· 142 142 void qla2x00_release_all_sadb(struct scsi_qla_host *vha, struct fc_port *fcport); 143 143 int qla_edif_process_els(scsi_qla_host_t *vha, struct bsg_job *bsgjob); 144 144 void qla_edif_sess_down(struct scsi_qla_host *vha, struct fc_port *sess); 145 + void qla_edif_clear_appdata(struct scsi_qla_host *vha, 146 + struct fc_port *fcport); 145 147 const char *sc_to_str(uint16_t cmd); 146 148 147 149 /* ··· 173 171 extern int ql2xgffidenable; 174 172 extern int ql2xenabledif; 175 173 extern int ql2xenablehba_err_chk; 176 - extern int ql2xtargetreset; 177 174 extern int ql2xdontresethba; 178 175 extern uint64_t ql2xmaxlun; 179 176 extern int ql2xmdcapmask; ··· 819 818 extern void qlafx00_fxdisc_iocb(srb_t *, struct fxdisc_entry_fx00 *); 820 819 extern void qlafx00_timer_routine(scsi_qla_host_t *); 821 820 extern int qlafx00_rescan_isp(scsi_qla_host_t *); 822 - extern int qlafx00_loop_reset(scsi_qla_host_t *vha); 823 821 824 822 /* qla82xx related functions */ 825 823
+86 -26
drivers/scsi/qla2xxx/qla_init.c
··· 330 330 lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY; 331 331 } else { 332 332 if (vha->hw->flags.edif_enabled && 333 - vha->e_dbell.db_flags & EDB_ACTIVE) { 333 + DBELL_ACTIVE(vha)) { 334 334 lio->u.logio.flags |= 335 335 (SRB_LOGIN_FCSP | SRB_LOGIN_SKIP_PRLI); 336 - ql_dbg(ql_dbg_disc, vha, 0x2072, 337 - "Async-login: w/ FCSP %8phC hdl=%x, loopid=%x portid=%06x\n", 338 - fcport->port_name, sp->handle, fcport->loop_id, fcport->d_id.b24); 339 336 } else { 340 337 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; 341 338 } ··· 341 344 if (NVME_TARGET(vha->hw, fcport)) 342 345 lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; 343 346 344 - ql_dbg(ql_dbg_disc, vha, 0x2072, 345 - "Async-login - %8phC hdl=%x, loopid=%x portid=%06x retries=%d.\n", 346 - fcport->port_name, sp->handle, fcport->loop_id, 347 - fcport->d_id.b24, fcport->login_retry); 348 - 349 347 rval = qla2x00_start_sp(sp); 348 + 349 + ql_dbg(ql_dbg_disc, vha, 0x2072, 350 + "Async-login - %8phC hdl=%x, loopid=%x portid=%06x retries=%d %s.\n", 351 + fcport->port_name, sp->handle, fcport->loop_id, 352 + fcport->d_id.b24, fcport->login_retry, 353 + lio->u.logio.flags & SRB_LOGIN_FCSP ? "FCSP" : ""); 354 + 350 355 if (rval != QLA_SUCCESS) { 351 356 fcport->flags |= FCF_LOGIN_NEEDED; 352 357 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); ··· 861 862 break; 862 863 case DSC_LS_PLOGI_COMP: 863 864 if (vha->hw->flags.edif_enabled && 864 - vha->e_dbell.db_flags & EDB_ACTIVE) { 865 + DBELL_ACTIVE(vha)) { 865 866 /* check to see if App support secure or not */ 866 867 qla24xx_post_gpdb_work(vha, fcport, 0); 867 868 break; ··· 986 987 sp->name, res, sp->u.iocb_cmd.u.mbx.in_mb[1], 987 988 sp->u.iocb_cmd.u.mbx.in_mb[2]); 988 989 989 - if (res == QLA_FUNCTION_TIMEOUT) 990 - return; 991 990 992 991 sp->fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); 993 992 memset(&ea, 0, sizeof(ea)); ··· 1023 1026 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); 1024 1027 1025 1028 list_for_each_entry_safe(fcport, tf, &h, gnl_entry) { 1026 - list_del_init(&fcport->gnl_entry); 1027 1029 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); 1030 + list_del_init(&fcport->gnl_entry); 1028 1031 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); 1029 1032 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); 1030 1033 ea.fcport = fcport; ··· 1451 1454 qla2x00_post_aen_work(vha, FCH_EVT_PORT_ONLINE, 1452 1455 fcport->d_id.b24); 1453 1456 1454 - if (vha->e_dbell.db_flags == EDB_ACTIVE) { 1457 + if (DBELL_ACTIVE(vha)) { 1455 1458 ql_dbg(ql_dbg_disc, vha, 0x20ef, 1456 1459 "%s %d %8phC EDIF: post DB_AUTH: AUTH needed\n", 1457 1460 __func__, __LINE__, fcport->port_name); ··· 1783 1786 fc_port_t *fcport; 1784 1787 unsigned long flags; 1785 1788 1786 - fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); 1787 - if (fcport) { 1788 - if (fcport->flags & FCF_FCP2_DEVICE) { 1789 - ql_dbg(ql_dbg_disc, vha, 0x2115, 1790 - "Delaying session delete for FCP2 portid=%06x %8phC ", 1791 - fcport->d_id.b24, fcport->port_name); 1792 - return; 1789 + switch (ea->id.b.rsvd_1) { 1790 + case RSCN_PORT_ADDR: 1791 + fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); 1792 + if (fcport) { 1793 + if (fcport->flags & FCF_FCP2_DEVICE) { 1794 + ql_dbg(ql_dbg_disc, vha, 0x2115, 1795 + "Delaying session delete for FCP2 portid=%06x %8phC ", 1796 + fcport->d_id.b24, fcport->port_name); 1797 + return; 1798 + } 1799 + 1800 + if (vha->hw->flags.edif_enabled && DBELL_ACTIVE(vha)) { 1801 + /* 1802 + * On ipsec start by remote port, Target port 1803 + * may use RSCN to trigger initiator to 1804 + * relogin. If driver is already in the 1805 + * process of a relogin, then ignore the RSCN 1806 + * and allow the current relogin to continue. 1807 + * This reduces thrashing of the connection. 1808 + */ 1809 + if (atomic_read(&fcport->state) == FCS_ONLINE) { 1810 + /* 1811 + * If state = online, then set scan_needed=1 to do relogin. 1812 + * Otherwise we're already in the middle of a relogin 1813 + */ 1814 + fcport->scan_needed = 1; 1815 + fcport->rscn_gen++; 1816 + } 1817 + } else { 1818 + fcport->scan_needed = 1; 1819 + fcport->rscn_gen++; 1820 + } 1793 1821 } 1794 - fcport->scan_needed = 1; 1795 - fcport->rscn_gen++; 1822 + break; 1823 + case RSCN_AREA_ADDR: 1824 + list_for_each_entry(fcport, &vha->vp_fcports, list) { 1825 + if (fcport->flags & FCF_FCP2_DEVICE) 1826 + continue; 1827 + 1828 + if ((ea->id.b24 & 0xffff00) == (fcport->d_id.b24 & 0xffff00)) { 1829 + fcport->scan_needed = 1; 1830 + fcport->rscn_gen++; 1831 + } 1832 + } 1833 + break; 1834 + case RSCN_DOM_ADDR: 1835 + list_for_each_entry(fcport, &vha->vp_fcports, list) { 1836 + if (fcport->flags & FCF_FCP2_DEVICE) 1837 + continue; 1838 + 1839 + if ((ea->id.b24 & 0xff0000) == (fcport->d_id.b24 & 0xff0000)) { 1840 + fcport->scan_needed = 1; 1841 + fcport->rscn_gen++; 1842 + } 1843 + } 1844 + break; 1845 + case RSCN_FAB_ADDR: 1846 + default: 1847 + list_for_each_entry(fcport, &vha->vp_fcports, list) { 1848 + if (fcport->flags & FCF_FCP2_DEVICE) 1849 + continue; 1850 + 1851 + fcport->scan_needed = 1; 1852 + fcport->rscn_gen++; 1853 + } 1854 + break; 1796 1855 } 1797 1856 1798 1857 spin_lock_irqsave(&vha->work_lock, flags); ··· 4240 4187 * fw shal not send PRLI after PLOGI Acc 4241 4188 */ 4242 4189 if (ha->flags.edif_enabled && 4243 - vha->e_dbell.db_flags & EDB_ACTIVE) { 4190 + DBELL_ACTIVE(vha)) { 4244 4191 ha->fw_options[3] |= BIT_15; 4245 4192 ha->flags.n2n_fw_acc_sec = 1; 4246 4193 } else { ··· 4485 4432 ql_dbg(ql_dbg_init, vha, 0x00bc, "FA-WWPN Support: %s.\n", 4486 4433 (ha->flags.fawwpn_enabled) ? "enabled" : "disabled"); 4487 4434 } 4435 + 4436 + /* ELS pass through payload is limit by frame size. */ 4437 + if (ha->flags.edif_enabled) 4438 + mid_init_cb->init_cb.frame_payload_size = cpu_to_le16(ELS_MAX_PAYLOAD); 4488 4439 4489 4440 rval = qla2x00_init_firmware(vha, ha->init_cb_size); 4490 4441 next_check: ··· 5396 5339 * use link up to wake up app to get ready for 5397 5340 * authentication. 5398 5341 */ 5399 - if (ha->flags.edif_enabled && 5400 - !(vha->e_dbell.db_flags & EDB_ACTIVE)) 5342 + if (ha->flags.edif_enabled && DBELL_INACTIVE(vha)) 5401 5343 qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, 5402 5344 ha->link_data_rate); 5403 5345 ··· 5888 5832 return; 5889 5833 5890 5834 qla2x00_update_fcport(fcport->vha, fcport); 5835 + 5836 + ql_dbg(ql_dbg_disc, fcport->vha, 0x911e, 5837 + "%s rscn gen %d/%d next DS %d\n", __func__, 5838 + rscn_gen, fcport->rscn_gen, fcport->next_disc_state); 5891 5839 5892 5840 if (rscn_gen != fcport->rscn_gen) { 5893 5841 /* RSCN(s) came in while registration */
+1 -2
drivers/scsi/qla2xxx/qla_iocb.c
··· 3034 3034 elsio->u.els_plogi.els_cmd = els_opcode; 3035 3035 elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode; 3036 3036 3037 - if (els_opcode == ELS_DCMD_PLOGI && vha->hw->flags.edif_enabled && 3038 - vha->e_dbell.db_flags & EDB_ACTIVE) { 3037 + if (els_opcode == ELS_DCMD_PLOGI && DBELL_ACTIVE(vha)) { 3039 3038 struct fc_els_flogi *p = ptr; 3040 3039 3041 3040 p->fl_csp.sp_features |= cpu_to_be16(FC_SP_FT_SEC);
+4
drivers/scsi/qla2xxx/qla_isr.c
··· 2233 2233 } 2234 2234 2235 2235 } else if (comp_status == CS_PORT_LOGGED_OUT) { 2236 + ql_dbg(ql_dbg_disc, vha, 0x911e, 2237 + "%s %d schedule session deletion\n", 2238 + __func__, __LINE__); 2239 + 2236 2240 els->u.els_plogi.len = 0; 2237 2241 res = DID_IMM_RETRY << 16; 2238 2242 qlt_schedule_sess_for_deletion(sp->fcport);
-23
drivers/scsi/qla2xxx/qla_mr.c
··· 739 739 } 740 740 741 741 int 742 - qlafx00_loop_reset(scsi_qla_host_t *vha) 743 - { 744 - int ret; 745 - struct fc_port *fcport; 746 - struct qla_hw_data *ha = vha->hw; 747 - 748 - if (ql2xtargetreset) { 749 - list_for_each_entry(fcport, &vha->vp_fcports, list) { 750 - if (fcport->port_type != FCT_TARGET) 751 - continue; 752 - 753 - ret = ha->isp_ops->target_reset(fcport, 0, 0); 754 - if (ret != QLA_SUCCESS) { 755 - ql_dbg(ql_dbg_taskm, vha, 0x803d, 756 - "Bus Reset failed: Reset=%d " 757 - "d_id=%x.\n", ret, fcport->d_id.b24); 758 - } 759 - } 760 - } 761 - return QLA_SUCCESS; 762 - } 763 - 764 - int 765 742 qlafx00_iospace_config(struct qla_hw_data *ha) 766 743 { 767 744 if (pci_request_selected_regions(ha->pdev, ha->bars,
+7 -30
drivers/scsi/qla2xxx/qla_os.c
··· 202 202 " 0 -- Regular doorbell.\n" 203 203 " 1 -- CAMRAM doorbell (faster).\n"); 204 204 205 - int ql2xtargetreset = 1; 206 - module_param(ql2xtargetreset, int, S_IRUGO); 207 - MODULE_PARM_DESC(ql2xtargetreset, 208 - "Enable target reset." 209 - "Default is 1 - use hw defaults."); 210 - 211 205 int ql2xgffidenable; 212 206 module_param(ql2xgffidenable, int, S_IRUGO); 213 207 MODULE_PARM_DESC(ql2xgffidenable, ··· 1689 1695 qla2x00_loop_reset(scsi_qla_host_t *vha) 1690 1696 { 1691 1697 int ret; 1692 - struct fc_port *fcport; 1693 1698 struct qla_hw_data *ha = vha->hw; 1694 1699 1695 - if (IS_QLAFX00(ha)) { 1696 - return qlafx00_loop_reset(vha); 1697 - } 1698 - 1699 - if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { 1700 - list_for_each_entry(fcport, &vha->vp_fcports, list) { 1701 - if (fcport->port_type != FCT_TARGET) 1702 - continue; 1703 - 1704 - ret = ha->isp_ops->target_reset(fcport, 0, 0); 1705 - if (ret != QLA_SUCCESS) { 1706 - ql_dbg(ql_dbg_taskm, vha, 0x802c, 1707 - "Bus Reset failed: Reset=%d " 1708 - "d_id=%x.\n", ret, fcport->d_id.b24); 1709 - } 1710 - } 1711 - } 1712 - 1700 + if (IS_QLAFX00(ha)) 1701 + return QLA_SUCCESS; 1713 1702 1714 1703 if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { 1715 1704 atomic_set(&vha->loop_state, LOOP_DOWN); ··· 3885 3908 static inline void 3886 3909 qla24xx_free_purex_list(struct purex_list *list) 3887 3910 { 3888 - struct list_head *item, *next; 3911 + struct purex_item *item, *next; 3889 3912 ulong flags; 3890 3913 3891 3914 spin_lock_irqsave(&list->lock, flags); 3892 - list_for_each_safe(item, next, &list->head) { 3893 - list_del(item); 3894 - kfree(list_entry(item, struct purex_item, list)); 3915 + list_for_each_entry_safe(item, next, &list->head, list) { 3916 + list_del(&item->list); 3917 + kfree(item); 3895 3918 } 3896 3919 spin_unlock_irqrestore(&list->lock, flags); 3897 3920 } ··· 4352 4375 4353 4376 /* allocate the purex dma pool */ 4354 4377 ha->purex_dma_pool = dma_pool_create(name, &ha->pdev->dev, 4355 - MAX_PAYLOAD, 8, 0); 4378 + ELS_MAX_PAYLOAD, 8, 0); 4356 4379 4357 4380 if (!ha->purex_dma_pool) { 4358 4381 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b,
+2 -1
drivers/scsi/qla2xxx/qla_target.c
··· 1003 1003 "%s bypassing release_all_sadb\n", 1004 1004 __func__); 1005 1005 } 1006 + qla_edif_clear_appdata(vha, sess); 1006 1007 qla_edif_sess_down(vha, sess); 1007 1008 } 1008 1009 qla2x00_mark_device_lost(vha, sess, 0); ··· 4813 4812 } 4814 4813 4815 4814 if (vha->hw->flags.edif_enabled) { 4816 - if (!(vha->e_dbell.db_flags & EDB_ACTIVE)) { 4815 + if (DBELL_INACTIVE(vha)) { 4817 4816 ql_dbg(ql_dbg_disc, vha, 0xffff, 4818 4817 "%s %d Term INOT due to app not started lid=%d, NportID %06X ", 4819 4818 __func__, __LINE__, loop_id, port_id.b24);
+2 -2
drivers/scsi/qla2xxx/qla_version.h
··· 6 6 /* 7 7 * Driver version 8 8 */ 9 - #define QLA2XXX_VERSION "10.02.07.100-k" 9 + #define QLA2XXX_VERSION "10.02.07.200-k" 10 10 11 11 #define QLA_DRIVER_MAJOR_VER 10 12 12 #define QLA_DRIVER_MINOR_VER 2 13 13 #define QLA_DRIVER_PATCH_VER 7 14 - #define QLA_DRIVER_BETA_VER 100 14 + #define QLA_DRIVER_BETA_VER 200
+4
drivers/scsi/scsi_debug.c
··· 4259 4259 mk_sense_invalid_opcode(scp); 4260 4260 return check_condition_result; 4261 4261 } 4262 + if (vnum == 0) 4263 + return 0; /* not an error */ 4262 4264 a_num = is_bytchk3 ? 1 : vnum; 4263 4265 /* Treat following check like one for read (i.e. no write) access */ 4264 4266 ret = check_device_access_params(scp, lba, a_num, false); ··· 4324 4322 } 4325 4323 zs_lba = get_unaligned_be64(cmd + 2); 4326 4324 alloc_len = get_unaligned_be32(cmd + 10); 4325 + if (alloc_len == 0) 4326 + return 0; /* not an error */ 4327 4327 rep_opts = cmd[14] & 0x3f; 4328 4328 partial = cmd[14] & 0x80; 4329 4329
+25
drivers/scsi/scsi_error.c
··· 133 133 return true; 134 134 } 135 135 136 + static void scsi_eh_complete_abort(struct scsi_cmnd *scmd, struct Scsi_Host *shost) 137 + { 138 + unsigned long flags; 139 + 140 + spin_lock_irqsave(shost->host_lock, flags); 141 + list_del_init(&scmd->eh_entry); 142 + /* 143 + * If the abort succeeds, and there is no further 144 + * EH action, clear the ->last_reset time. 145 + */ 146 + if (list_empty(&shost->eh_abort_list) && 147 + list_empty(&shost->eh_cmd_q)) 148 + if (shost->eh_deadline != -1) 149 + shost->last_reset = 0; 150 + spin_unlock_irqrestore(shost->host_lock, flags); 151 + } 152 + 136 153 /** 137 154 * scmd_eh_abort_handler - Handle command aborts 138 155 * @work: command to be aborted. ··· 167 150 container_of(work, struct scsi_cmnd, abort_work.work); 168 151 struct scsi_device *sdev = scmd->device; 169 152 enum scsi_disposition rtn; 153 + unsigned long flags; 170 154 171 155 if (scsi_host_eh_past_deadline(sdev->host)) { 172 156 SCSI_LOG_ERROR_RECOVERY(3, ··· 191 173 SCSI_LOG_ERROR_RECOVERY(3, 192 174 scmd_printk(KERN_WARNING, scmd, 193 175 "retry aborted command\n")); 176 + scsi_eh_complete_abort(scmd, sdev->host); 194 177 scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); 195 178 return; 196 179 } else { 197 180 SCSI_LOG_ERROR_RECOVERY(3, 198 181 scmd_printk(KERN_WARNING, scmd, 199 182 "finish aborted command\n")); 183 + scsi_eh_complete_abort(scmd, sdev->host); 200 184 scsi_finish_command(scmd); 201 185 return; 202 186 } ··· 211 191 } 212 192 } 213 193 194 + spin_lock_irqsave(sdev->host->host_lock, flags); 195 + list_del_init(&scmd->eh_entry); 196 + spin_unlock_irqrestore(sdev->host->host_lock, flags); 214 197 scsi_eh_scmd_add(scmd); 215 198 } 216 199 ··· 244 221 spin_lock_irqsave(shost->host_lock, flags); 245 222 if (shost->eh_deadline != -1 && !shost->last_reset) 246 223 shost->last_reset = jiffies; 224 + BUG_ON(!list_empty(&scmd->eh_entry)); 225 + list_add_tail(&scmd->eh_entry, &shost->eh_abort_list); 247 226 spin_unlock_irqrestore(shost->host_lock, flags); 248 227 249 228 scmd->eh_eflags |= SCSI_EH_ABORT_SCHEDULED;
+2
drivers/scsi/scsi_ioctl.c
··· 347 347 { 348 348 struct scsi_request *req = scsi_req(rq); 349 349 350 + if (hdr->cmd_len < 6) 351 + return -EMSGSIZE; 350 352 if (copy_from_user(req->cmd, hdr->cmdp, hdr->cmd_len)) 351 353 return -EFAULT; 352 354 if (!scsi_cmd_allowed(req->cmd, mode))
+1 -2
drivers/scsi/scsi_lib.c
··· 1153 1153 cmd->sense_buffer = buf; 1154 1154 cmd->prot_sdb = prot; 1155 1155 cmd->flags = flags; 1156 + INIT_LIST_HEAD(&cmd->eh_entry); 1156 1157 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); 1157 1158 cmd->jiffies_at_alloc = jiffies_at_alloc; 1158 1159 cmd->retries = retries; ··· 1185 1184 } 1186 1185 1187 1186 cmd->cmd_len = scsi_req(req)->cmd_len; 1188 - if (cmd->cmd_len == 0) 1189 - cmd->cmd_len = scsi_command_size(cmd->cmnd); 1190 1187 cmd->cmnd = scsi_req(req)->cmd; 1191 1188 cmd->transfersize = blk_rq_bytes(req); 1192 1189 cmd->allowed = scsi_req(req)->retries;
+2 -10
drivers/scsi/scsi_sysfs.c
··· 1383 1383 * We're treating error on bsg register as non-fatal, so 1384 1384 * pretend nothing went wrong. 1385 1385 */ 1386 + error = PTR_ERR(sdev->bsg_dev); 1386 1387 sdev_printk(KERN_INFO, sdev, 1387 1388 "Failed to register bsg queue, errno=%d\n", 1388 1389 error); ··· 1581 1580 1582 1581 void scsi_sysfs_device_initialize(struct scsi_device *sdev) 1583 1582 { 1584 - int i, j = 0; 1585 1583 unsigned long flags; 1586 1584 struct Scsi_Host *shost = sdev->host; 1587 1585 struct scsi_host_template *hostt = shost->hostt; ··· 1592 1592 scsi_enable_async_suspend(&sdev->sdev_gendev); 1593 1593 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu", 1594 1594 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); 1595 - sdev->gendev_attr_groups[j++] = &scsi_sdev_attr_group; 1596 - if (hostt->sdev_groups) { 1597 - for (i = 0; hostt->sdev_groups[i] && 1598 - j < ARRAY_SIZE(sdev->gendev_attr_groups); 1599 - i++, j++) { 1600 - sdev->gendev_attr_groups[j] = hostt->sdev_groups[i]; 1601 - } 1602 - } 1603 - WARN_ON_ONCE(j >= ARRAY_SIZE(sdev->gendev_attr_groups)); 1595 + sdev->sdev_gendev.groups = hostt->sdev_groups; 1604 1596 1605 1597 device_initialize(&sdev->sdev_dev); 1606 1598 sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
-1
drivers/scsi/sr.c
··· 693 693 cd->device = sdev; 694 694 cd->disk = disk; 695 695 cd->driver = &sr_template; 696 - cd->disk = disk; 697 696 cd->capacity = 0x1fffff; 698 697 cd->device->changed = 1; /* force recheck CD type */ 699 698 cd->media_present = 1;
+95 -3
drivers/scsi/ufs/ufs-debugfs.c
··· 8 8 9 9 static struct dentry *ufs_debugfs_root; 10 10 11 + struct ufs_debugfs_attr { 12 + const char *name; 13 + mode_t mode; 14 + const struct file_operations *fops; 15 + }; 16 + 17 + /* @file corresponds to a debugfs attribute in directory hba->debugfs_root. */ 18 + static inline struct ufs_hba *hba_from_file(const struct file *file) 19 + { 20 + return d_inode(file->f_path.dentry->d_parent)->i_private; 21 + } 22 + 11 23 void __init ufs_debugfs_init(void) 12 24 { 13 25 ufs_debugfs_root = debugfs_create_dir("ufshcd", NULL); ··· 32 20 33 21 static int ufs_debugfs_stats_show(struct seq_file *s, void *data) 34 22 { 35 - struct ufs_hba *hba = s->private; 23 + struct ufs_hba *hba = hba_from_file(s->file); 36 24 struct ufs_event_hist *e = hba->ufs_stats.event; 37 25 38 26 #define PRT(fmt, typ) \ ··· 138 126 ufs_debugfs_put_user_access(hba); 139 127 } 140 128 129 + static int ufs_saved_err_show(struct seq_file *s, void *data) 130 + { 131 + struct ufs_debugfs_attr *attr = s->private; 132 + struct ufs_hba *hba = hba_from_file(s->file); 133 + const int *p; 134 + 135 + if (strcmp(attr->name, "saved_err") == 0) { 136 + p = &hba->saved_err; 137 + } else if (strcmp(attr->name, "saved_uic_err") == 0) { 138 + p = &hba->saved_uic_err; 139 + } else { 140 + return -ENOENT; 141 + } 142 + 143 + seq_printf(s, "%d\n", *p); 144 + return 0; 145 + } 146 + 147 + static ssize_t ufs_saved_err_write(struct file *file, const char __user *buf, 148 + size_t count, loff_t *ppos) 149 + { 150 + struct ufs_debugfs_attr *attr = file->f_inode->i_private; 151 + struct ufs_hba *hba = hba_from_file(file); 152 + char val_str[16] = { }; 153 + int val, ret; 154 + 155 + if (count > sizeof(val_str)) 156 + return -EINVAL; 157 + if (copy_from_user(val_str, buf, count)) 158 + return -EFAULT; 159 + ret = kstrtoint(val_str, 0, &val); 160 + if (ret < 0) 161 + return ret; 162 + 163 + spin_lock_irq(hba->host->host_lock); 164 + if (strcmp(attr->name, "saved_err") == 0) { 165 + hba->saved_err = val; 166 + } else if (strcmp(attr->name, "saved_uic_err") == 0) { 167 + hba->saved_uic_err = val; 168 + } else { 169 + ret = -ENOENT; 170 + } 171 + if (ret == 0) 172 + ufshcd_schedule_eh_work(hba); 173 + spin_unlock_irq(hba->host->host_lock); 174 + 175 + return ret < 0 ? ret : count; 176 + } 177 + 178 + static int ufs_saved_err_open(struct inode *inode, struct file *file) 179 + { 180 + return single_open(file, ufs_saved_err_show, inode->i_private); 181 + } 182 + 183 + static const struct file_operations ufs_saved_err_fops = { 184 + .owner = THIS_MODULE, 185 + .open = ufs_saved_err_open, 186 + .read = seq_read, 187 + .write = ufs_saved_err_write, 188 + .llseek = seq_lseek, 189 + .release = single_release, 190 + }; 191 + 192 + static const struct ufs_debugfs_attr ufs_attrs[] = { 193 + { "stats", 0400, &ufs_debugfs_stats_fops }, 194 + { "saved_err", 0600, &ufs_saved_err_fops }, 195 + { "saved_uic_err", 0600, &ufs_saved_err_fops }, 196 + { } 197 + }; 198 + 141 199 void ufs_debugfs_hba_init(struct ufs_hba *hba) 142 200 { 201 + const struct ufs_debugfs_attr *attr; 202 + struct dentry *root; 203 + 143 204 /* Set default exception event rate limit period to 20ms */ 144 205 hba->debugfs_ee_rate_limit_ms = 20; 145 206 INIT_DELAYED_WORK(&hba->debugfs_ee_work, ufs_debugfs_restart_ee); 146 - hba->debugfs_root = debugfs_create_dir(dev_name(hba->dev), ufs_debugfs_root); 147 - debugfs_create_file("stats", 0400, hba->debugfs_root, hba, &ufs_debugfs_stats_fops); 207 + 208 + root = debugfs_create_dir(dev_name(hba->dev), ufs_debugfs_root); 209 + if (IS_ERR_OR_NULL(root)) 210 + return; 211 + hba->debugfs_root = root; 212 + d_inode(root)->i_private = hba; 213 + for (attr = ufs_attrs; attr->name; attr++) 214 + debugfs_create_file(attr->name, attr->mode, root, (void *)attr, 215 + attr->fops); 148 216 debugfs_create_file("exception_event_mask", 0600, hba->debugfs_root, 149 217 hba, &ee_usr_mask_fops); 150 218 debugfs_create_u32("exception_event_rate_limit_ms", 0600, hba->debugfs_root,
+334 -20
drivers/scsi/ufs/ufs-exynos.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 14 #include <linux/of_address.h> 15 + #include <linux/mfd/syscon.h> 15 16 #include <linux/phy/phy.h> 16 17 #include <linux/platform_device.h> 18 + #include <linux/regmap.h> 17 19 18 20 #include "ufshcd.h" 19 21 #include "ufshcd-pltfrm.h" ··· 50 48 #define HCI_ERR_EN_T_LAYER 0x84 51 49 #define HCI_ERR_EN_DME_LAYER 0x88 52 50 #define HCI_CLKSTOP_CTRL 0xB0 51 + #define REFCLKOUT_STOP BIT(4) 53 52 #define REFCLK_STOP BIT(2) 54 53 #define UNIPRO_MCLK_STOP BIT(1) 55 54 #define UNIPRO_PCLK_STOP BIT(0) 56 - #define CLK_STOP_MASK (REFCLK_STOP |\ 55 + #define CLK_STOP_MASK (REFCLKOUT_STOP | REFCLK_STOP |\ 57 56 UNIPRO_MCLK_STOP |\ 58 57 UNIPRO_PCLK_STOP) 59 58 #define HCI_MISC 0xB4 ··· 76 73 UIC_TRANSPORT_UNKNOWN_CPORTID |\ 77 74 UIC_TRANSPORT_NO_CONNECTION_RX |\ 78 75 UIC_TRANSPORT_BAD_TC) 76 + 77 + /* FSYS UFS Shareability */ 78 + #define UFS_WR_SHARABLE BIT(2) 79 + #define UFS_RD_SHARABLE BIT(1) 80 + #define UFS_SHARABLE (UFS_WR_SHARABLE | UFS_RD_SHARABLE) 81 + #define UFS_SHAREABILITY_OFFSET 0x710 82 + 83 + /* Multi-host registers */ 84 + #define MHCTRL 0xC4 85 + #define MHCTRL_EN_VH_MASK (0xE) 86 + #define MHCTRL_EN_VH(vh) (vh << 1) 87 + #define PH2VH_MBOX 0xD8 88 + 89 + #define MH_MSG_MASK (0xFF) 90 + 91 + #define MH_MSG(id, msg) ((id << 8) | (msg & 0xFF)) 92 + #define MH_MSG_PH_READY 0x1 93 + #define MH_MSG_VH_READY 0x2 94 + 95 + #define ALLOW_INQUIRY BIT(25) 96 + #define ALLOW_MODE_SELECT BIT(24) 97 + #define ALLOW_MODE_SENSE BIT(23) 98 + #define ALLOW_PRE_FETCH GENMASK(22, 21) 99 + #define ALLOW_READ_CMD_ALL GENMASK(20, 18) /* read_6/10/16 */ 100 + #define ALLOW_READ_BUFFER BIT(17) 101 + #define ALLOW_READ_CAPACITY GENMASK(16, 15) 102 + #define ALLOW_REPORT_LUNS BIT(14) 103 + #define ALLOW_REQUEST_SENSE BIT(13) 104 + #define ALLOW_SYNCHRONIZE_CACHE GENMASK(8, 7) 105 + #define ALLOW_TEST_UNIT_READY BIT(6) 106 + #define ALLOW_UNMAP BIT(5) 107 + #define ALLOW_VERIFY BIT(4) 108 + #define ALLOW_WRITE_CMD_ALL GENMASK(3, 1) /* write_6/10/16 */ 109 + 110 + #define ALLOW_TRANS_VH_DEFAULT (ALLOW_INQUIRY | ALLOW_MODE_SELECT | \ 111 + ALLOW_MODE_SENSE | ALLOW_PRE_FETCH | \ 112 + ALLOW_READ_CMD_ALL | ALLOW_READ_BUFFER | \ 113 + ALLOW_READ_CAPACITY | ALLOW_REPORT_LUNS | \ 114 + ALLOW_REQUEST_SENSE | ALLOW_SYNCHRONIZE_CACHE | \ 115 + ALLOW_TEST_UNIT_READY | ALLOW_UNMAP | \ 116 + ALLOW_VERIFY | ALLOW_WRITE_CMD_ALL) 117 + 118 + #define HCI_MH_ALLOWABLE_TRAN_OF_VH 0x30C 119 + #define HCI_MH_IID_IN_TASK_TAG 0X308 120 + 121 + #define PH_READY_TIMEOUT_MS (5 * MSEC_PER_SEC) 79 122 80 123 enum { 81 124 UNIPRO_L1_5 = 0,/* PHY Adapter */ ··· 195 146 196 147 static int exynos7_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs) 197 148 { 149 + return 0; 150 + } 151 + 152 + static int exynosauto_ufs_drv_init(struct device *dev, struct exynos_ufs *ufs) 153 + { 154 + struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr; 155 + 156 + /* IO Coherency setting */ 157 + if (ufs->sysreg) { 158 + return regmap_update_bits(ufs->sysreg, 159 + ufs->shareability_reg_offset, 160 + UFS_SHARABLE, UFS_SHARABLE); 161 + } 162 + 163 + attr->tx_dif_p_nsec = 3200000; 164 + 165 + return 0; 166 + } 167 + 168 + static int exynosauto_ufs_post_hce_enable(struct exynos_ufs *ufs) 169 + { 170 + struct ufs_hba *hba = ufs->hba; 171 + 172 + /* Enable Virtual Host #1 */ 173 + ufshcd_rmwl(hba, MHCTRL_EN_VH_MASK, MHCTRL_EN_VH(1), MHCTRL); 174 + /* Default VH Transfer permissions */ 175 + hci_writel(ufs, ALLOW_TRANS_VH_DEFAULT, HCI_MH_ALLOWABLE_TRAN_OF_VH); 176 + /* IID information is replaced in TASKTAG[7:5] instead of IID in UCD */ 177 + hci_writel(ufs, 0x1, HCI_MH_IID_IN_TASK_TAG); 178 + 179 + return 0; 180 + } 181 + 182 + static int exynosauto_ufs_pre_link(struct exynos_ufs *ufs) 183 + { 184 + struct ufs_hba *hba = ufs->hba; 185 + int i; 186 + u32 tx_line_reset_period, rx_line_reset_period; 187 + 188 + rx_line_reset_period = (RX_LINE_RESET_TIME * ufs->mclk_rate) / NSEC_PER_MSEC; 189 + tx_line_reset_period = (TX_LINE_RESET_TIME * ufs->mclk_rate) / NSEC_PER_MSEC; 190 + 191 + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x40); 192 + for_each_ufs_rx_lane(ufs, i) { 193 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_CLK_PRD, i), 194 + DIV_ROUND_UP(NSEC_PER_SEC, ufs->mclk_rate)); 195 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_CLK_PRD_EN, i), 0x0); 196 + 197 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE2, i), 198 + (rx_line_reset_period >> 16) & 0xFF); 199 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE1, i), 200 + (rx_line_reset_period >> 8) & 0xFF); 201 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_RX_LINERESET_VALUE0, i), 202 + (rx_line_reset_period) & 0xFF); 203 + 204 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x2f, i), 0x79); 205 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x84, i), 0x1); 206 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x25, i), 0xf6); 207 + } 208 + 209 + for_each_ufs_tx_lane(ufs, i) { 210 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_CLK_PRD, i), 211 + DIV_ROUND_UP(NSEC_PER_SEC, ufs->mclk_rate)); 212 + /* Not to affect VND_TX_LINERESET_PVALUE to VND_TX_CLK_PRD */ 213 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_CLK_PRD_EN, i), 214 + 0x02); 215 + 216 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE2, i), 217 + (tx_line_reset_period >> 16) & 0xFF); 218 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE1, i), 219 + (tx_line_reset_period >> 8) & 0xFF); 220 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VND_TX_LINERESET_PVALUE0, i), 221 + (tx_line_reset_period) & 0xFF); 222 + 223 + /* TX PWM Gear Capability / PWM_G1_ONLY */ 224 + ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x04, i), 0x1); 225 + } 226 + 227 + ufshcd_dme_set(hba, UIC_ARG_MIB(0x200), 0x0); 228 + 229 + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0x0); 230 + 231 + ufshcd_dme_set(hba, UIC_ARG_MIB(0xa011), 0x8000); 232 + 233 + return 0; 234 + } 235 + 236 + static int exynosauto_ufs_pre_pwr_change(struct exynos_ufs *ufs, 237 + struct ufs_pa_layer_attr *pwr) 238 + { 239 + struct ufs_hba *hba = ufs->hba; 240 + 241 + /* PACP_PWR_req and delivered to the remote DME */ 242 + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), 12000); 243 + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), 32000); 244 + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA2), 16000); 245 + 246 + return 0; 247 + } 248 + 249 + static int exynosauto_ufs_post_pwr_change(struct exynos_ufs *ufs, 250 + struct ufs_pa_layer_attr *pwr) 251 + { 252 + struct ufs_hba *hba = ufs->hba; 253 + u32 enabled_vh; 254 + 255 + enabled_vh = ufshcd_readl(hba, MHCTRL) & MHCTRL_EN_VH_MASK; 256 + 257 + /* Send physical host ready message to virtual hosts */ 258 + ufshcd_writel(hba, MH_MSG(enabled_vh, MH_MSG_PH_READY), PH2VH_MBOX); 259 + 198 260 return 0; 199 261 } 200 262 ··· 953 793 } 954 794 } 955 795 796 + static int exynos_ufs_setup_clocks(struct ufs_hba *hba, bool on, 797 + enum ufs_notify_change_status status) 798 + { 799 + struct exynos_ufs *ufs = ufshcd_get_variant(hba); 800 + 801 + if (!ufs) 802 + return 0; 803 + 804 + if (on && status == PRE_CHANGE) { 805 + if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL) 806 + exynos_ufs_disable_auto_ctrl_hcc(ufs); 807 + exynos_ufs_ungate_clks(ufs); 808 + } else if (!on && status == POST_CHANGE) { 809 + exynos_ufs_gate_clks(ufs); 810 + if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL) 811 + exynos_ufs_enable_auto_ctrl_hcc(ufs); 812 + } 813 + 814 + return 0; 815 + } 816 + 956 817 static int exynos_ufs_pre_link(struct ufs_hba *hba) 957 818 { 958 819 struct exynos_ufs *ufs = ufshcd_get_variant(hba); ··· 989 808 990 809 /* m-phy */ 991 810 exynos_ufs_phy_init(ufs); 992 - exynos_ufs_config_phy_time_attr(ufs); 993 - exynos_ufs_config_phy_cap_attr(ufs); 811 + if (!(ufs->opts & EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR)) { 812 + exynos_ufs_config_phy_time_attr(ufs); 813 + exynos_ufs_config_phy_cap_attr(ufs); 814 + } 815 + 816 + exynos_ufs_setup_clocks(hba, true, PRE_CHANGE); 994 817 995 818 if (ufs->drv_data->pre_link) 996 819 ufs->drv_data->pre_link(ufs); ··· 1078 893 static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs) 1079 894 { 1080 895 struct device_node *np = dev->of_node; 1081 - struct exynos_ufs_drv_data *drv_data = &exynos_ufs_drvs; 1082 896 struct exynos_ufs_uic_attr *attr; 1083 897 int ret = 0; 1084 898 1085 - while (drv_data->compatible) { 1086 - if (of_device_is_compatible(np, drv_data->compatible)) { 1087 - ufs->drv_data = drv_data; 1088 - break; 1089 - } 1090 - drv_data++; 1091 - } 899 + ufs->drv_data = device_get_match_data(dev); 1092 900 1093 901 if (ufs->drv_data && ufs->drv_data->uic_attr) { 1094 902 attr = ufs->drv_data->uic_attr; ··· 1089 911 dev_err(dev, "failed to get uic attributes\n"); 1090 912 ret = -EINVAL; 1091 913 goto out; 914 + } 915 + 916 + ufs->sysreg = syscon_regmap_lookup_by_phandle(np, "samsung,sysreg"); 917 + if (IS_ERR(ufs->sysreg)) 918 + ufs->sysreg = NULL; 919 + else { 920 + if (of_property_read_u32_index(np, "samsung,sysreg", 1, 921 + &ufs->shareability_reg_offset)) { 922 + dev_warn(dev, "can't get an offset from sysreg. Set to default value\n"); 923 + ufs->shareability_reg_offset = UFS_SHAREABILITY_OFFSET; 924 + } 1092 925 } 1093 926 1094 927 ufs->pclk_avail_min = PCLK_AVAIL_MIN; ··· 1114 925 1115 926 out: 1116 927 return ret; 928 + } 929 + 930 + static inline void exynos_ufs_priv_init(struct ufs_hba *hba, 931 + struct exynos_ufs *ufs) 932 + { 933 + ufs->hba = hba; 934 + ufs->opts = ufs->drv_data->opts; 935 + ufs->rx_sel_idx = PA_MAXDATALANES; 936 + if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX) 937 + ufs->rx_sel_idx = 0; 938 + hba->priv = (void *)ufs; 939 + hba->quirks = ufs->drv_data->quirks; 1117 940 } 1118 941 1119 942 static int exynos_ufs_init(struct ufs_hba *hba) ··· 1177 976 if (ret) 1178 977 goto phy_off; 1179 978 1180 - ufs->hba = hba; 1181 - ufs->opts = ufs->drv_data->opts; 1182 - ufs->rx_sel_idx = PA_MAXDATALANES; 1183 - if (ufs->opts & EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX) 1184 - ufs->rx_sel_idx = 0; 1185 - hba->priv = (void *)ufs; 1186 - hba->quirks = ufs->drv_data->quirks; 979 + exynos_ufs_priv_init(hba, ufs); 980 + 1187 981 if (ufs->drv_data->drv_init) { 1188 982 ret = ufs->drv_data->drv_init(dev, ufs); 1189 983 if (ret) { ··· 1306 1110 1307 1111 switch (status) { 1308 1112 case PRE_CHANGE: 1113 + if (ufs->drv_data->pre_hce_enable) { 1114 + ret = ufs->drv_data->pre_hce_enable(ufs); 1115 + if (ret) 1116 + return ret; 1117 + } 1118 + 1309 1119 ret = exynos_ufs_host_reset(hba); 1310 1120 if (ret) 1311 1121 return ret; ··· 1321 1119 exynos_ufs_calc_pwm_clk_div(ufs); 1322 1120 if (!(ufs->opts & EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL)) 1323 1121 exynos_ufs_enable_auto_ctrl_hcc(ufs); 1122 + 1123 + if (ufs->drv_data->post_hce_enable) 1124 + ret = ufs->drv_data->post_hce_enable(ufs); 1125 + 1324 1126 break; 1325 1127 } 1326 1128 ··· 1408 1202 return 0; 1409 1203 } 1410 1204 1205 + static int exynosauto_ufs_vh_link_startup_notify(struct ufs_hba *hba, 1206 + enum ufs_notify_change_status status) 1207 + { 1208 + if (status == POST_CHANGE) { 1209 + ufshcd_set_link_active(hba); 1210 + ufshcd_set_ufs_dev_active(hba); 1211 + } 1212 + 1213 + return 0; 1214 + } 1215 + 1216 + static int exynosauto_ufs_vh_wait_ph_ready(struct ufs_hba *hba) 1217 + { 1218 + u32 mbox; 1219 + ktime_t start, stop; 1220 + 1221 + start = ktime_get(); 1222 + stop = ktime_add(start, ms_to_ktime(PH_READY_TIMEOUT_MS)); 1223 + 1224 + do { 1225 + mbox = ufshcd_readl(hba, PH2VH_MBOX); 1226 + /* TODO: Mailbox message protocols between the PH and VHs are 1227 + * not implemented yet. This will be supported later 1228 + */ 1229 + if ((mbox & MH_MSG_MASK) == MH_MSG_PH_READY) 1230 + return 0; 1231 + 1232 + usleep_range(40, 50); 1233 + } while (ktime_before(ktime_get(), stop)); 1234 + 1235 + return -ETIME; 1236 + } 1237 + 1238 + static int exynosauto_ufs_vh_init(struct ufs_hba *hba) 1239 + { 1240 + struct device *dev = hba->dev; 1241 + struct platform_device *pdev = to_platform_device(dev); 1242 + struct exynos_ufs *ufs; 1243 + int ret; 1244 + 1245 + ufs = devm_kzalloc(dev, sizeof(*ufs), GFP_KERNEL); 1246 + if (!ufs) 1247 + return -ENOMEM; 1248 + 1249 + /* exynos-specific hci */ 1250 + ufs->reg_hci = devm_platform_ioremap_resource_byname(pdev, "vs_hci"); 1251 + if (IS_ERR(ufs->reg_hci)) { 1252 + dev_err(dev, "cannot ioremap for hci vendor register\n"); 1253 + return PTR_ERR(ufs->reg_hci); 1254 + } 1255 + 1256 + ret = exynosauto_ufs_vh_wait_ph_ready(hba); 1257 + if (ret) 1258 + return ret; 1259 + 1260 + ufs->drv_data = device_get_match_data(dev); 1261 + if (!ufs->drv_data) 1262 + return -ENODEV; 1263 + 1264 + exynos_ufs_priv_init(hba, ufs); 1265 + 1266 + return 0; 1267 + } 1268 + 1411 1269 static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { 1412 1270 .name = "exynos_ufs", 1413 1271 .init = exynos_ufs_init, 1414 1272 .hce_enable_notify = exynos_ufs_hce_enable_notify, 1415 1273 .link_startup_notify = exynos_ufs_link_startup_notify, 1416 1274 .pwr_change_notify = exynos_ufs_pwr_change_notify, 1275 + .setup_clocks = exynos_ufs_setup_clocks, 1417 1276 .setup_xfer_req = exynos_ufs_specify_nexus_t_xfer_req, 1418 1277 .setup_task_mgmt = exynos_ufs_specify_nexus_t_tm_req, 1419 1278 .hibern8_notify = exynos_ufs_hibern8_notify, ··· 1486 1215 .resume = exynos_ufs_resume, 1487 1216 }; 1488 1217 1218 + static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = { 1219 + .name = "exynosauto_ufs_vh", 1220 + .init = exynosauto_ufs_vh_init, 1221 + .link_startup_notify = exynosauto_ufs_vh_link_startup_notify, 1222 + }; 1223 + 1489 1224 static int exynos_ufs_probe(struct platform_device *pdev) 1490 1225 { 1491 1226 int err; 1492 1227 struct device *dev = &pdev->dev; 1228 + const struct ufs_hba_variant_ops *vops = &ufs_hba_exynos_ops; 1229 + const struct exynos_ufs_drv_data *drv_data = 1230 + device_get_match_data(dev); 1493 1231 1494 - err = ufshcd_pltfrm_init(pdev, &ufs_hba_exynos_ops); 1232 + if (drv_data && drv_data->vops) 1233 + vops = drv_data->vops; 1234 + 1235 + err = ufshcd_pltfrm_init(pdev, vops); 1495 1236 if (err) 1496 1237 dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err); 1497 1238 ··· 1544 1261 .pa_dbg_option_suite = 0x30103, 1545 1262 }; 1546 1263 1264 + static struct exynos_ufs_drv_data exynosauto_ufs_drvs = { 1265 + .uic_attr = &exynos7_uic_attr, 1266 + .quirks = UFSHCD_QUIRK_PRDT_BYTE_GRAN | 1267 + UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR | 1268 + UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR | 1269 + UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING, 1270 + .opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL | 1271 + EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR | 1272 + EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX, 1273 + .drv_init = exynosauto_ufs_drv_init, 1274 + .post_hce_enable = exynosauto_ufs_post_hce_enable, 1275 + .pre_link = exynosauto_ufs_pre_link, 1276 + .pre_pwr_change = exynosauto_ufs_pre_pwr_change, 1277 + .post_pwr_change = exynosauto_ufs_post_pwr_change, 1278 + }; 1279 + 1280 + static struct exynos_ufs_drv_data exynosauto_ufs_vh_drvs = { 1281 + .vops = &ufs_hba_exynosauto_vh_ops, 1282 + .quirks = UFSHCD_QUIRK_PRDT_BYTE_GRAN | 1283 + UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR | 1284 + UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR | 1285 + UFSHCI_QUIRK_BROKEN_HCE | 1286 + UFSHCD_QUIRK_BROKEN_UIC_CMD | 1287 + UFSHCD_QUIRK_SKIP_PH_CONFIGURATION | 1288 + UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING, 1289 + .opts = EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX, 1290 + }; 1291 + 1547 1292 static struct exynos_ufs_drv_data exynos_ufs_drvs = { 1548 - .compatible = "samsung,exynos7-ufs", 1549 1293 .uic_attr = &exynos7_uic_attr, 1550 1294 .quirks = UFSHCD_QUIRK_PRDT_BYTE_GRAN | 1551 1295 UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR | ··· 1597 1287 static const struct of_device_id exynos_ufs_of_match[] = { 1598 1288 { .compatible = "samsung,exynos7-ufs", 1599 1289 .data = &exynos_ufs_drvs }, 1290 + { .compatible = "samsung,exynosautov9-ufs", 1291 + .data = &exynosauto_ufs_drvs }, 1292 + { .compatible = "samsung,exynosautov9-ufs-vh", 1293 + .data = &exynosauto_ufs_vh_drvs }, 1600 1294 {}, 1601 1295 }; 1602 1296
+24 -3
drivers/scsi/ufs/ufs-exynos.h
··· 56 56 #define TX_GRAN_NVAL_10_08 0x0296 57 57 #define TX_GRAN_NVAL_H(v) (((v) >> 8) & 0x3) 58 58 59 + #define VND_TX_CLK_PRD 0xAA 60 + #define VND_TX_CLK_PRD_EN 0xA9 61 + #define VND_TX_LINERESET_PVALUE0 0xAD 62 + #define VND_TX_LINERESET_PVALUE1 0xAC 63 + #define VND_TX_LINERESET_PVALUE2 0xAB 64 + 65 + #define TX_LINE_RESET_TIME 3200 66 + 67 + #define VND_RX_CLK_PRD 0x12 68 + #define VND_RX_CLK_PRD_EN 0x11 69 + #define VND_RX_LINERESET_VALUE0 0x1D 70 + #define VND_RX_LINERESET_VALUE1 0x1C 71 + #define VND_RX_LINERESET_VALUE2 0x1B 72 + 73 + #define RX_LINE_RESET_TIME 1000 74 + 59 75 #define RX_FILLER_ENABLE 0x0316 60 76 #define RX_FILLER_EN (1 << 1) 61 77 #define RX_LINERESET_VAL 0x0317 ··· 115 99 #define PA_HIBERN8TIME_VAL 0x20 116 100 117 101 #define PCLK_AVAIL_MIN 70000000 118 - #define PCLK_AVAIL_MAX 133000000 102 + #define PCLK_AVAIL_MAX 167000000 119 103 120 104 struct exynos_ufs_uic_attr { 121 105 /* TX Attributes */ ··· 158 142 }; 159 143 160 144 struct exynos_ufs_drv_data { 161 - char *compatible; 145 + const struct ufs_hba_variant_ops *vops; 162 146 struct exynos_ufs_uic_attr *uic_attr; 163 147 unsigned int quirks; 164 148 unsigned int opts; ··· 170 154 struct ufs_pa_layer_attr *pwr); 171 155 int (*post_pwr_change)(struct exynos_ufs *ufs, 172 156 struct ufs_pa_layer_attr *pwr); 157 + int (*pre_hce_enable)(struct exynos_ufs *ufs); 158 + int (*post_hce_enable)(struct exynos_ufs *ufs); 173 159 }; 174 160 175 161 struct ufs_phy_time_cfg { ··· 209 191 struct ufs_pa_layer_attr dev_req_params; 210 192 struct ufs_phy_time_cfg t_cfg; 211 193 ktime_t entry_hibern8_t; 212 - struct exynos_ufs_drv_data *drv_data; 194 + const struct exynos_ufs_drv_data *drv_data; 195 + struct regmap *sysreg; 196 + u32 shareability_reg_offset; 213 197 214 198 u32 opts; 215 199 #define EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL BIT(0) ··· 219 199 #define EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL BIT(2) 220 200 #define EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX BIT(3) 221 201 #define EXYNOS_UFS_OPT_USE_SW_HIBERN8_TIMER BIT(4) 202 + #define EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR BIT(5) 222 203 }; 223 204 224 205 #define for_each_ufs_rx_lane(ufs, i) \
+70 -38
drivers/scsi/ufs/ufshcd.c
··· 132 132 UFSHCD_CAN_QUEUE = 32, 133 133 }; 134 134 135 + static const char *const ufshcd_state_name[] = { 136 + [UFSHCD_STATE_RESET] = "reset", 137 + [UFSHCD_STATE_OPERATIONAL] = "operational", 138 + [UFSHCD_STATE_ERROR] = "error", 139 + [UFSHCD_STATE_EH_SCHEDULED_FATAL] = "eh_fatal", 140 + [UFSHCD_STATE_EH_SCHEDULED_NON_FATAL] = "eh_non_fatal", 141 + }; 142 + 135 143 /* UFSHCD error handling flags */ 136 144 enum { 137 145 UFSHCD_EH_IN_PROGRESS = (1 << 0), ··· 244 236 static irqreturn_t ufshcd_intr(int irq, void *__hba); 245 237 static int ufshcd_change_power_mode(struct ufs_hba *hba, 246 238 struct ufs_pa_layer_attr *pwr_mode); 247 - static void ufshcd_schedule_eh_work(struct ufs_hba *hba); 248 239 static int ufshcd_setup_hba_vreg(struct ufs_hba *hba, bool on); 249 240 static int ufshcd_setup_vreg(struct ufs_hba *hba, bool on); 250 241 static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, ··· 718 711 * This function is used to get the OCS field from UTRD 719 712 * Returns the OCS field in the UTRD 720 713 */ 721 - static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) 714 + static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) 722 715 { 723 716 return le32_to_cpu(lrbp->utr_descriptor_ptr->header.dword_2) & MASK_OCS; 724 717 } ··· 2330 2323 int ret; 2331 2324 unsigned long flags; 2332 2325 2326 + if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD) 2327 + return 0; 2328 + 2333 2329 ufshcd_hold(hba, false); 2334 2330 mutex_lock(&hba->uic_cmd_mutex); 2335 2331 ufshcd_add_delay_before_dme_cmd(hba); ··· 2377 2367 sizeof(struct ufshcd_sg_entry))); 2378 2368 else 2379 2369 lrbp->utr_descriptor_ptr->prd_table_length = 2380 - cpu_to_le16((u16) (sg_segments)); 2370 + cpu_to_le16(sg_segments); 2381 2371 2382 - prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr; 2372 + prd_table = lrbp->ucd_prdt_ptr; 2383 2373 2384 2374 scsi_for_each_sg(cmd, sg, sg_segments, i) { 2385 - prd_table[i].size = 2386 - cpu_to_le32(((u32) sg_dma_len(sg))-1); 2387 - prd_table[i].base_addr = 2388 - cpu_to_le32(lower_32_bits(sg->dma_address)); 2389 - prd_table[i].upper_addr = 2390 - cpu_to_le32(upper_32_bits(sg->dma_address)); 2375 + const unsigned int len = sg_dma_len(sg); 2376 + 2377 + /* 2378 + * From the UFSHCI spec: "Data Byte Count (DBC): A '0' 2379 + * based value that indicates the length, in bytes, of 2380 + * the data block. A maximum of length of 256KB may 2381 + * exist for any entry. Bits 1:0 of this field shall be 2382 + * 11b to indicate Dword granularity. A value of '3' 2383 + * indicates 4 bytes, '7' indicates 8 bytes, etc." 2384 + */ 2385 + WARN_ONCE(len > 256 * 1024, "len = %#x\n", len); 2386 + prd_table[i].size = cpu_to_le32(len - 1); 2387 + prd_table[i].addr = cpu_to_le64(sg->dma_address); 2391 2388 prd_table[i].reserved = 0; 2392 2389 } 2393 2390 } else { ··· 2678 2661 lrb->ucd_req_dma_addr = cmd_desc_element_addr; 2679 2662 lrb->ucd_rsp_ptr = (struct utp_upiu_rsp *)cmd_descp[i].response_upiu; 2680 2663 lrb->ucd_rsp_dma_addr = cmd_desc_element_addr + response_offset; 2681 - lrb->ucd_prdt_ptr = (struct ufshcd_sg_entry *)cmd_descp[i].prd_table; 2664 + lrb->ucd_prdt_ptr = cmd_descp[i].prd_table; 2682 2665 lrb->ucd_prdt_dma_addr = cmd_desc_element_addr + prdt_offset; 2683 2666 } 2684 2667 ··· 5101 5084 { 5102 5085 int result = 0; 5103 5086 int scsi_status; 5104 - int ocs; 5087 + enum utp_ocs ocs; 5105 5088 5106 5089 /* overall command status of utrd */ 5107 5090 ocs = ufshcd_get_tr_ocs(lrbp); ··· 5260 5243 * __ufshcd_transfer_req_compl - handle SCSI and query command completion 5261 5244 * @hba: per adapter instance 5262 5245 * @completed_reqs: bitmask that indicates which requests to complete 5263 - * @retry_requests: whether to ask the SCSI core to retry completed requests 5264 5246 */ 5265 5247 static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, 5266 - unsigned long completed_reqs, 5267 - bool retry_requests) 5248 + unsigned long completed_reqs) 5268 5249 { 5269 5250 struct ufshcd_lrb *lrbp; 5270 5251 struct scsi_cmnd *cmd; ··· 5278 5263 if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) 5279 5264 ufshcd_update_monitor(hba, lrbp); 5280 5265 ufshcd_add_command_trace(hba, index, UFS_CMD_COMP); 5281 - result = retry_requests ? DID_BUS_BUSY << 16 : 5282 - ufshcd_transfer_rsp_status(hba, lrbp); 5266 + result = ufshcd_transfer_rsp_status(hba, lrbp); 5283 5267 scsi_dma_unmap(cmd); 5284 5268 cmd->result = result; 5285 5269 /* Mark completed command as NULL in LRB */ ··· 5304 5290 /** 5305 5291 * ufshcd_transfer_req_compl - handle SCSI and query command completion 5306 5292 * @hba: per adapter instance 5307 - * @retry_requests: whether or not to ask to retry requests 5308 5293 * 5309 5294 * Returns 5310 5295 * IRQ_HANDLED - If interrupt is valid 5311 5296 * IRQ_NONE - If invalid interrupt 5312 5297 */ 5313 - static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba, 5314 - bool retry_requests) 5298 + static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) 5315 5299 { 5316 5300 unsigned long completed_reqs, flags; 5317 5301 u32 tr_doorbell; ··· 5338 5326 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 5339 5327 5340 5328 if (completed_reqs) { 5341 - __ufshcd_transfer_req_compl(hba, completed_reqs, 5342 - retry_requests); 5329 + __ufshcd_transfer_req_compl(hba, completed_reqs); 5343 5330 return IRQ_HANDLED; 5344 5331 } else { 5345 5332 return IRQ_NONE; ··· 5837 5826 /* Complete requests that have door-bell cleared */ 5838 5827 static void ufshcd_complete_requests(struct ufs_hba *hba) 5839 5828 { 5840 - ufshcd_transfer_req_compl(hba, /*retry_requests=*/false); 5841 - ufshcd_tmc_handler(hba); 5842 - } 5843 - 5844 - static void ufshcd_retry_aborted_requests(struct ufs_hba *hba) 5845 - { 5846 - ufshcd_transfer_req_compl(hba, /*retry_requests=*/true); 5829 + ufshcd_transfer_req_compl(hba); 5847 5830 ufshcd_tmc_handler(hba); 5848 5831 } 5849 5832 ··· 5919 5914 (hba->saved_err & (INT_FATAL_ERRORS | UFSHCD_UIC_HIBERN8_MASK)); 5920 5915 } 5921 5916 5922 - /* host lock must be held before calling this func */ 5923 - static inline void ufshcd_schedule_eh_work(struct ufs_hba *hba) 5917 + void ufshcd_schedule_eh_work(struct ufs_hba *hba) 5924 5918 { 5919 + lockdep_assert_held(hba->host->host_lock); 5920 + 5925 5921 /* handle fatal errors only when link is not in error state */ 5926 5922 if (hba->ufshcd_state != UFSHCD_STATE_ERROR) { 5927 5923 if (hba->force_reset || ufshcd_is_link_broken(hba) || ··· 6082 6076 6083 6077 hba = container_of(work, struct ufs_hba, eh_work); 6084 6078 6079 + dev_info(hba->dev, 6080 + "%s started; HBA state %s; powered %d; shutting down %d; saved_err = %d; saved_uic_err = %d; force_reset = %d%s\n", 6081 + __func__, ufshcd_state_name[hba->ufshcd_state], 6082 + hba->is_powered, hba->shutting_down, hba->saved_err, 6083 + hba->saved_uic_err, hba->force_reset, 6084 + ufshcd_is_link_broken(hba) ? "; link is broken" : ""); 6085 + 6085 6086 down(&hba->host_sem); 6086 6087 spin_lock_irqsave(hba->host->host_lock, flags); 6087 6088 if (ufshcd_err_handling_should_stop(hba)) { ··· 6183 6170 err_xfer = true; 6184 6171 goto lock_skip_pending_xfer_clear; 6185 6172 } 6173 + dev_err(hba->dev, "Aborted tag %d / CDB %#02x\n", tag, 6174 + hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0] : -1); 6186 6175 } 6187 6176 6188 6177 /* Clear pending task management requests */ ··· 6196 6181 } 6197 6182 6198 6183 lock_skip_pending_xfer_clear: 6199 - ufshcd_retry_aborted_requests(hba); 6184 + /* Complete the requests that are cleared by s/w */ 6185 + ufshcd_complete_requests(hba); 6200 6186 6201 6187 spin_lock_irqsave(hba->host->host_lock, flags); 6202 6188 hba->silence_err_logs = false; ··· 6265 6249 spin_unlock_irqrestore(hba->host->host_lock, flags); 6266 6250 ufshcd_err_handling_unprepare(hba); 6267 6251 up(&hba->host_sem); 6252 + 6253 + dev_info(hba->dev, "%s finished; HBA state %s\n", __func__, 6254 + ufshcd_state_name[hba->ufshcd_state]); 6268 6255 } 6269 6256 6270 6257 /** ··· 6492 6473 retval |= ufshcd_tmc_handler(hba); 6493 6474 6494 6475 if (intr_status & UTP_TRANSFER_REQ_COMPL) 6495 - retval |= ufshcd_transfer_req_compl(hba, /*retry_requests=*/false); 6476 + retval |= ufshcd_transfer_req_compl(hba); 6496 6477 6497 6478 return retval; 6498 6479 } ··· 6564 6545 err = ufshcd_wait_for_register(hba, 6565 6546 REG_UTP_TASK_REQ_DOOR_BELL, 6566 6547 mask, 0, 1000, 1000); 6548 + 6549 + dev_err(hba->dev, "Clearing task management function with tag %d %s\n", 6550 + tag, err ? "succeeded" : "failed"); 6551 + 6567 6552 out: 6568 6553 return err; 6569 6554 } ··· 6660 6637 u8 tm_function, u8 *tm_response) 6661 6638 { 6662 6639 struct utp_task_req_desc treq = { { 0 }, }; 6663 - int ocs_value, err; 6640 + enum utp_ocs ocs_value; 6641 + int err; 6664 6642 6665 6643 /* Configure task request descriptor */ 6666 6644 treq.header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); ··· 6839 6815 int err; 6840 6816 enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY; 6841 6817 struct utp_task_req_desc treq = { { 0 }, }; 6842 - int ocs_value; 6818 + enum utp_ocs ocs_value; 6843 6819 u8 tm_f = be32_to_cpu(req_upiu->header.dword_1) >> 16 & MASK_TM_FUNC; 6844 6820 6845 6821 switch (msgcode) { ··· 6917 6893 err = ufshcd_clear_cmd(hba, pos); 6918 6894 if (err) 6919 6895 break; 6920 - __ufshcd_transfer_req_compl(hba, 1U << pos, false); 6896 + __ufshcd_transfer_req_compl(hba, 1U << pos); 6921 6897 } 6922 6898 } 6923 6899 ··· 7079 7055 dev_err(hba->dev, 7080 7056 "%s: cmd was completed, but without a notifying intr, tag = %d", 7081 7057 __func__, tag); 7082 - __ufshcd_transfer_req_compl(hba, 1UL << tag, /*retry_requests=*/false); 7058 + __ufshcd_transfer_req_compl(hba, 1UL << tag); 7083 7059 goto release; 7084 7060 } 7085 7061 ··· 7145 7121 ufshpb_reset_host(hba); 7146 7122 ufshcd_hba_stop(hba); 7147 7123 hba->silence_err_logs = true; 7148 - ufshcd_retry_aborted_requests(hba); 7124 + ufshcd_complete_requests(hba); 7149 7125 hba->silence_err_logs = false; 7150 7126 7151 7127 /* scale up clocks to max frequency before full reinitialization */ ··· 8024 8000 8025 8001 ret = ufshcd_link_startup(hba); 8026 8002 if (ret) 8003 + goto out; 8004 + 8005 + if (hba->quirks & UFSHCD_QUIRK_SKIP_PH_CONFIGURATION) 8027 8006 goto out; 8028 8007 8029 8008 /* Debug counters initialization */ ··· 9798 9771 static int __init ufshcd_core_init(void) 9799 9772 { 9800 9773 int ret; 9774 + 9775 + /* Verify that there are no gaps in struct utp_transfer_cmd_desc. */ 9776 + static_assert(sizeof(struct utp_transfer_cmd_desc) == 9777 + 2 * ALIGNED_UPIU_SIZE + 9778 + SG_ALL * sizeof(struct ufshcd_sg_entry)); 9801 9779 9802 9780 ufs_debugfs_init(); 9803 9781
+13
drivers/scsi/ufs/ufshcd.h
··· 589 589 * This quirk allows only sg entries aligned with page size. 590 590 */ 591 591 UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 14, 592 + 593 + /* 594 + * This quirk needs to be enabled if the host controller does not 595 + * support UIC command 596 + */ 597 + UFSHCD_QUIRK_BROKEN_UIC_CMD = 1 << 15, 598 + 599 + /* 600 + * This quirk needs to be enabled if the host controller cannot 601 + * support physical host configuration. 602 + */ 603 + UFSHCD_QUIRK_SKIP_PH_CONFIGURATION = 1 << 16, 592 604 }; 593 605 594 606 enum ufshcd_caps { ··· 1035 1023 void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk); 1036 1024 void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val); 1037 1025 void ufshcd_hba_stop(struct ufs_hba *hba); 1026 + void ufshcd_schedule_eh_work(struct ufs_hba *hba); 1038 1027 1039 1028 static inline void check_upiu_size(void) 1040 1029 {
+8 -7
drivers/scsi/ufs/ufshci.h
··· 389 389 }; 390 390 391 391 /* Overall command status values */ 392 - enum { 392 + enum utp_ocs { 393 393 OCS_SUCCESS = 0x0, 394 394 OCS_INVALID_CMD_TABLE_ATTR = 0x1, 395 395 OCS_INVALID_PRDT_ATTR = 0x2, ··· 402 402 OCS_INVALID_CRYPTO_CONFIG = 0x9, 403 403 OCS_GENERAL_CRYPTO_ERROR = 0xA, 404 404 OCS_INVALID_COMMAND_STATUS = 0x0F, 405 + }; 406 + 407 + enum { 405 408 MASK_OCS = 0x0F, 406 409 }; 407 410 ··· 415 412 416 413 /** 417 414 * struct ufshcd_sg_entry - UFSHCI PRD Entry 418 - * @base_addr: Lower 32bit physical address DW-0 419 - * @upper_addr: Upper 32bit physical address DW-1 415 + * @addr: Physical address; DW-0 and DW-1. 420 416 * @reserved: Reserved for future use DW-2 421 417 * @size: size of physical segment DW-3 422 418 */ 423 419 struct ufshcd_sg_entry { 424 - __le32 base_addr; 425 - __le32 upper_addr; 420 + __le64 addr; 426 421 __le32 reserved; 427 422 __le32 size; 428 423 }; 429 424 430 425 /** 431 - * struct utp_transfer_cmd_desc - UFS Command Descriptor structure 426 + * struct utp_transfer_cmd_desc - UTP Command Descriptor (UCD) 432 427 * @command_upiu: Command UPIU Frame address 433 428 * @response_upiu: Response UPIU Frame address 434 429 * @prd_table: Physical Region Descriptor ··· 452 451 }; 453 452 454 453 /** 455 - * struct utp_transfer_req_desc - UTRD structure 454 + * struct utp_transfer_req_desc - UTP Transfer Request Descriptor (UTRD) 456 455 * @header: UTRD header DW-0 to DW-3 457 456 * @command_desc_base_addr_lo: UCD base address low DW-4 458 457 * @command_desc_base_addr_hi: UCD base address high DW-5
+13 -11
drivers/scsi/ufs/ufshpb.c
··· 394 394 if (!ufshpb_is_supported_chunk(hpb, transfer_len)) 395 395 return 0; 396 396 397 - WARN_ON_ONCE(transfer_len > HPB_MULTI_CHUNK_HIGH); 398 - 399 397 if (hpb->is_hcm) { 400 398 /* 401 399 * in host control mode, reads are the main source for ··· 1570 1572 if (ufshpb_is_legacy(hba)) 1571 1573 hpb->pre_req_max_tr_len = HPB_LEGACY_CHUNK_HIGH; 1572 1574 else 1573 - hpb->pre_req_max_tr_len = HPB_MULTI_CHUNK_HIGH; 1575 + hpb->pre_req_max_tr_len = hpb_dev_info->max_hpb_single_cmd; 1574 1576 1575 1577 hpb->lu_pinned_start = hpb_lu_info->pinned_start; 1576 1578 hpb->lu_pinned_end = hpb_lu_info->num_pinned ? ··· 2580 2582 { 2581 2583 struct ufshpb_dev_info *hpb_dev_info = &hba->ufshpb_dev; 2582 2584 int version, ret; 2583 - u32 max_hpb_single_cmd = HPB_MULTI_CHUNK_LOW; 2585 + int max_single_cmd; 2584 2586 2585 2587 hpb_dev_info->control_mode = desc_buf[DEVICE_DESC_PARAM_HPB_CONTROL]; 2586 2588 ··· 2596 2598 if (version == HPB_SUPPORT_LEGACY_VERSION) 2597 2599 hpb_dev_info->is_legacy = true; 2598 2600 2599 - ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, 2600 - QUERY_ATTR_IDN_MAX_HPB_SINGLE_CMD, 0, 0, &max_hpb_single_cmd); 2601 - if (ret) 2602 - dev_err(hba->dev, "%s: idn: read max size of single hpb cmd query request failed", 2603 - __func__); 2604 - hpb_dev_info->max_hpb_single_cmd = max_hpb_single_cmd; 2605 - 2606 2601 /* 2607 2602 * Get the number of user logical unit to check whether all 2608 2603 * scsi_device finish initialization 2609 2604 */ 2610 2605 hpb_dev_info->num_lu = desc_buf[DEVICE_DESC_PARAM_NUM_LU]; 2606 + 2607 + if (hpb_dev_info->is_legacy) 2608 + return; 2609 + 2610 + ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, 2611 + QUERY_ATTR_IDN_MAX_HPB_SINGLE_CMD, 0, 0, &max_single_cmd); 2612 + 2613 + if (ret) 2614 + hpb_dev_info->max_hpb_single_cmd = HPB_LEGACY_CHUNK_HIGH; 2615 + else 2616 + hpb_dev_info->max_hpb_single_cmd = min(max_single_cmd + 1, HPB_MULTI_CHUNK_HIGH); 2611 2617 } 2612 2618 2613 2619 void ufshpb_init(struct ufs_hba *hba)
-1
drivers/scsi/ufs/ufshpb.h
··· 31 31 32 32 /* hpb support chunk size */ 33 33 #define HPB_LEGACY_CHUNK_HIGH 1 34 - #define HPB_MULTI_CHUNK_LOW 7 35 34 #define HPB_MULTI_CHUNK_HIGH 255 36 35 37 36 /* hpb vender defined opcode */
+1 -16
drivers/target/target_core_tmr.c
··· 50 50 51 51 void core_tmr_release_req(struct se_tmr_req *tmr) 52 52 { 53 - struct se_device *dev = tmr->tmr_dev; 54 - unsigned long flags; 55 - 56 - if (dev) { 57 - spin_lock_irqsave(&dev->se_tmr_lock, flags); 58 - list_del_init(&tmr->tmr_list); 59 - spin_unlock_irqrestore(&dev->se_tmr_lock, flags); 60 - } 61 - 62 53 kfree(tmr); 63 54 } 64 55 ··· 147 156 se_cmd->state_active = false; 148 157 spin_unlock_irqrestore(&dev->queues[i].lock, flags); 149 158 150 - /* 151 - * Ensure that this ABORT request is visible to the LU 152 - * RESET code. 153 - */ 154 - if (!tmr->tmr_dev) 155 - WARN_ON_ONCE(transport_lookup_tmr_lun(tmr->task_cmd) < 0); 156 - 157 159 if (dev->transport->tmr_notify) 158 160 dev->transport->tmr_notify(dev, TMR_ABORT_TASK, 159 161 &aborted_list); ··· 218 234 } 219 235 220 236 list_move_tail(&tmr_p->tmr_list, &drain_tmr_list); 237 + tmr_p->tmr_dev = NULL; 221 238 } 222 239 spin_unlock_irqrestore(&dev->se_tmr_lock, flags); 223 240
+23 -7
drivers/target/target_core_transport.c
··· 676 676 spin_unlock_irqrestore(&dev->queues[cmd->cpuid].lock, flags); 677 677 } 678 678 679 + static void target_remove_from_tmr_list(struct se_cmd *cmd) 680 + { 681 + struct se_device *dev = NULL; 682 + unsigned long flags; 683 + 684 + if (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) 685 + dev = cmd->se_tmr_req->tmr_dev; 686 + 687 + if (dev) { 688 + spin_lock_irqsave(&dev->se_tmr_lock, flags); 689 + if (cmd->se_tmr_req->tmr_dev) 690 + list_del_init(&cmd->se_tmr_req->tmr_list); 691 + spin_unlock_irqrestore(&dev->se_tmr_lock, flags); 692 + } 693 + } 679 694 /* 680 695 * This function is called by the target core after the target core has 681 696 * finished processing a SCSI command or SCSI TMF. Both the regular command ··· 701 686 static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd) 702 687 { 703 688 unsigned long flags; 704 - 705 - target_remove_from_state_list(cmd); 706 - 707 - /* 708 - * Clear struct se_cmd->se_lun before the handoff to FE. 709 - */ 710 - cmd->se_lun = NULL; 711 689 712 690 spin_lock_irqsave(&cmd->t_state_lock, flags); 713 691 /* ··· 736 728 if (!lun) 737 729 return; 738 730 731 + target_remove_from_state_list(cmd); 732 + target_remove_from_tmr_list(cmd); 733 + 739 734 if (cmpxchg(&cmd->lun_ref_active, true, false)) 740 735 percpu_ref_put(&lun->lun_ref); 736 + 737 + /* 738 + * Clear struct se_cmd->se_lun before the handoff to FE. 739 + */ 740 + cmd->se_lun = NULL; 741 741 } 742 742 743 743 static void target_complete_failure_work(struct work_struct *work)
+1 -1
include/scsi/scsi_cmnd.h
··· 73 73 struct scsi_cmnd { 74 74 struct scsi_request req; 75 75 struct scsi_device *device; 76 - struct list_head eh_entry; /* entry for the host eh_cmd_q */ 76 + struct list_head eh_entry; /* entry for the host eh_abort_list/eh_cmd_q */ 77 77 struct delayed_work abort_work; 78 78 79 79 struct rcu_head rcu;
-6
include/scsi/scsi_device.h
··· 226 226 227 227 struct device sdev_gendev, 228 228 sdev_dev; 229 - /* 230 - * The array size 6 provides space for one attribute group for the 231 - * SCSI core, four attribute groups defined by SCSI LLDs and one 232 - * terminating NULL pointer. 233 - */ 234 - const struct attribute_group *gendev_attr_groups[6]; 235 229 236 230 struct execute_work ew; /* used to get process context on put */ 237 231 struct work_struct requeue_work;
+1
include/scsi/scsi_host.h
··· 551 551 552 552 struct mutex scan_mutex;/* serialize scanning activity */ 553 553 554 + struct list_head eh_abort_list; 554 555 struct list_head eh_cmd_q; 555 556 struct task_struct * ehandler; /* Error recovery thread. */ 556 557 struct completion * eh_action; /* Wait for specific actions on the