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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull more SCSI updates from James Bottomley:
"Mostly small stragglers that missed the initial merge.

Driver updates are qla2xxx and smartpqi (mp3sas has a high diffstat
due to the volatile qualifier removal, fnic due to unused function
removal and sd.c has a lot of code shuffling to remove forward
declarations)"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (38 commits)
scsi: ufs: core: No need to update UPIU.header.flags and lun in advanced RPMB handler
scsi: ufs: core: Add advanced RPMB support where UFSHCI 4.0 does not support EHS length in UTRD
scsi: mpt3sas: Remove volatile qualifier
scsi: mpt3sas: Perform additional retries if doorbell read returns 0
scsi: libsas: Simplify sas_queue_reset() and remove unused code
scsi: ufs: Fix the build for the old ARM OABI
scsi: qla2xxx: Fix unused variable warning in qla2xxx_process_purls_pkt()
scsi: fnic: Remove unused functions fnic_scsi_host_start/end_tag()
scsi: qla2xxx: Fix spelling mistake "tranport" -> "transport"
scsi: fnic: Replace sgreset tag with max_tag_id
scsi: qla2xxx: Remove unused variables in qla24xx_build_scsi_type_6_iocbs()
scsi: qla2xxx: Fix nvme_fc_rcv_ls_req() undefined error
scsi: smartpqi: Change driver version to 2.1.24-046
scsi: smartpqi: Enhance error messages
scsi: smartpqi: Enhance controller offline notification
scsi: smartpqi: Enhance shutdown notification
scsi: smartpqi: Simplify lun_number assignment
scsi: smartpqi: Rename pciinfo to pci_info
scsi: smartpqi: Rename MACRO to clarify purpose
scsi: smartpqi: Add abort handler
...

+1436 -322
+1 -1
drivers/ata/libata-scsi.c
··· 4752 4752 } 4753 4753 4754 4754 spin_unlock_irqrestore(ap->lock, flags); 4755 - scsi_rescan_device(&(sdev->sdev_gendev)); 4755 + scsi_rescan_device(sdev); 4756 4756 scsi_device_put(sdev); 4757 4757 spin_lock_irqsave(ap->lock, flags); 4758 4758 }
+1 -1
drivers/scsi/aacraid/commsup.c
··· 1451 1451 #endif 1452 1452 break; 1453 1453 } 1454 - scsi_rescan_device(&device->sdev_gendev); 1454 + scsi_rescan_device(device); 1455 1455 break; 1456 1456 1457 1457 default:
+2 -1
drivers/scsi/fnic/fnic.h
··· 27 27 28 28 #define DRV_NAME "fnic" 29 29 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver" 30 - #define DRV_VERSION "1.6.0.55" 30 + #define DRV_VERSION "1.6.0.56" 31 31 #define PFX DRV_NAME ": " 32 32 #define DFX DRV_NAME "%d: " 33 33 ··· 236 236 unsigned int wq_count; 237 237 unsigned int cq_count; 238 238 239 + struct mutex sgreset_mutex; 239 240 struct dentry *fnic_stats_debugfs_host; 240 241 struct dentry *fnic_stats_debugfs_file; 241 242 struct dentry *fnic_reset_debugfs_file;
+9 -44
drivers/scsi/fnic/fnic_scsi.c
··· 2168 2168 } 2169 2169 2170 2170 /* 2171 - * fnic_scsi_host_start_tag 2172 - * Allocates tagid from host's tag list 2173 - **/ 2174 - static inline int 2175 - fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) 2176 - { 2177 - struct request *rq = scsi_cmd_to_rq(sc); 2178 - struct request_queue *q = rq->q; 2179 - struct request *dummy; 2180 - 2181 - dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT); 2182 - if (IS_ERR(dummy)) 2183 - return SCSI_NO_TAG; 2184 - 2185 - rq->tag = dummy->tag; 2186 - sc->host_scribble = (unsigned char *)dummy; 2187 - 2188 - return dummy->tag; 2189 - } 2190 - 2191 - /* 2192 - * fnic_scsi_host_end_tag 2193 - * frees tag allocated by fnic_scsi_host_start_tag. 2194 - **/ 2195 - static inline void 2196 - fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) 2197 - { 2198 - struct request *dummy = (struct request *)sc->host_scribble; 2199 - 2200 - blk_mq_free_request(dummy); 2201 - } 2202 - 2203 - /* 2204 2171 * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN 2205 2172 * fail to get aborted. It calls driver's eh_device_reset with a SCSI command 2206 2173 * on the LUN. ··· 2189 2222 struct reset_stats *reset_stats; 2190 2223 int tag = rq->tag; 2191 2224 DECLARE_COMPLETION_ONSTACK(tm_done); 2192 - int tag_gen_flag = 0; /*to track tags allocated by fnic driver*/ 2193 2225 bool new_sc = 0; 2194 2226 2195 2227 /* Wait for rport to unblock */ ··· 2218 2252 } 2219 2253 2220 2254 fnic_priv(sc)->flags = FNIC_DEVICE_RESET; 2221 - /* Allocate tag if not present */ 2222 2255 2223 2256 if (unlikely(tag < 0)) { 2224 2257 /* 2225 - * Really should fix the midlayer to pass in a proper 2226 - * request for ioctls... 2258 + * For device reset issued through sg3utils, we let 2259 + * only one LUN_RESET to go through and use a special 2260 + * tag equal to max_tag_id so that we don't have to allocate 2261 + * or free it. It won't interact with tags 2262 + * allocated by mid layer. 2227 2263 */ 2228 - tag = fnic_scsi_host_start_tag(fnic, sc); 2229 - if (unlikely(tag == SCSI_NO_TAG)) 2230 - goto fnic_device_reset_end; 2231 - tag_gen_flag = 1; 2264 + mutex_lock(&fnic->sgreset_mutex); 2265 + tag = fnic->fnic_max_tag_id; 2232 2266 new_sc = 1; 2233 2267 } 2234 2268 io_lock = fnic_io_lock_hash(fnic, sc); ··· 2400 2434 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 2401 2435 fnic_flags_and_state(sc)); 2402 2436 2403 - /* free tag if it is allocated */ 2404 - if (unlikely(tag_gen_flag)) 2405 - fnic_scsi_host_end_tag(fnic, sc); 2437 + if (new_sc) 2438 + mutex_unlock(&fnic->sgreset_mutex); 2406 2439 2407 2440 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2408 2441 "Returning from device reset %s\n",
+3 -38
drivers/scsi/libsas/sas_scsi_host.c
··· 386 386 } 387 387 EXPORT_SYMBOL_GPL(sas_get_local_phy); 388 388 389 - static void sas_wait_eh(struct domain_device *dev) 390 - { 391 - struct sas_ha_struct *ha = dev->port->ha; 392 - DEFINE_WAIT(wait); 393 - 394 - if (dev_is_sata(dev)) { 395 - ata_port_wait_eh(dev->sata_dev.ap); 396 - return; 397 - } 398 - retry: 399 - spin_lock_irq(&ha->lock); 400 - 401 - while (test_bit(SAS_DEV_EH_PENDING, &dev->state)) { 402 - prepare_to_wait(&ha->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); 403 - spin_unlock_irq(&ha->lock); 404 - schedule(); 405 - spin_lock_irq(&ha->lock); 406 - } 407 - finish_wait(&ha->eh_wait_q, &wait); 408 - 409 - spin_unlock_irq(&ha->lock); 410 - 411 - /* make sure SCSI EH is complete */ 412 - if (scsi_host_in_recovery(ha->shost)) { 413 - msleep(10); 414 - goto retry; 415 - } 416 - } 417 - 418 - static int sas_queue_reset(struct domain_device *dev, int reset_type, 419 - u64 lun, int wait) 389 + static int sas_queue_reset(struct domain_device *dev, int reset_type, u64 lun) 420 390 { 421 391 struct sas_ha_struct *ha = dev->port->ha; 422 392 int scheduled = 0, tries = 100; ··· 394 424 /* ata: promote lun reset to bus reset */ 395 425 if (dev_is_sata(dev)) { 396 426 sas_ata_schedule_reset(dev); 397 - if (wait) 398 - sas_ata_wait_eh(dev); 399 427 return SUCCESS; 400 428 } 401 429 ··· 410 442 scsi_schedule_eh(ha->shost); 411 443 } 412 444 spin_unlock_irq(&ha->lock); 413 - 414 - if (wait) 415 - sas_wait_eh(dev); 416 445 417 446 if (scheduled) 418 447 return SUCCESS; ··· 463 498 struct sas_internal *i = to_sas_internal(host->transportt); 464 499 465 500 if (current != host->ehandler) 466 - return sas_queue_reset(dev, SAS_DEV_LU_RESET, cmd->device->lun, 0); 501 + return sas_queue_reset(dev, SAS_DEV_LU_RESET, cmd->device->lun); 467 502 468 503 int_to_scsilun(cmd->device->lun, &lun); 469 504 ··· 486 521 struct sas_internal *i = to_sas_internal(host->transportt); 487 522 488 523 if (current != host->ehandler) 489 - return sas_queue_reset(dev, SAS_DEV_RESET, 0, 0); 524 + return sas_queue_reset(dev, SAS_DEV_RESET, 0); 490 525 491 526 if (!i->dft->lldd_I_T_nexus_reset) 492 527 return FAILED;
+1 -1
drivers/scsi/mpt3sas/mpi/mpi2.h
··· 199 199 * 200 200 *****************************************************************************/ 201 201 202 - typedef volatile struct _MPI2_SYSTEM_INTERFACE_REGS { 202 + typedef struct _MPI2_SYSTEM_INTERFACE_REGS { 203 203 U32 Doorbell; /*0x00 */ 204 204 U32 WriteSequence; /*0x04 */ 205 205 U32 HostDiagnostic; /*0x08 */
+35 -15
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 138 138 static void 139 139 _base_clear_outstanding_commands(struct MPT3SAS_ADAPTER *ioc); 140 140 141 + static u32 142 + _base_readl_ext_retry(const void __iomem *addr); 143 + 141 144 /** 142 145 * mpt3sas_base_check_cmd_timeout - Function 143 146 * to check timeout and command termination due ··· 204 201 * while reading the system interface register. 205 202 */ 206 203 static inline u32 207 - _base_readl_aero(const volatile void __iomem *addr) 204 + _base_readl_aero(const void __iomem *addr) 208 205 { 209 206 u32 i = 0, ret_val; 210 207 ··· 216 213 return ret_val; 217 214 } 218 215 216 + static u32 217 + _base_readl_ext_retry(const void __iomem *addr) 218 + { 219 + u32 i, ret_val; 220 + 221 + for (i = 0 ; i < 30 ; i++) { 222 + ret_val = readl(addr); 223 + if (ret_val == 0) 224 + continue; 225 + } 226 + 227 + return ret_val; 228 + } 229 + 219 230 static inline u32 220 - _base_readl(const volatile void __iomem *addr) 231 + _base_readl(const void __iomem *addr) 221 232 { 222 233 return readl(addr); 223 234 } ··· 957 940 958 941 dump_stack(); 959 942 960 - doorbell = ioc->base_readl(&ioc->chip->Doorbell); 943 + doorbell = ioc->base_readl_ext_retry(&ioc->chip->Doorbell); 961 944 if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) { 962 945 mpt3sas_print_fault_code(ioc, doorbell & 963 946 MPI2_DOORBELL_DATA_MASK); ··· 6703 6686 { 6704 6687 u32 s, sc; 6705 6688 6706 - s = ioc->base_readl(&ioc->chip->Doorbell); 6689 + s = ioc->base_readl_ext_retry(&ioc->chip->Doorbell); 6707 6690 sc = s & MPI2_IOC_STATE_MASK; 6708 6691 return cooked ? sc : s; 6709 6692 } ··· 6848 6831 __func__, count, timeout)); 6849 6832 return 0; 6850 6833 } else if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) { 6851 - doorbell = ioc->base_readl(&ioc->chip->Doorbell); 6834 + doorbell = ioc->base_readl_ext_retry(&ioc->chip->Doorbell); 6852 6835 if ((doorbell & MPI2_IOC_STATE_MASK) == 6853 6836 MPI2_IOC_STATE_FAULT) { 6854 6837 mpt3sas_print_fault_code(ioc, doorbell); ··· 6888 6871 count = 0; 6889 6872 cntdn = 1000 * timeout; 6890 6873 do { 6891 - doorbell_reg = ioc->base_readl(&ioc->chip->Doorbell); 6874 + doorbell_reg = ioc->base_readl_ext_retry(&ioc->chip->Doorbell); 6892 6875 if (!(doorbell_reg & MPI2_DOORBELL_USED)) { 6893 6876 dhsprintk(ioc, 6894 6877 ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n", ··· 7036 7019 __le32 *mfp; 7037 7020 7038 7021 /* make sure doorbell is not in use */ 7039 - if ((ioc->base_readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) { 7022 + if ((ioc->base_readl_ext_retry(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) { 7040 7023 ioc_err(ioc, "doorbell is in use (line=%d)\n", __LINE__); 7041 7024 return -EFAULT; 7042 7025 } ··· 7085 7068 } 7086 7069 7087 7070 /* read the first two 16-bits, it gives the total length of the reply */ 7088 - reply[0] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell) 7071 + reply[0] = le16_to_cpu(ioc->base_readl_ext_retry(&ioc->chip->Doorbell) 7089 7072 & MPI2_DOORBELL_DATA_MASK); 7090 7073 writel(0, &ioc->chip->HostInterruptStatus); 7091 7074 if ((_base_wait_for_doorbell_int(ioc, 5))) { ··· 7093 7076 __LINE__); 7094 7077 return -EFAULT; 7095 7078 } 7096 - reply[1] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell) 7079 + reply[1] = le16_to_cpu(ioc->base_readl_ext_retry(&ioc->chip->Doorbell) 7097 7080 & MPI2_DOORBELL_DATA_MASK); 7098 7081 writel(0, &ioc->chip->HostInterruptStatus); 7099 7082 ··· 7104 7087 return -EFAULT; 7105 7088 } 7106 7089 if (i >= reply_bytes/2) /* overflow case */ 7107 - ioc->base_readl(&ioc->chip->Doorbell); 7090 + ioc->base_readl_ext_retry(&ioc->chip->Doorbell); 7108 7091 else 7109 7092 reply[i] = le16_to_cpu( 7110 - ioc->base_readl(&ioc->chip->Doorbell) 7093 + ioc->base_readl_ext_retry(&ioc->chip->Doorbell) 7111 7094 & MPI2_DOORBELL_DATA_MASK); 7112 7095 writel(0, &ioc->chip->HostInterruptStatus); 7113 7096 } ··· 7966 7949 goto out; 7967 7950 } 7968 7951 7969 - host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic); 7952 + host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic); 7970 7953 drsprintk(ioc, 7971 7954 ioc_info(ioc, "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n", 7972 7955 count, host_diagnostic)); ··· 7986 7969 for (count = 0; count < (300000000 / 7987 7970 MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) { 7988 7971 7989 - host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic); 7972 + host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic); 7990 7973 7991 7974 if (host_diagnostic == 0xFFFFFFFF) { 7992 7975 ioc_info(ioc, ··· 8376 8359 ioc->rdpq_array_enable_assigned = 0; 8377 8360 ioc->use_32bit_dma = false; 8378 8361 ioc->dma_mask = 64; 8379 - if (ioc->is_aero_ioc) 8362 + if (ioc->is_aero_ioc) { 8380 8363 ioc->base_readl = &_base_readl_aero; 8381 - else 8364 + ioc->base_readl_ext_retry = &_base_readl_ext_retry; 8365 + } else { 8382 8366 ioc->base_readl = &_base_readl; 8367 + ioc->base_readl_ext_retry = &_base_readl; 8368 + } 8383 8369 r = mpt3sas_base_map_resources(ioc); 8384 8370 if (r) 8385 8371 goto out_free_resources;
+2 -1
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 994 994 typedef void (*PUT_SMID_IO_FP_HIP) (struct MPT3SAS_ADAPTER *ioc, u16 smid, 995 995 u16 funcdep); 996 996 typedef void (*PUT_SMID_DEFAULT) (struct MPT3SAS_ADAPTER *ioc, u16 smid); 997 - typedef u32 (*BASE_READ_REG) (const volatile void __iomem *addr); 997 + typedef u32 (*BASE_READ_REG) (const void __iomem *addr); 998 998 /* 999 999 * To get high iops reply queue's msix index when high iops mode is enabled 1000 1000 * else get the msix index of general reply queues. ··· 1618 1618 u8 diag_trigger_active; 1619 1619 u8 atomic_desc_capable; 1620 1620 BASE_READ_REG base_readl; 1621 + BASE_READ_REG base_readl_ext_retry; 1621 1622 struct SL_WH_MASTER_TRIGGER_T diag_trigger_master; 1622 1623 struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event; 1623 1624 struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
+1 -1
drivers/scsi/mvumi.c
··· 1500 1500 1501 1501 sdev = scsi_device_lookup(mhba->shost, 0, id, 0); 1502 1502 if (sdev) { 1503 - scsi_rescan_device(&sdev->sdev_gendev); 1503 + scsi_rescan_device(sdev); 1504 1504 scsi_device_put(sdev); 1505 1505 } 1506 1506 }
-1
drivers/scsi/qedf/qedf.h
··· 548 548 extern void qedf_wq_grcdump(struct work_struct *work); 549 549 void qedf_stag_change_work(struct work_struct *work); 550 550 void qedf_ctx_soft_reset(struct fc_lport *lport); 551 - extern void qedf_board_disable_work(struct work_struct *work); 552 551 extern void qedf_schedule_hw_err_handler(void *dev, 553 552 enum qed_hw_err_type err_type); 554 553
-2
drivers/scsi/qedi/qedi_gbl.h
··· 67 67 int qedi_alloc_id(struct qedi_portid_tbl *id_tbl, u16 id); 68 68 u16 qedi_alloc_new_id(struct qedi_portid_tbl *id_tbl); 69 69 void qedi_free_id(struct qedi_portid_tbl *id_tbl, u16 id); 70 - int qedi_create_sysfs_ctx_attr(struct qedi_ctx *qedi); 71 - void qedi_remove_sysfs_ctx_attr(struct qedi_ctx *qedi); 72 70 void qedi_clearsq(struct qedi_ctx *qedi, 73 71 struct qedi_conn *qedi_conn, 74 72 struct iscsi_task *task);
-2
drivers/scsi/qla2xxx/qla_attr.c
··· 3093 3093 vha->flags.difdix_supported = 1; 3094 3094 ql_dbg(ql_dbg_user, vha, 0x7082, 3095 3095 "Registered for DIF/DIX type 1 and 3 protection.\n"); 3096 - if (ql2xenabledif == 1) 3097 - prot = SHOST_DIX_TYPE0_PROTECTION; 3098 3096 scsi_host_set_prot(vha->host, 3099 3097 prot | SHOST_DIF_TYPE1_PROTECTION 3100 3098 | SHOST_DIF_TYPE2_PROTECTION
+3 -4
drivers/scsi/qla2xxx/qla_dbg.c
··· 12 12 * ---------------------------------------------------------------------- 13 13 * | Module Init and Probe | 0x0199 | | 14 14 * | Mailbox commands | 0x1206 | 0x11a5-0x11ff | 15 - * | Device Discovery | 0x2134 | 0x210e-0x2115 | 16 - * | | | 0x211c-0x2128 | 17 - * | | | 0x212c-0x2134 | 15 + * | Device Discovery | 0x2134 | 0x2112-0x2115 | 16 + * | | | 0x2127-0x2128 | 18 17 * | Queue Command and IO tracing | 0x3074 | 0x300b | 19 18 * | | | 0x3027-0x3028 | 20 19 * | | | 0x303d-0x3041 | 21 - * | | | 0x302d,0x3033 | 20 + * | | | 0x302e,0x3033 | 22 21 * | | | 0x3036,0x3038 | 23 22 * | | | 0x303a | 24 23 * | DPC Thread | 0x4023 | 0x4002,0x4013 |
+1
drivers/scsi/qla2xxx/qla_dbg.h
··· 368 368 #define ql_dbg_tgt_tmr 0x00001000 /* Target mode task management */ 369 369 #define ql_dbg_tgt_dif 0x00000800 /* Target mode dif */ 370 370 #define ql_dbg_edif 0x00000400 /* edif and purex debug */ 371 + #define ql_dbg_unsol 0x00000100 /* Unsolicited path debug */ 371 372 372 373 extern int qla27xx_dump_mpi_ram(struct qla_hw_data *, uint32_t, uint32_t *, 373 374 uint32_t, void **);
+49 -8
drivers/scsi/qla2xxx/qla_def.h
··· 346 346 u8 sent; 347 347 }; 348 348 349 + struct qla_nvme_fc_rjt { 350 + struct fcnvme_ls_rjt *c; 351 + dma_addr_t cdma; 352 + u16 size; 353 + }; 354 + 349 355 struct els_reject { 350 356 struct fc_els_ls_rjt *c; 351 357 dma_addr_t cdma; ··· 509 503 port_id_t id; 510 504 }; 511 505 506 + struct qla_nvme_lsrjt_pt_arg { 507 + struct fc_port *fcport; 508 + u8 opcode; 509 + u8 vp_idx; 510 + u8 reason; 511 + u8 explanation; 512 + __le16 nport_handle; 513 + u16 control_flags; 514 + __le16 ox_id; 515 + __le32 xchg_address; 516 + u32 tx_byte_count, rx_byte_count; 517 + dma_addr_t tx_addr, rx_addr; 518 + }; 519 + 512 520 /* 513 521 * SRB extensions. 514 522 */ ··· 631 611 void *desc; 632 612 633 613 /* These are only used with ls4 requests */ 634 - int cmd_len; 635 - int rsp_len; 614 + __le32 cmd_len; 615 + __le32 rsp_len; 636 616 dma_addr_t cmd_dma; 637 617 dma_addr_t rsp_dma; 638 618 enum nvmefc_fcp_datadir dir; 639 619 uint32_t dl; 640 620 uint32_t timeout_sec; 621 + __le32 exchange_address; 622 + __le16 nport_handle; 623 + __le16 ox_id; 641 624 struct list_head entry; 642 625 } nvme; 643 626 struct { ··· 730 707 struct fc_port *fcport; 731 708 struct scsi_qla_host *vha; 732 709 unsigned int start_timer:1; 710 + unsigned int abort:1; 711 + unsigned int aborted:1; 712 + unsigned int completed:1; 713 + unsigned int unsol_rsp:1; 733 714 734 715 uint32_t handle; 735 716 uint16_t flags; ··· 2569 2542 typedef struct fc_port { 2570 2543 struct list_head list; 2571 2544 struct scsi_qla_host *vha; 2545 + struct list_head unsol_ctx_head; 2572 2546 2573 2547 unsigned int conf_compl_supported:1; 2574 2548 unsigned int deleted:2; ··· 3770 3742 u16 pad; 3771 3743 }; 3772 3744 3745 + struct qla_fw_res { 3746 + u16 iocb_total; 3747 + u16 iocb_limit; 3748 + atomic_t iocb_used; 3749 + 3750 + u16 exch_total; 3751 + u16 exch_limit; 3752 + atomic_t exch_used; 3753 + }; 3754 + 3773 3755 #define QLA_IOCB_PCT_LIMIT 95 3774 3756 3775 3757 struct qla_buf_pool { ··· 3825 3787 3826 3788 uint16_t id; /* qp number used with FW */ 3827 3789 uint16_t vp_idx; /* vport ID */ 3790 + 3791 + uint16_t dsd_inuse; 3792 + uint16_t dsd_avail; 3793 + struct list_head dsd_list; 3794 + #define NUM_DSD_CHAIN 4096 3795 + 3828 3796 mempool_t *srb_mempool; 3829 3797 3830 3798 struct pci_dev *pdev; ··· 4428 4384 uint8_t aen_mbx_count; 4429 4385 atomic_t num_pend_mbx_stage1; 4430 4386 atomic_t num_pend_mbx_stage2; 4431 - atomic_t num_pend_mbx_stage3; 4432 4387 uint16_t frame_payload_size; 4433 4388 4434 4389 uint32_t login_retry_count; ··· 4757 4714 struct fw_blob *hablob; 4758 4715 struct qla82xx_legacy_intr_set nx_legacy_intr; 4759 4716 4760 - uint16_t gbl_dsd_inuse; 4761 - uint16_t gbl_dsd_avail; 4762 - struct list_head gbl_dsd_list; 4763 - #define NUM_DSD_CHAIN 4096 4764 - 4765 4717 uint8_t fw_type; 4766 4718 uint32_t file_prd_off; /* File firmware product offset */ 4767 4719 ··· 4838 4800 struct els_reject elsrej; 4839 4801 u8 edif_post_stop_cnt_down; 4840 4802 struct qla_vp_map *vp_map; 4803 + struct qla_nvme_fc_rjt lsrjt; 4804 + struct qla_fw_res fwres ____cacheline_aligned; 4841 4805 }; 4842 4806 4843 4807 #define RX_ELS_SIZE (roundup(sizeof(struct enode) + ELS_MAX_PAYLOAD, SMP_CACHE_BYTES)) ··· 4872 4832 * is variable) starting at "iocb". 4873 4833 */ 4874 4834 struct purex_item { 4835 + void *purls_context; 4875 4836 struct list_head list; 4876 4837 struct scsi_qla_host *vha; 4877 4838 void (*process_item)(struct scsi_qla_host *vha,
+10
drivers/scsi/qla2xxx/qla_dfs.c
··· 276 276 277 277 seq_printf(s, "estimate exchange used[%d] high water limit [%d] n", 278 278 exch_used, ha->base_qpair->fwres.exch_limit); 279 + 280 + if (ql2xenforce_iocb_limit == 2) { 281 + iocbs_used = atomic_read(&ha->fwres.iocb_used); 282 + exch_used = atomic_read(&ha->fwres.exch_used); 283 + seq_printf(s, " estimate iocb2 used [%d] high water limit [%d]\n", 284 + iocbs_used, ha->fwres.iocb_limit); 285 + 286 + seq_printf(s, " estimate exchange2 used[%d] high water limit [%d] \n", 287 + exch_used, ha->fwres.exch_limit); 288 + } 279 289 } 280 290 281 291 return 0;
+10 -4
drivers/scsi/qla2xxx/qla_gbl.h
··· 603 603 fc_port_t *qla2x00_find_fcport_by_loopid(scsi_qla_host_t *, uint16_t); 604 604 fc_port_t *qla2x00_find_fcport_by_wwpn(scsi_qla_host_t *, u8 *, u8); 605 605 fc_port_t *qla2x00_find_fcport_by_nportid(scsi_qla_host_t *, port_id_t *, u8); 606 - void __qla_consume_iocb(struct scsi_qla_host *vha, void **pkt, struct rsp_que **rsp); 606 + void qla24xx_queue_purex_item(scsi_qla_host_t *, struct purex_item *, 607 + void (*process_item)(struct scsi_qla_host *, 608 + struct purex_item *)); 609 + void __qla_consume_iocb(struct scsi_qla_host *, void **, struct rsp_que **); 610 + void qla2xxx_process_purls_iocb(void **pkt, struct rsp_que **rsp); 607 611 608 612 /* 609 613 * Global Function Prototypes in qla_sup.c source file. ··· 670 666 extern void qla2xxx_flash_npiv_conf(scsi_qla_host_t *); 671 667 extern int qla24xx_read_fcp_prio_cfg(scsi_qla_host_t *); 672 668 extern int qla2x00_mailbox_passthru(struct bsg_job *bsg_job); 673 - int __qla_copy_purex_to_buffer(struct scsi_qla_host *vha, void **pkt, 674 - struct rsp_que **rsp, u8 *buf, u32 buf_len); 675 - 669 + int qla2x00_sys_ld_info(struct bsg_job *bsg_job); 670 + int __qla_copy_purex_to_buffer(struct scsi_qla_host *, void **, 671 + struct rsp_que **, u8 *, u32); 672 + struct purex_item *qla27xx_copy_multiple_pkt(struct scsi_qla_host *vha, 673 + void **pkt, struct rsp_que **rsp, bool is_purls, bool byte_order); 676 674 int qla_mailbox_passthru(scsi_qla_host_t *vha, uint16_t *mbx_in, 677 675 uint16_t *mbx_out); 678 676
+31 -5
drivers/scsi/qla2xxx/qla_init.c
··· 2223 2223 rval = QLA_FUNCTION_FAILED; 2224 2224 } 2225 2225 } 2226 + if (tm_iocb->u.tmf.data) 2227 + rval = tm_iocb->u.tmf.data; 2226 2228 2227 2229 done_free_sp: 2228 2230 /* ref: INIT */ ··· 4205 4203 u8 i; 4206 4204 struct qla_hw_data *ha = vha->hw; 4207 4205 4208 - __qla_adjust_iocb_limit(ha->base_qpair); 4206 + __qla_adjust_iocb_limit(ha->base_qpair); 4209 4207 ha->base_qpair->fwres.iocbs_used = 0; 4210 4208 ha->base_qpair->fwres.exch_used = 0; 4211 4209 ··· 4216 4214 ha->queue_pair_map[i]->fwres.exch_used = 0; 4217 4215 } 4218 4216 } 4217 + 4218 + ha->fwres.iocb_total = ha->orig_fw_iocb_count; 4219 + ha->fwres.iocb_limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100; 4220 + ha->fwres.exch_total = ha->orig_fw_xcb_count; 4221 + ha->fwres.exch_limit = (ha->orig_fw_xcb_count * QLA_IOCB_PCT_LIMIT) / 100; 4222 + 4223 + atomic_set(&ha->fwres.iocb_used, 0); 4224 + atomic_set(&ha->fwres.exch_used, 0); 4219 4225 } 4220 4226 4221 4227 void qla_adjust_iocb_limit(scsi_qla_host_t *vha) ··· 5564 5554 INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); 5565 5555 INIT_LIST_HEAD(&fcport->gnl_entry); 5566 5556 INIT_LIST_HEAD(&fcport->list); 5557 + INIT_LIST_HEAD(&fcport->unsol_ctx_head); 5567 5558 5568 5559 INIT_LIST_HEAD(&fcport->sess_cmd_list); 5569 5560 spin_lock_init(&fcport->sess_cmd_lock); ··· 5607 5596 __be32 *q; 5608 5597 5609 5598 memset(ha->init_cb, 0, ha->init_cb_size); 5610 - sz = min_t(int, sizeof(struct fc_els_csp), ha->init_cb_size); 5599 + sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size); 5611 5600 rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, 5612 5601 ha->init_cb, sz); 5613 5602 if (rval != QLA_SUCCESS) { ··· 7401 7390 } 7402 7391 7403 7392 /* purge MBox commands */ 7404 - if (atomic_read(&ha->num_pend_mbx_stage3)) { 7393 + spin_lock_irqsave(&ha->hardware_lock, flags); 7394 + if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags)) { 7405 7395 clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 7406 7396 complete(&ha->mbx_intr_comp); 7407 7397 } 7398 + spin_unlock_irqrestore(&ha->hardware_lock, flags); 7408 7399 7409 7400 i = 0; 7410 - while (atomic_read(&ha->num_pend_mbx_stage3) || 7411 - atomic_read(&ha->num_pend_mbx_stage2) || 7401 + while (atomic_read(&ha->num_pend_mbx_stage2) || 7412 7402 atomic_read(&ha->num_pend_mbx_stage1)) { 7413 7403 msleep(20); 7414 7404 i++; ··· 9655 9643 qpair->vp_idx = vp_idx; 9656 9644 qpair->fw_started = ha->flags.fw_started; 9657 9645 INIT_LIST_HEAD(&qpair->hints_list); 9646 + INIT_LIST_HEAD(&qpair->dsd_list); 9658 9647 qpair->chip_reset = ha->base_qpair->chip_reset; 9659 9648 qpair->enable_class_2 = ha->base_qpair->enable_class_2; 9660 9649 qpair->enable_explicit_conf = ··· 9783 9770 ret = qla25xx_delete_rsp_que(vha, qpair->rsp); 9784 9771 if (ret != QLA_SUCCESS) 9785 9772 goto fail; 9773 + 9774 + if (!list_empty(&qpair->dsd_list)) { 9775 + struct dsd_dma *dsd_ptr, *tdsd_ptr; 9776 + 9777 + /* clean up allocated prev pool */ 9778 + list_for_each_entry_safe(dsd_ptr, tdsd_ptr, 9779 + &qpair->dsd_list, list) { 9780 + dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr, 9781 + dsd_ptr->dsd_list_dma); 9782 + list_del(&dsd_ptr->list); 9783 + kfree(dsd_ptr); 9784 + } 9785 + } 9786 9786 9787 9787 mutex_lock(&ha->mq_lock); 9788 9788 ha->queue_pair_map[qpair->id] = NULL;
+56 -1
drivers/scsi/qla2xxx/qla_inline.h
··· 386 386 RESOURCE_IOCB = BIT_0, 387 387 RESOURCE_EXCH = BIT_1, /* exchange */ 388 388 RESOURCE_FORCE = BIT_2, 389 + RESOURCE_HA = BIT_3, 389 390 }; 390 391 391 392 static inline int ··· 394 393 { 395 394 u16 iocbs_used, i; 396 395 u16 exch_used; 397 - struct qla_hw_data *ha = qp->vha->hw; 396 + struct qla_hw_data *ha = qp->hw; 398 397 399 398 if (!ql2xenforce_iocb_limit) { 400 399 iores->res_type = RESOURCE_NONE; ··· 429 428 return -ENOSPC; 430 429 } 431 430 } 431 + 432 + if (ql2xenforce_iocb_limit == 2) { 433 + if ((iores->iocb_cnt + atomic_read(&ha->fwres.iocb_used)) >= 434 + ha->fwres.iocb_limit) { 435 + iores->res_type = RESOURCE_NONE; 436 + return -ENOSPC; 437 + } 438 + 439 + if (iores->res_type & RESOURCE_EXCH) { 440 + if ((iores->exch_cnt + atomic_read(&ha->fwres.exch_used)) >= 441 + ha->fwres.exch_limit) { 442 + iores->res_type = RESOURCE_NONE; 443 + return -ENOSPC; 444 + } 445 + } 446 + } 447 + 432 448 force: 433 449 qp->fwres.iocbs_used += iores->iocb_cnt; 434 450 qp->fwres.exch_used += iores->exch_cnt; 451 + if (ql2xenforce_iocb_limit == 2) { 452 + atomic_add(iores->iocb_cnt, &ha->fwres.iocb_used); 453 + atomic_add(iores->exch_cnt, &ha->fwres.exch_used); 454 + iores->res_type |= RESOURCE_HA; 455 + } 435 456 return 0; 457 + } 458 + 459 + /* 460 + * decrement to zero. This routine will not decrement below zero 461 + * @v: pointer of type atomic_t 462 + * @amount: amount to decrement from v 463 + */ 464 + static void qla_atomic_dtz(atomic_t *v, int amount) 465 + { 466 + int c, old, dec; 467 + 468 + c = atomic_read(v); 469 + for (;;) { 470 + dec = c - amount; 471 + if (unlikely(dec < 0)) 472 + dec = 0; 473 + 474 + old = atomic_cmpxchg((v), c, dec); 475 + if (likely(old == c)) 476 + break; 477 + c = old; 478 + } 436 479 } 437 480 438 481 static inline void 439 482 qla_put_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores) 440 483 { 484 + struct qla_hw_data *ha = qp->hw; 485 + 486 + if (iores->res_type & RESOURCE_HA) { 487 + if (iores->res_type & RESOURCE_IOCB) 488 + qla_atomic_dtz(&ha->fwres.iocb_used, iores->iocb_cnt); 489 + 490 + if (iores->res_type & RESOURCE_EXCH) 491 + qla_atomic_dtz(&ha->fwres.exch_used, iores->exch_cnt); 492 + } 493 + 441 494 if (iores->res_type & RESOURCE_IOCB) { 442 495 if (qp->fwres.iocbs_used >= iores->iocb_cnt) { 443 496 qp->fwres.iocbs_used -= iores->iocb_cnt;
+297 -26
drivers/scsi/qla2xxx/qla_iocb.c
··· 11 11 12 12 #include <scsi/scsi_tcq.h> 13 13 14 + static int qla_start_scsi_type6(srb_t *sp); 14 15 /** 15 16 * qla2x00_get_cmd_direction() - Determine control_flag data direction. 16 17 * @sp: SCSI command ··· 591 590 uint16_t tot_dsds) 592 591 { 593 592 struct dsd64 *cur_dsd = NULL, *next_dsd; 594 - scsi_qla_host_t *vha; 595 - struct qla_hw_data *ha; 596 593 struct scsi_cmnd *cmd; 597 594 struct scatterlist *cur_seg; 598 595 uint8_t avail_dsds; ··· 612 613 return 0; 613 614 } 614 615 615 - vha = sp->vha; 616 - ha = vha->hw; 617 - 618 616 /* Set transfer direction */ 619 617 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 620 618 cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA); ··· 632 636 tot_dsds -= avail_dsds; 633 637 dsd_list_len = (avail_dsds + 1) * QLA_DSD_SIZE; 634 638 635 - dsd_ptr = list_first_entry(&ha->gbl_dsd_list, 636 - struct dsd_dma, list); 639 + dsd_ptr = list_first_entry(&qpair->dsd_list, struct dsd_dma, list); 637 640 next_dsd = dsd_ptr->dsd_addr; 638 641 list_del(&dsd_ptr->list); 639 - ha->gbl_dsd_avail--; 642 + qpair->dsd_avail--; 640 643 list_add_tail(&dsd_ptr->list, &ctx->dsd_list); 641 644 ctx->dsd_use_cnt++; 642 - ha->gbl_dsd_inuse++; 645 + qpair->dsd_inuse++; 643 646 644 647 if (first_iocb) { 645 648 first_iocb = 0; ··· 1717 1722 if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { 1718 1723 if (cmd->cmd_len <= 16) 1719 1724 return qla24xx_start_scsi(sp); 1725 + else 1726 + return qla_start_scsi_type6(sp); 1720 1727 } 1721 1728 1722 1729 /* Setup device pointers. */ ··· 2098 2101 if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { 2099 2102 if (cmd->cmd_len <= 16) 2100 2103 return qla2xxx_start_scsi_mq(sp); 2104 + else 2105 + return qla_start_scsi_type6(sp); 2101 2106 } 2102 2107 2103 2108 spin_lock_irqsave(&qpair->qp_lock, flags); ··· 3367 3368 struct qla_hw_data *ha = vha->hw; 3368 3369 struct req_que *req = NULL; 3369 3370 struct rsp_que *rsp = NULL; 3371 + struct qla_qpair *qpair = sp->qpair; 3370 3372 3371 3373 /* Setup device pointers. */ 3372 3374 reg = &ha->iobase->isp82; ··· 3416 3416 uint16_t i; 3417 3417 3418 3418 more_dsd_lists = qla24xx_calc_dsd_lists(tot_dsds); 3419 - if ((more_dsd_lists + ha->gbl_dsd_inuse) >= NUM_DSD_CHAIN) { 3419 + if ((more_dsd_lists + qpair->dsd_inuse) >= NUM_DSD_CHAIN) { 3420 3420 ql_dbg(ql_dbg_io, vha, 0x300d, 3421 3421 "Num of DSD list %d is than %d for cmd=%p.\n", 3422 - more_dsd_lists + ha->gbl_dsd_inuse, NUM_DSD_CHAIN, 3422 + more_dsd_lists + qpair->dsd_inuse, NUM_DSD_CHAIN, 3423 3423 cmd); 3424 3424 goto queuing_error; 3425 3425 } 3426 3426 3427 - if (more_dsd_lists <= ha->gbl_dsd_avail) 3427 + if (more_dsd_lists <= qpair->dsd_avail) 3428 3428 goto sufficient_dsds; 3429 3429 else 3430 - more_dsd_lists -= ha->gbl_dsd_avail; 3430 + more_dsd_lists -= qpair->dsd_avail; 3431 3431 3432 3432 for (i = 0; i < more_dsd_lists; i++) { 3433 3433 dsd_ptr = kzalloc(sizeof(struct dsd_dma), GFP_ATOMIC); ··· 3447 3447 "for cmd=%p.\n", cmd); 3448 3448 goto queuing_error; 3449 3449 } 3450 - list_add_tail(&dsd_ptr->list, &ha->gbl_dsd_list); 3451 - ha->gbl_dsd_avail++; 3450 + list_add_tail(&dsd_ptr->list, &qpair->dsd_list); 3451 + qpair->dsd_avail++; 3452 3452 } 3453 3453 3454 3454 sufficient_dsds: ··· 3767 3767 nvme = &sp->u.iocb_cmd; 3768 3768 cmd_pkt->entry_type = PT_LS4_REQUEST; 3769 3769 cmd_pkt->entry_count = 1; 3770 - cmd_pkt->control_flags = cpu_to_le16(CF_LS4_ORIGINATOR << CF_LS4_SHIFT); 3771 - 3772 3770 cmd_pkt->timeout = cpu_to_le16(nvme->u.nvme.timeout_sec); 3773 - cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); 3774 3771 cmd_pkt->vp_index = sp->fcport->vha->vp_idx; 3775 3772 3776 - cmd_pkt->tx_dseg_count = cpu_to_le16(1); 3777 - cmd_pkt->tx_byte_count = cpu_to_le32(nvme->u.nvme.cmd_len); 3778 - cmd_pkt->dsd[0].length = cpu_to_le32(nvme->u.nvme.cmd_len); 3779 - put_unaligned_le64(nvme->u.nvme.cmd_dma, &cmd_pkt->dsd[0].address); 3773 + if (sp->unsol_rsp) { 3774 + cmd_pkt->control_flags = 3775 + cpu_to_le16(CF_LS4_RESPONDER << CF_LS4_SHIFT); 3776 + cmd_pkt->nport_handle = nvme->u.nvme.nport_handle; 3777 + cmd_pkt->exchange_address = nvme->u.nvme.exchange_address; 3778 + } else { 3779 + cmd_pkt->control_flags = 3780 + cpu_to_le16(CF_LS4_ORIGINATOR << CF_LS4_SHIFT); 3781 + cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); 3782 + cmd_pkt->rx_dseg_count = cpu_to_le16(1); 3783 + cmd_pkt->rx_byte_count = nvme->u.nvme.rsp_len; 3784 + cmd_pkt->dsd[1].length = nvme->u.nvme.rsp_len; 3785 + put_unaligned_le64(nvme->u.nvme.rsp_dma, &cmd_pkt->dsd[1].address); 3786 + } 3780 3787 3781 - cmd_pkt->rx_dseg_count = cpu_to_le16(1); 3782 - cmd_pkt->rx_byte_count = cpu_to_le32(nvme->u.nvme.rsp_len); 3783 - cmd_pkt->dsd[1].length = cpu_to_le32(nvme->u.nvme.rsp_len); 3784 - put_unaligned_le64(nvme->u.nvme.rsp_dma, &cmd_pkt->dsd[1].address); 3788 + cmd_pkt->tx_dseg_count = cpu_to_le16(1); 3789 + cmd_pkt->tx_byte_count = nvme->u.nvme.cmd_len; 3790 + cmd_pkt->dsd[0].length = nvme->u.nvme.cmd_len; 3791 + put_unaligned_le64(nvme->u.nvme.cmd_dma, &cmd_pkt->dsd[0].address); 3785 3792 } 3786 3793 3787 3794 static void ··· 4204 4197 spin_unlock_irqrestore(&ha->hardware_lock, flags); 4205 4198 4206 4199 return rval; 4200 + } 4201 + 4202 + /** 4203 + * qla_start_scsi_type6() - Send a SCSI command to the ISP 4204 + * @sp: command to send to the ISP 4205 + * 4206 + * Returns non-zero if a failure occurred, else zero. 4207 + */ 4208 + static int 4209 + qla_start_scsi_type6(srb_t *sp) 4210 + { 4211 + int nseg; 4212 + unsigned long flags; 4213 + uint32_t *clr_ptr; 4214 + uint32_t handle; 4215 + struct cmd_type_6 *cmd_pkt; 4216 + uint16_t cnt; 4217 + uint16_t req_cnt; 4218 + uint16_t tot_dsds; 4219 + struct req_que *req = NULL; 4220 + struct rsp_que *rsp; 4221 + struct scsi_cmnd *cmd = GET_CMD_SP(sp); 4222 + struct scsi_qla_host *vha = sp->fcport->vha; 4223 + struct qla_hw_data *ha = vha->hw; 4224 + struct qla_qpair *qpair = sp->qpair; 4225 + uint16_t more_dsd_lists = 0; 4226 + struct dsd_dma *dsd_ptr; 4227 + uint16_t i; 4228 + __be32 *fcp_dl; 4229 + uint8_t additional_cdb_len; 4230 + struct ct6_dsd *ctx; 4231 + 4232 + /* Acquire qpair specific lock */ 4233 + spin_lock_irqsave(&qpair->qp_lock, flags); 4234 + 4235 + /* Setup qpair pointers */ 4236 + req = qpair->req; 4237 + rsp = qpair->rsp; 4238 + 4239 + /* So we know we haven't pci_map'ed anything yet */ 4240 + tot_dsds = 0; 4241 + 4242 + /* Send marker if required */ 4243 + if (vha->marker_needed != 0) { 4244 + if (__qla2x00_marker(vha, qpair, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) { 4245 + spin_unlock_irqrestore(&qpair->qp_lock, flags); 4246 + return QLA_FUNCTION_FAILED; 4247 + } 4248 + vha->marker_needed = 0; 4249 + } 4250 + 4251 + handle = qla2xxx_get_next_handle(req); 4252 + if (handle == 0) 4253 + goto queuing_error; 4254 + 4255 + /* Map the sg table so we have an accurate count of sg entries needed */ 4256 + if (scsi_sg_count(cmd)) { 4257 + nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), 4258 + scsi_sg_count(cmd), cmd->sc_data_direction); 4259 + if (unlikely(!nseg)) 4260 + goto queuing_error; 4261 + } else { 4262 + nseg = 0; 4263 + } 4264 + 4265 + tot_dsds = nseg; 4266 + 4267 + /* eventhough driver only need 1 T6 IOCB, FW still convert DSD to Continueation IOCB */ 4268 + req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); 4269 + 4270 + sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; 4271 + sp->iores.exch_cnt = 1; 4272 + sp->iores.iocb_cnt = req_cnt; 4273 + 4274 + if (qla_get_fw_resources(sp->qpair, &sp->iores)) 4275 + goto queuing_error; 4276 + 4277 + more_dsd_lists = qla24xx_calc_dsd_lists(tot_dsds); 4278 + if ((more_dsd_lists + qpair->dsd_inuse) >= NUM_DSD_CHAIN) { 4279 + ql_dbg(ql_dbg_io, vha, 0x3028, 4280 + "Num of DSD list %d is than %d for cmd=%p.\n", 4281 + more_dsd_lists + qpair->dsd_inuse, NUM_DSD_CHAIN, cmd); 4282 + goto queuing_error; 4283 + } 4284 + 4285 + if (more_dsd_lists <= qpair->dsd_avail) 4286 + goto sufficient_dsds; 4287 + else 4288 + more_dsd_lists -= qpair->dsd_avail; 4289 + 4290 + for (i = 0; i < more_dsd_lists; i++) { 4291 + dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC); 4292 + if (!dsd_ptr) { 4293 + ql_log(ql_log_fatal, vha, 0x3029, 4294 + "Failed to allocate memory for dsd_dma for cmd=%p.\n", cmd); 4295 + goto queuing_error; 4296 + } 4297 + INIT_LIST_HEAD(&dsd_ptr->list); 4298 + 4299 + dsd_ptr->dsd_addr = dma_pool_alloc(ha->dl_dma_pool, 4300 + GFP_ATOMIC, &dsd_ptr->dsd_list_dma); 4301 + if (!dsd_ptr->dsd_addr) { 4302 + kfree(dsd_ptr); 4303 + ql_log(ql_log_fatal, vha, 0x302a, 4304 + "Failed to allocate memory for dsd_addr for cmd=%p.\n", cmd); 4305 + goto queuing_error; 4306 + } 4307 + list_add_tail(&dsd_ptr->list, &qpair->dsd_list); 4308 + qpair->dsd_avail++; 4309 + } 4310 + 4311 + sufficient_dsds: 4312 + req_cnt = 1; 4313 + 4314 + if (req->cnt < (req_cnt + 2)) { 4315 + if (IS_SHADOW_REG_CAPABLE(ha)) { 4316 + cnt = *req->out_ptr; 4317 + } else { 4318 + cnt = (uint16_t)rd_reg_dword_relaxed(req->req_q_out); 4319 + if (qla2x00_check_reg16_for_disconnect(vha, cnt)) 4320 + goto queuing_error; 4321 + } 4322 + 4323 + if (req->ring_index < cnt) 4324 + req->cnt = cnt - req->ring_index; 4325 + else 4326 + req->cnt = req->length - (req->ring_index - cnt); 4327 + if (req->cnt < (req_cnt + 2)) 4328 + goto queuing_error; 4329 + } 4330 + 4331 + ctx = &sp->u.scmd.ct6_ctx; 4332 + 4333 + memset(ctx, 0, sizeof(struct ct6_dsd)); 4334 + ctx->fcp_cmnd = dma_pool_zalloc(ha->fcp_cmnd_dma_pool, 4335 + GFP_ATOMIC, &ctx->fcp_cmnd_dma); 4336 + if (!ctx->fcp_cmnd) { 4337 + ql_log(ql_log_fatal, vha, 0x3031, 4338 + "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd); 4339 + goto queuing_error; 4340 + } 4341 + 4342 + /* Initialize the DSD list and dma handle */ 4343 + INIT_LIST_HEAD(&ctx->dsd_list); 4344 + ctx->dsd_use_cnt = 0; 4345 + 4346 + if (cmd->cmd_len > 16) { 4347 + additional_cdb_len = cmd->cmd_len - 16; 4348 + if (cmd->cmd_len % 4 || 4349 + cmd->cmd_len > QLA_CDB_BUF_SIZE) { 4350 + /* 4351 + * SCSI command bigger than 16 bytes must be 4352 + * multiple of 4 or too big. 4353 + */ 4354 + ql_log(ql_log_warn, vha, 0x3033, 4355 + "scsi cmd len %d not multiple of 4 for cmd=%p.\n", 4356 + cmd->cmd_len, cmd); 4357 + goto queuing_error_fcp_cmnd; 4358 + } 4359 + ctx->fcp_cmnd_len = 12 + cmd->cmd_len + 4; 4360 + } else { 4361 + additional_cdb_len = 0; 4362 + ctx->fcp_cmnd_len = 12 + 16 + 4; 4363 + } 4364 + 4365 + /* Build command packet. */ 4366 + req->current_outstanding_cmd = handle; 4367 + req->outstanding_cmds[handle] = sp; 4368 + sp->handle = handle; 4369 + cmd->host_scribble = (unsigned char *)(unsigned long)handle; 4370 + req->cnt -= req_cnt; 4371 + 4372 + cmd_pkt = (struct cmd_type_6 *)req->ring_ptr; 4373 + cmd_pkt->handle = make_handle(req->id, handle); 4374 + 4375 + /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ 4376 + clr_ptr = (uint32_t *)cmd_pkt + 2; 4377 + memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); 4378 + cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); 4379 + 4380 + /* Set NPORT-ID and LUN number */ 4381 + cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); 4382 + cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; 4383 + cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; 4384 + cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; 4385 + cmd_pkt->vp_index = sp->vha->vp_idx; 4386 + 4387 + /* Build IOCB segments */ 4388 + qla24xx_build_scsi_type_6_iocbs(sp, cmd_pkt, tot_dsds); 4389 + 4390 + int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); 4391 + host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); 4392 + 4393 + /* build FCP_CMND IU */ 4394 + int_to_scsilun(cmd->device->lun, &ctx->fcp_cmnd->lun); 4395 + ctx->fcp_cmnd->additional_cdb_len = additional_cdb_len; 4396 + 4397 + if (cmd->sc_data_direction == DMA_TO_DEVICE) 4398 + ctx->fcp_cmnd->additional_cdb_len |= 1; 4399 + else if (cmd->sc_data_direction == DMA_FROM_DEVICE) 4400 + ctx->fcp_cmnd->additional_cdb_len |= 2; 4401 + 4402 + /* Populate the FCP_PRIO. */ 4403 + if (ha->flags.fcp_prio_enabled) 4404 + ctx->fcp_cmnd->task_attribute |= 4405 + sp->fcport->fcp_prio << 3; 4406 + 4407 + memcpy(ctx->fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); 4408 + 4409 + fcp_dl = (__be32 *)(ctx->fcp_cmnd->cdb + 16 + 4410 + additional_cdb_len); 4411 + *fcp_dl = htonl((uint32_t)scsi_bufflen(cmd)); 4412 + 4413 + cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len); 4414 + put_unaligned_le64(ctx->fcp_cmnd_dma, 4415 + &cmd_pkt->fcp_cmnd_dseg_address); 4416 + 4417 + sp->flags |= SRB_FCP_CMND_DMA_VALID; 4418 + cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); 4419 + /* Set total data segment count. */ 4420 + cmd_pkt->entry_count = (uint8_t)req_cnt; 4421 + 4422 + wmb(); 4423 + /* Adjust ring index. */ 4424 + req->ring_index++; 4425 + if (req->ring_index == req->length) { 4426 + req->ring_index = 0; 4427 + req->ring_ptr = req->ring; 4428 + } else { 4429 + req->ring_ptr++; 4430 + } 4431 + 4432 + sp->qpair->cmd_cnt++; 4433 + sp->flags |= SRB_DMA_VALID; 4434 + 4435 + /* Set chip new ring index. */ 4436 + wrt_reg_dword(req->req_q_in, req->ring_index); 4437 + 4438 + /* Manage unprocessed RIO/ZIO commands in response queue. */ 4439 + if (vha->flags.process_response_queue && 4440 + rsp->ring_ptr->signature != RESPONSE_PROCESSED) 4441 + qla24xx_process_response_queue(vha, rsp); 4442 + 4443 + spin_unlock_irqrestore(&qpair->qp_lock, flags); 4444 + 4445 + return QLA_SUCCESS; 4446 + 4447 + queuing_error_fcp_cmnd: 4448 + dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd, ctx->fcp_cmnd_dma); 4449 + 4450 + queuing_error: 4451 + if (tot_dsds) 4452 + scsi_dma_unmap(cmd); 4453 + 4454 + qla_put_fw_resources(sp->qpair, &sp->iores); 4455 + 4456 + if (sp->u.scmd.crc_ctx) { 4457 + mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool); 4458 + sp->u.scmd.crc_ctx = NULL; 4459 + } 4460 + 4461 + spin_unlock_irqrestore(&qpair->qp_lock, flags); 4462 + 4463 + return QLA_FUNCTION_FAILED; 4207 4464 }
+161 -1
drivers/scsi/qla2xxx/qla_isr.c
··· 56 56 [FCS_ONLINE] = "ONLINE" 57 57 }; 58 58 59 + #define SFP_DISABLE_LASER_INITIATED 0x15 /* Sub code of 8070 AEN */ 60 + #define SFP_ENABLE_LASER_INITIATED 0x16 /* Sub code of 8070 AEN */ 61 + 62 + static inline void display_Laser_info(scsi_qla_host_t *vha, 63 + u16 mb1, u16 mb2, u16 mb3) { 64 + 65 + if (mb1 == SFP_DISABLE_LASER_INITIATED) 66 + ql_log(ql_log_warn, vha, 0xf0a2, 67 + "SFP temperature (%d C) reached/exceeded the threshold (%d C). Laser is disabled.\n", 68 + mb3, mb2); 69 + if (mb1 == SFP_ENABLE_LASER_INITIATED) 70 + ql_log(ql_log_warn, vha, 0xf0a3, 71 + "SFP temperature (%d C) reached normal operating level. Laser is enabled.\n", 72 + mb3); 73 + } 74 + 59 75 static void 60 76 qla24xx_process_abts(struct scsi_qla_host *vha, struct purex_item *pkt) 61 77 { ··· 839 823 } 840 824 } 841 825 826 + /** 827 + * qla27xx_copy_multiple_pkt() - Copy over purex/purls packets that can 828 + * span over multiple IOCBs. 829 + * @vha: SCSI driver HA context 830 + * @pkt: ELS packet 831 + * @rsp: Response queue 832 + * @is_purls: True, for Unsolicited Received FC-NVMe LS rsp IOCB 833 + * false, for Unsolicited Received ELS IOCB 834 + * @byte_order: True, to change the byte ordering of iocb payload 835 + */ 836 + struct purex_item * 837 + qla27xx_copy_multiple_pkt(struct scsi_qla_host *vha, void **pkt, 838 + struct rsp_que **rsp, bool is_purls, 839 + bool byte_order) 840 + { 841 + struct purex_entry_24xx *purex = NULL; 842 + struct pt_ls4_rx_unsol *purls = NULL; 843 + struct rsp_que *rsp_q = *rsp; 844 + sts_cont_entry_t *new_pkt; 845 + uint16_t no_bytes = 0, total_bytes = 0, pending_bytes = 0; 846 + uint16_t buffer_copy_offset = 0, payload_size = 0; 847 + uint16_t entry_count, entry_count_remaining; 848 + struct purex_item *item; 849 + void *iocb_pkt = NULL; 850 + 851 + if (is_purls) { 852 + purls = *pkt; 853 + total_bytes = (le16_to_cpu(purls->frame_size) & 0x0FFF) - 854 + PURX_ELS_HEADER_SIZE; 855 + entry_count = entry_count_remaining = purls->entry_count; 856 + payload_size = sizeof(purls->payload); 857 + } else { 858 + purex = *pkt; 859 + total_bytes = (le16_to_cpu(purex->frame_size) & 0x0FFF) - 860 + PURX_ELS_HEADER_SIZE; 861 + entry_count = entry_count_remaining = purex->entry_count; 862 + payload_size = sizeof(purex->els_frame_payload); 863 + } 864 + 865 + pending_bytes = total_bytes; 866 + no_bytes = (pending_bytes > payload_size) ? payload_size : 867 + pending_bytes; 868 + ql_dbg(ql_dbg_async, vha, 0x509a, 869 + "%s LS, frame_size 0x%x, entry count %d\n", 870 + (is_purls ? "PURLS" : "FPIN"), total_bytes, entry_count); 871 + 872 + item = qla24xx_alloc_purex_item(vha, total_bytes); 873 + if (!item) 874 + return item; 875 + 876 + iocb_pkt = &item->iocb; 877 + 878 + if (is_purls) 879 + memcpy(iocb_pkt, &purls->payload[0], no_bytes); 880 + else 881 + memcpy(iocb_pkt, &purex->els_frame_payload[0], no_bytes); 882 + buffer_copy_offset += no_bytes; 883 + pending_bytes -= no_bytes; 884 + --entry_count_remaining; 885 + 886 + if (is_purls) 887 + ((response_t *)purls)->signature = RESPONSE_PROCESSED; 888 + else 889 + ((response_t *)purex)->signature = RESPONSE_PROCESSED; 890 + wmb(); 891 + 892 + do { 893 + while ((total_bytes > 0) && (entry_count_remaining > 0)) { 894 + if (rsp_q->ring_ptr->signature == RESPONSE_PROCESSED) { 895 + ql_dbg(ql_dbg_async, vha, 0x5084, 896 + "Ran out of IOCBs, partial data 0x%x\n", 897 + buffer_copy_offset); 898 + cpu_relax(); 899 + continue; 900 + } 901 + 902 + new_pkt = (sts_cont_entry_t *)rsp_q->ring_ptr; 903 + *pkt = new_pkt; 904 + 905 + if (new_pkt->entry_type != STATUS_CONT_TYPE) { 906 + ql_log(ql_log_warn, vha, 0x507a, 907 + "Unexpected IOCB type, partial data 0x%x\n", 908 + buffer_copy_offset); 909 + break; 910 + } 911 + 912 + rsp_q->ring_index++; 913 + if (rsp_q->ring_index == rsp_q->length) { 914 + rsp_q->ring_index = 0; 915 + rsp_q->ring_ptr = rsp_q->ring; 916 + } else { 917 + rsp_q->ring_ptr++; 918 + } 919 + no_bytes = (pending_bytes > sizeof(new_pkt->data)) ? 920 + sizeof(new_pkt->data) : pending_bytes; 921 + if ((buffer_copy_offset + no_bytes) <= total_bytes) { 922 + memcpy(((uint8_t *)iocb_pkt + buffer_copy_offset), 923 + new_pkt->data, no_bytes); 924 + buffer_copy_offset += no_bytes; 925 + pending_bytes -= no_bytes; 926 + --entry_count_remaining; 927 + } else { 928 + ql_log(ql_log_warn, vha, 0x5044, 929 + "Attempt to copy more that we got, optimizing..%x\n", 930 + buffer_copy_offset); 931 + memcpy(((uint8_t *)iocb_pkt + buffer_copy_offset), 932 + new_pkt->data, 933 + total_bytes - buffer_copy_offset); 934 + } 935 + 936 + ((response_t *)new_pkt)->signature = RESPONSE_PROCESSED; 937 + wmb(); 938 + } 939 + 940 + if (pending_bytes != 0 || entry_count_remaining != 0) { 941 + ql_log(ql_log_fatal, vha, 0x508b, 942 + "Dropping partial FPIN, underrun bytes = 0x%x, entry cnts 0x%x\n", 943 + total_bytes, entry_count_remaining); 944 + qla24xx_free_purex_item(item); 945 + return NULL; 946 + } 947 + } while (entry_count_remaining > 0); 948 + 949 + if (byte_order) 950 + host_to_fcp_swap((uint8_t *)&item->iocb, total_bytes); 951 + 952 + return item; 953 + } 954 + 842 955 int 843 956 qla2x00_is_a_vp_did(scsi_qla_host_t *vha, uint32_t rscn_entry) 844 957 { ··· 1103 958 return item; 1104 959 } 1105 960 1106 - static void 961 + void 1107 962 qla24xx_queue_purex_item(scsi_qla_host_t *vha, struct purex_item *pkt, 1108 963 void (*process_item)(struct scsi_qla_host *vha, 1109 964 struct purex_item *pkt)) ··· 1943 1798 break; 1944 1799 1945 1800 case MBA_TEMPERATURE_ALERT: 1801 + if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) 1802 + display_Laser_info(vha, mb[1], mb[2], mb[3]); 1946 1803 ql_dbg(ql_dbg_async, vha, 0x505e, 1947 1804 "TEMPERATURE ALERT: %04x %04x %04x\n", mb[1], mb[2], mb[3]); 1948 1805 break; ··· 3958 3811 struct qla_hw_data *ha = vha->hw; 3959 3812 struct purex_entry_24xx *purex_entry; 3960 3813 struct purex_item *pure_item; 3814 + struct pt_ls4_rx_unsol *p; 3961 3815 u16 rsp_in = 0, cur_ring_index; 3962 3816 int is_shadow_hba; 3963 3817 ··· 4131 3983 qla28xx_sa_update_iocb_entry(vha, rsp->req, 4132 3984 (struct sa_update_28xx *)pkt); 4133 3985 break; 3986 + case PT_LS4_UNSOL: 3987 + p = (void *)pkt; 3988 + if (qla_chk_cont_iocb_avail(vha, rsp, (response_t *)pkt, rsp_in)) { 3989 + rsp->ring_ptr = (response_t *)pkt; 3990 + rsp->ring_index = cur_ring_index; 4134 3991 3992 + ql_dbg(ql_dbg_init, vha, 0x2124, 3993 + "Defer processing UNSOL LS req opcode %#x...\n", 3994 + p->payload[0]); 3995 + return; 3996 + } 3997 + qla2xxx_process_purls_iocb((void **)&pkt, &rsp); 3998 + break; 4135 3999 default: 4136 4000 /* Type Not Supported. */ 4137 4001 ql_dbg(ql_dbg_async, vha, 0x5042,
-4
drivers/scsi/qla2xxx/qla_mbx.c
··· 273 273 spin_unlock_irqrestore(&ha->hardware_lock, flags); 274 274 275 275 wait_time = jiffies; 276 - atomic_inc(&ha->num_pend_mbx_stage3); 277 276 if (!wait_for_completion_timeout(&ha->mbx_intr_comp, 278 277 mcp->tov * HZ)) { 279 278 ql_dbg(ql_dbg_mbx, vha, 0x117a, ··· 289 290 spin_unlock_irqrestore(&ha->hardware_lock, 290 291 flags); 291 292 atomic_dec(&ha->num_pend_mbx_stage2); 292 - atomic_dec(&ha->num_pend_mbx_stage3); 293 293 rval = QLA_ABORTED; 294 294 goto premature_exit; 295 295 } ··· 300 302 ha->flags.mbox_busy = 0; 301 303 spin_unlock_irqrestore(&ha->hardware_lock, flags); 302 304 atomic_dec(&ha->num_pend_mbx_stage2); 303 - atomic_dec(&ha->num_pend_mbx_stage3); 304 305 rval = QLA_ABORTED; 305 306 goto premature_exit; 306 307 } 307 - atomic_dec(&ha->num_pend_mbx_stage3); 308 308 309 309 if (time_after(jiffies, wait_time + 5 * HZ)) 310 310 ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n",
+401 -1
drivers/scsi/qla2xxx/qla_nvme.c
··· 12 12 #include <linux/blk-mq.h> 13 13 14 14 static struct nvme_fc_port_template qla_nvme_fc_transport; 15 + static int qla_nvme_ls_reject_iocb(struct scsi_qla_host *vha, 16 + struct qla_qpair *qp, 17 + struct qla_nvme_lsrjt_pt_arg *a, 18 + bool is_xchg_terminate); 19 + 20 + struct qla_nvme_unsol_ctx { 21 + struct list_head elem; 22 + struct scsi_qla_host *vha; 23 + struct fc_port *fcport; 24 + struct srb *sp; 25 + struct nvmefc_ls_rsp lsrsp; 26 + struct nvmefc_ls_rsp *fd_rsp; 27 + struct work_struct lsrsp_work; 28 + struct work_struct abort_work; 29 + __le32 exchange_address; 30 + __le16 nport_handle; 31 + __le16 ox_id; 32 + int comp_status; 33 + spinlock_t cmd_lock; 34 + }; 15 35 16 36 int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) 17 37 { ··· 236 216 schedule_work(&priv->ls_work); 237 217 } 238 218 219 + static void qla_nvme_release_lsrsp_cmd_kref(struct kref *kref) 220 + { 221 + struct srb *sp = container_of(kref, struct srb, cmd_kref); 222 + struct qla_nvme_unsol_ctx *uctx = sp->priv; 223 + struct nvmefc_ls_rsp *fd_rsp; 224 + unsigned long flags; 225 + 226 + if (!uctx) { 227 + qla2x00_rel_sp(sp); 228 + return; 229 + } 230 + 231 + spin_lock_irqsave(&uctx->cmd_lock, flags); 232 + uctx->sp = NULL; 233 + sp->priv = NULL; 234 + spin_unlock_irqrestore(&uctx->cmd_lock, flags); 235 + 236 + fd_rsp = uctx->fd_rsp; 237 + 238 + list_del(&uctx->elem); 239 + 240 + fd_rsp->done(fd_rsp); 241 + kfree(uctx); 242 + qla2x00_rel_sp(sp); 243 + } 244 + 245 + static void qla_nvme_lsrsp_complete(struct work_struct *work) 246 + { 247 + struct qla_nvme_unsol_ctx *uctx = 248 + container_of(work, struct qla_nvme_unsol_ctx, lsrsp_work); 249 + 250 + kref_put(&uctx->sp->cmd_kref, qla_nvme_release_lsrsp_cmd_kref); 251 + } 252 + 253 + static void qla_nvme_sp_lsrsp_done(srb_t *sp, int res) 254 + { 255 + struct qla_nvme_unsol_ctx *uctx = sp->priv; 256 + 257 + if (WARN_ON_ONCE(kref_read(&sp->cmd_kref) == 0)) 258 + return; 259 + 260 + if (res) 261 + res = -EINVAL; 262 + 263 + uctx->comp_status = res; 264 + INIT_WORK(&uctx->lsrsp_work, qla_nvme_lsrsp_complete); 265 + schedule_work(&uctx->lsrsp_work); 266 + } 267 + 239 268 /* it assumed that QPair lock is held. */ 240 269 static void qla_nvme_sp_done(srb_t *sp, int res) 241 270 { ··· 357 288 kref_put(&sp->cmd_kref, sp->put_fn); 358 289 } 359 290 291 + static int qla_nvme_xmt_ls_rsp(struct nvme_fc_local_port *lport, 292 + struct nvme_fc_remote_port *rport, 293 + struct nvmefc_ls_rsp *fd_resp) 294 + { 295 + struct qla_nvme_unsol_ctx *uctx = container_of(fd_resp, 296 + struct qla_nvme_unsol_ctx, lsrsp); 297 + struct qla_nvme_rport *qla_rport = rport->private; 298 + fc_port_t *fcport = qla_rport->fcport; 299 + struct scsi_qla_host *vha = uctx->vha; 300 + struct qla_hw_data *ha = vha->hw; 301 + struct qla_nvme_lsrjt_pt_arg a; 302 + struct srb_iocb *nvme; 303 + srb_t *sp; 304 + int rval = QLA_FUNCTION_FAILED; 305 + uint8_t cnt = 0; 306 + 307 + if (!fcport || fcport->deleted) 308 + goto out; 309 + 310 + if (!ha->flags.fw_started) 311 + goto out; 312 + 313 + /* Alloc SRB structure */ 314 + sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); 315 + if (!sp) 316 + goto out; 317 + 318 + sp->type = SRB_NVME_LS; 319 + sp->name = "nvme_ls"; 320 + sp->done = qla_nvme_sp_lsrsp_done; 321 + sp->put_fn = qla_nvme_release_lsrsp_cmd_kref; 322 + sp->priv = (void *)uctx; 323 + sp->unsol_rsp = 1; 324 + uctx->sp = sp; 325 + spin_lock_init(&uctx->cmd_lock); 326 + nvme = &sp->u.iocb_cmd; 327 + uctx->fd_rsp = fd_resp; 328 + nvme->u.nvme.desc = fd_resp; 329 + nvme->u.nvme.dir = 0; 330 + nvme->u.nvme.dl = 0; 331 + nvme->u.nvme.timeout_sec = 0; 332 + nvme->u.nvme.cmd_dma = fd_resp->rspdma; 333 + nvme->u.nvme.cmd_len = fd_resp->rsplen; 334 + nvme->u.nvme.rsp_len = 0; 335 + nvme->u.nvme.rsp_dma = 0; 336 + nvme->u.nvme.exchange_address = uctx->exchange_address; 337 + nvme->u.nvme.nport_handle = uctx->nport_handle; 338 + nvme->u.nvme.ox_id = uctx->ox_id; 339 + dma_sync_single_for_device(&ha->pdev->dev, nvme->u.nvme.cmd_dma, 340 + le32_to_cpu(fd_resp->rsplen), DMA_TO_DEVICE); 341 + 342 + ql_dbg(ql_dbg_unsol, vha, 0x2122, 343 + "Unsol lsreq portid=%06x %8phC exchange_address 0x%x ox_id 0x%x hdl 0x%x\n", 344 + fcport->d_id.b24, fcport->port_name, uctx->exchange_address, 345 + uctx->ox_id, uctx->nport_handle); 346 + retry: 347 + rval = qla2x00_start_sp(sp); 348 + switch (rval) { 349 + case QLA_SUCCESS: 350 + break; 351 + case EAGAIN: 352 + msleep(PURLS_MSLEEP_INTERVAL); 353 + cnt++; 354 + if (cnt < PURLS_RETRY_COUNT) 355 + goto retry; 356 + 357 + fallthrough; 358 + default: 359 + ql_dbg(ql_log_warn, vha, 0x2123, 360 + "Failed to xmit Unsol ls response = %d\n", rval); 361 + rval = -EIO; 362 + qla2x00_rel_sp(sp); 363 + goto out; 364 + } 365 + 366 + return 0; 367 + out: 368 + memset((void *)&a, 0, sizeof(a)); 369 + a.vp_idx = vha->vp_idx; 370 + a.nport_handle = uctx->nport_handle; 371 + a.xchg_address = uctx->exchange_address; 372 + qla_nvme_ls_reject_iocb(vha, ha->base_qpair, &a, true); 373 + kfree(uctx); 374 + return rval; 375 + } 376 + 360 377 static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, 361 378 struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) 362 379 { ··· 510 355 nvme->u.nvme.timeout_sec = fd->timeout; 511 356 nvme->u.nvme.cmd_dma = fd->rqstdma; 512 357 dma_sync_single_for_device(&ha->pdev->dev, nvme->u.nvme.cmd_dma, 513 - fd->rqstlen, DMA_TO_DEVICE); 358 + le32_to_cpu(fd->rqstlen), DMA_TO_DEVICE); 514 359 515 360 rval = qla2x00_start_sp(sp); 516 361 if (rval != QLA_SUCCESS) { ··· 875 720 .ls_abort = qla_nvme_ls_abort, 876 721 .fcp_io = qla_nvme_post_cmd, 877 722 .fcp_abort = qla_nvme_fcp_abort, 723 + .xmt_ls_rsp = qla_nvme_xmt_ls_rsp, 878 724 .map_queues = qla_nvme_map_queues, 879 725 .max_hw_queues = DEF_NVME_HW_QUEUES, 880 726 .max_sgl_segments = 1024, ··· 1079 923 if (!(ql2xabts_wait_nvme && QLA_ABTS_WAIT_ENABLED(orig_sp))) 1080 924 return; 1081 925 kref_put(&orig_sp->cmd_kref, orig_sp->put_fn); 926 + } 927 + 928 + static void qla_nvme_fc_format_rjt(void *buf, u8 ls_cmd, u8 reason, 929 + u8 explanation, u8 vendor) 930 + { 931 + struct fcnvme_ls_rjt *rjt = buf; 932 + 933 + rjt->w0.ls_cmd = FCNVME_LSDESC_RQST; 934 + rjt->desc_list_len = fcnvme_lsdesc_len(sizeof(struct fcnvme_ls_rjt)); 935 + rjt->rqst.desc_tag = cpu_to_be32(FCNVME_LSDESC_RQST); 936 + rjt->rqst.desc_len = 937 + fcnvme_lsdesc_len(sizeof(struct fcnvme_lsdesc_rqst)); 938 + rjt->rqst.w0.ls_cmd = ls_cmd; 939 + rjt->rjt.desc_tag = cpu_to_be32(FCNVME_LSDESC_RJT); 940 + rjt->rjt.desc_len = fcnvme_lsdesc_len(sizeof(struct fcnvme_lsdesc_rjt)); 941 + rjt->rjt.reason_code = reason; 942 + rjt->rjt.reason_explanation = explanation; 943 + rjt->rjt.vendor = vendor; 944 + } 945 + 946 + static void qla_nvme_lsrjt_pt_iocb(struct scsi_qla_host *vha, 947 + struct pt_ls4_request *lsrjt_iocb, 948 + struct qla_nvme_lsrjt_pt_arg *a) 949 + { 950 + lsrjt_iocb->entry_type = PT_LS4_REQUEST; 951 + lsrjt_iocb->entry_count = 1; 952 + lsrjt_iocb->sys_define = 0; 953 + lsrjt_iocb->entry_status = 0; 954 + lsrjt_iocb->handle = QLA_SKIP_HANDLE; 955 + lsrjt_iocb->nport_handle = a->nport_handle; 956 + lsrjt_iocb->exchange_address = a->xchg_address; 957 + lsrjt_iocb->vp_index = a->vp_idx; 958 + 959 + lsrjt_iocb->control_flags = cpu_to_le16(a->control_flags); 960 + 961 + put_unaligned_le64(a->tx_addr, &lsrjt_iocb->dsd[0].address); 962 + lsrjt_iocb->dsd[0].length = cpu_to_le32(a->tx_byte_count); 963 + lsrjt_iocb->tx_dseg_count = cpu_to_le16(1); 964 + lsrjt_iocb->tx_byte_count = cpu_to_le32(a->tx_byte_count); 965 + 966 + put_unaligned_le64(a->rx_addr, &lsrjt_iocb->dsd[1].address); 967 + lsrjt_iocb->dsd[1].length = 0; 968 + lsrjt_iocb->rx_dseg_count = 0; 969 + lsrjt_iocb->rx_byte_count = 0; 970 + } 971 + 972 + static int 973 + qla_nvme_ls_reject_iocb(struct scsi_qla_host *vha, struct qla_qpair *qp, 974 + struct qla_nvme_lsrjt_pt_arg *a, bool is_xchg_terminate) 975 + { 976 + struct pt_ls4_request *lsrjt_iocb; 977 + 978 + lsrjt_iocb = __qla2x00_alloc_iocbs(qp, NULL); 979 + if (!lsrjt_iocb) { 980 + ql_log(ql_log_warn, vha, 0x210e, 981 + "qla2x00_alloc_iocbs failed.\n"); 982 + return QLA_FUNCTION_FAILED; 983 + } 984 + 985 + if (!is_xchg_terminate) { 986 + qla_nvme_fc_format_rjt((void *)vha->hw->lsrjt.c, a->opcode, 987 + a->reason, a->explanation, 0); 988 + 989 + a->tx_byte_count = sizeof(struct fcnvme_ls_rjt); 990 + a->tx_addr = vha->hw->lsrjt.cdma; 991 + a->control_flags = CF_LS4_RESPONDER << CF_LS4_SHIFT; 992 + 993 + ql_dbg(ql_dbg_unsol, vha, 0x211f, 994 + "Sending nvme fc ls reject ox_id %04x op %04x\n", 995 + a->ox_id, a->opcode); 996 + ql_dump_buffer(ql_dbg_unsol + ql_dbg_verbose, vha, 0x210f, 997 + vha->hw->lsrjt.c, sizeof(*vha->hw->lsrjt.c)); 998 + } else { 999 + a->tx_byte_count = 0; 1000 + a->control_flags = CF_LS4_RESPONDER_TERM << CF_LS4_SHIFT; 1001 + ql_dbg(ql_dbg_unsol, vha, 0x2110, 1002 + "Terminate nvme ls xchg 0x%x\n", a->xchg_address); 1003 + } 1004 + 1005 + qla_nvme_lsrjt_pt_iocb(vha, lsrjt_iocb, a); 1006 + /* flush iocb to mem before notifying hw doorbell */ 1007 + wmb(); 1008 + qla2x00_start_iocbs(vha, qp->req); 1009 + return 0; 1010 + } 1011 + 1012 + /* 1013 + * qla2xxx_process_purls_pkt() - Pass-up Unsolicited 1014 + * Received FC-NVMe Link Service pkt to nvme_fc_rcv_ls_req(). 1015 + * LLDD need to provide memory for response buffer, which 1016 + * will be used to reference the exchange corresponding 1017 + * to the LS when issuing an ls response. LLDD will have to free 1018 + * response buffer in lport->ops->xmt_ls_rsp(). 1019 + * 1020 + * @vha: SCSI qla host 1021 + * @item: ptr to purex_item 1022 + */ 1023 + static void 1024 + qla2xxx_process_purls_pkt(struct scsi_qla_host *vha, struct purex_item *item) 1025 + { 1026 + struct qla_nvme_unsol_ctx *uctx = item->purls_context; 1027 + struct qla_nvme_lsrjt_pt_arg a; 1028 + int ret = 1; 1029 + 1030 + #if (IS_ENABLED(CONFIG_NVME_FC)) 1031 + ret = nvme_fc_rcv_ls_req(uctx->fcport->nvme_remote_port, &uctx->lsrsp, 1032 + &item->iocb, item->size); 1033 + #endif 1034 + if (ret) { 1035 + ql_dbg(ql_dbg_unsol, vha, 0x2125, "NVMe transport ls_req failed\n"); 1036 + memset((void *)&a, 0, sizeof(a)); 1037 + a.vp_idx = vha->vp_idx; 1038 + a.nport_handle = uctx->nport_handle; 1039 + a.xchg_address = uctx->exchange_address; 1040 + qla_nvme_ls_reject_iocb(vha, vha->hw->base_qpair, &a, true); 1041 + list_del(&uctx->elem); 1042 + kfree(uctx); 1043 + } 1044 + } 1045 + 1046 + static scsi_qla_host_t * 1047 + qla2xxx_get_vha_from_vp_idx(struct qla_hw_data *ha, uint16_t vp_index) 1048 + { 1049 + scsi_qla_host_t *base_vha, *vha, *tvp; 1050 + unsigned long flags; 1051 + 1052 + base_vha = pci_get_drvdata(ha->pdev); 1053 + 1054 + if (!vp_index && !ha->num_vhosts) 1055 + return base_vha; 1056 + 1057 + spin_lock_irqsave(&ha->vport_slock, flags); 1058 + list_for_each_entry_safe(vha, tvp, &ha->vp_list, list) { 1059 + if (vha->vp_idx == vp_index) { 1060 + spin_unlock_irqrestore(&ha->vport_slock, flags); 1061 + return vha; 1062 + } 1063 + } 1064 + spin_unlock_irqrestore(&ha->vport_slock, flags); 1065 + 1066 + return NULL; 1067 + } 1068 + 1069 + void qla2xxx_process_purls_iocb(void **pkt, struct rsp_que **rsp) 1070 + { 1071 + struct nvme_fc_remote_port *rport; 1072 + struct qla_nvme_rport *qla_rport; 1073 + struct qla_nvme_lsrjt_pt_arg a; 1074 + struct pt_ls4_rx_unsol *p = *pkt; 1075 + struct qla_nvme_unsol_ctx *uctx; 1076 + struct rsp_que *rsp_q = *rsp; 1077 + struct qla_hw_data *ha; 1078 + scsi_qla_host_t *vha; 1079 + fc_port_t *fcport = NULL; 1080 + struct purex_item *item; 1081 + port_id_t d_id = {0}; 1082 + port_id_t id = {0}; 1083 + u8 *opcode; 1084 + bool xmt_reject = false; 1085 + 1086 + ha = rsp_q->hw; 1087 + 1088 + vha = qla2xxx_get_vha_from_vp_idx(ha, p->vp_index); 1089 + if (!vha) { 1090 + ql_log(ql_log_warn, NULL, 0x2110, "Invalid vp index %d\n", p->vp_index); 1091 + WARN_ON_ONCE(1); 1092 + return; 1093 + } 1094 + 1095 + memset((void *)&a, 0, sizeof(a)); 1096 + opcode = (u8 *)&p->payload[0]; 1097 + a.opcode = opcode[3]; 1098 + a.vp_idx = p->vp_index; 1099 + a.nport_handle = p->nport_handle; 1100 + a.ox_id = p->ox_id; 1101 + a.xchg_address = p->exchange_address; 1102 + 1103 + id.b.domain = p->s_id.domain; 1104 + id.b.area = p->s_id.area; 1105 + id.b.al_pa = p->s_id.al_pa; 1106 + d_id.b.domain = p->d_id[2]; 1107 + d_id.b.area = p->d_id[1]; 1108 + d_id.b.al_pa = p->d_id[0]; 1109 + 1110 + fcport = qla2x00_find_fcport_by_nportid(vha, &id, 0); 1111 + if (!fcport) { 1112 + ql_dbg(ql_dbg_unsol, vha, 0x211e, 1113 + "Failed to find sid=%06x did=%06x\n", 1114 + id.b24, d_id.b24); 1115 + a.reason = FCNVME_RJT_RC_INV_ASSOC; 1116 + a.explanation = FCNVME_RJT_EXP_NONE; 1117 + xmt_reject = true; 1118 + goto out; 1119 + } 1120 + rport = fcport->nvme_remote_port; 1121 + qla_rport = rport->private; 1122 + 1123 + item = qla27xx_copy_multiple_pkt(vha, pkt, rsp, true, false); 1124 + if (!item) { 1125 + a.reason = FCNVME_RJT_RC_LOGIC; 1126 + a.explanation = FCNVME_RJT_EXP_NONE; 1127 + xmt_reject = true; 1128 + goto out; 1129 + } 1130 + 1131 + uctx = kzalloc(sizeof(*uctx), GFP_ATOMIC); 1132 + if (!uctx) { 1133 + ql_log(ql_log_info, vha, 0x2126, "Failed allocate memory\n"); 1134 + a.reason = FCNVME_RJT_RC_LOGIC; 1135 + a.explanation = FCNVME_RJT_EXP_NONE; 1136 + xmt_reject = true; 1137 + kfree(item); 1138 + goto out; 1139 + } 1140 + 1141 + uctx->vha = vha; 1142 + uctx->fcport = fcport; 1143 + uctx->exchange_address = p->exchange_address; 1144 + uctx->nport_handle = p->nport_handle; 1145 + uctx->ox_id = p->ox_id; 1146 + qla_rport->uctx = uctx; 1147 + INIT_LIST_HEAD(&uctx->elem); 1148 + list_add_tail(&uctx->elem, &fcport->unsol_ctx_head); 1149 + item->purls_context = (void *)uctx; 1150 + 1151 + ql_dbg(ql_dbg_unsol, vha, 0x2121, 1152 + "PURLS OP[%01x] size %d xchg addr 0x%x portid %06x\n", 1153 + item->iocb.iocb[3], item->size, uctx->exchange_address, 1154 + fcport->d_id.b24); 1155 + /* +48 0 1 2 3 4 5 6 7 8 9 A B C D E F 1156 + * ----- ----------------------------------------------- 1157 + * 0000: 00 00 00 05 28 00 00 00 07 00 00 00 08 00 00 00 1158 + * 0010: ab ec 0f cc 00 00 8d 7d 05 00 00 00 10 00 00 00 1159 + * 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1160 + */ 1161 + ql_dump_buffer(ql_dbg_unsol + ql_dbg_verbose, vha, 0x2120, 1162 + &item->iocb, item->size); 1163 + 1164 + qla24xx_queue_purex_item(vha, item, qla2xxx_process_purls_pkt); 1165 + out: 1166 + if (xmt_reject) { 1167 + qla_nvme_ls_reject_iocb(vha, (*rsp)->qpair, &a, false); 1168 + __qla_consume_iocb(vha, pkt, rsp); 1169 + } 1082 1170 }
+10 -7
drivers/scsi/qla2xxx/qla_nvme.h
··· 21 21 #define Q2T_NVME_NUM_TAGS 2048 22 22 #define QLA_MAX_FC_SEGMENTS 64 23 23 24 + struct qla_nvme_unsol_ctx; 24 25 struct scsi_qla_host; 25 26 struct qla_hw_data; 26 27 struct req_que; ··· 38 37 39 38 struct qla_nvme_rport { 40 39 struct fc_port *fcport; 40 + struct qla_nvme_unsol_ctx *uctx; 41 41 }; 42 42 43 43 #define COMMAND_NVME 0x88 /* Command Type FC-NVMe IOCB */ ··· 76 74 77 75 struct dsd64 nvme_dsd; 78 76 }; 77 + 78 + #define PURLS_MSLEEP_INTERVAL 1 79 + #define PURLS_RETRY_COUNT 5 79 80 80 81 #define PT_LS4_REQUEST 0x89 /* Link Service pass-through IOCB (request) */ 81 82 struct pt_ls4_request { ··· 123 118 __le32 exchange_address; 124 119 uint8_t d_id[3]; 125 120 uint8_t r_ctl; 126 - be_id_t s_id; 121 + le_id_t s_id; 127 122 uint8_t cs_ctl; 128 123 uint8_t f_ctl[3]; 129 124 uint8_t type; 130 125 __le16 seq_cnt; 131 126 uint8_t df_ctl; 132 127 uint8_t seq_id; 133 - __le16 rx_id; 134 - __le16 ox_id; 135 - __le32 param; 136 - __le32 desc0; 128 + __le16 rx_id; 129 + __le16 ox_id; 130 + __le32 desc0; 137 131 #define PT_LS4_PAYLOAD_OFFSET 0x2c 138 132 #define PT_LS4_FIRST_PACKET_LEN 20 139 - __le32 desc_len; 140 - __le32 payload[3]; 133 + __le32 payload[5]; 141 134 }; 142 135 143 136 /*
+3 -1
drivers/scsi/qla2xxx/qla_nx.h
··· 857 857 uint8_t task_attribute; 858 858 uint8_t task_management; 859 859 uint8_t additional_cdb_len; 860 - uint8_t cdb[260]; /* 256 for CDB len and 4 for FCP_DL */ 860 + #define QLA_CDB_BUF_SIZE 256 861 + #define QLA_FCP_DL_SIZE 4 862 + uint8_t cdb[QLA_CDB_BUF_SIZE + QLA_FCP_DL_SIZE]; /* 256 for CDB len and 4 for FCP_DL */ 861 863 }; 862 864 863 865 struct dsd_dma {
+48 -25
drivers/scsi/qla2xxx/qla_os.c
··· 44 44 MODULE_PARM_DESC(ql2xfulldump_on_mpifail, 45 45 "Set this to take full dump on MPI hang."); 46 46 47 - int ql2xenforce_iocb_limit = 1; 47 + int ql2xenforce_iocb_limit = 2; 48 48 module_param(ql2xenforce_iocb_limit, int, S_IRUGO | S_IWUSR); 49 49 MODULE_PARM_DESC(ql2xenforce_iocb_limit, 50 - "Enforce IOCB throttling, to avoid FW congestion. (default: 1)"); 50 + "Enforce IOCB throttling, to avoid FW congestion. (default: 2) " 51 + "1: track usage per queue, 2: track usage per adapter"); 51 52 52 53 /* 53 54 * CT6 CTX allocation cache ··· 433 432 ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q]; 434 433 ha->base_qpair->srb_mempool = ha->srb_mempool; 435 434 INIT_LIST_HEAD(&ha->base_qpair->hints_list); 435 + INIT_LIST_HEAD(&ha->base_qpair->dsd_list); 436 436 ha->base_qpair->enable_class_2 = ql2xenableclass2; 437 437 /* init qpair to this cpu. Will adjust at run time. */ 438 438 qla_cpu_update(rsp->qpair, raw_smp_processor_id()); ··· 752 750 753 751 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, 754 752 ctx1->fcp_cmnd_dma); 755 - list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); 756 - ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; 757 - ha->gbl_dsd_avail += ctx1->dsd_use_cnt; 753 + list_splice(&ctx1->dsd_list, &sp->qpair->dsd_list); 754 + sp->qpair->dsd_inuse -= ctx1->dsd_use_cnt; 755 + sp->qpair->dsd_avail += ctx1->dsd_use_cnt; 758 756 } 759 757 760 758 if (sp->flags & SRB_GOT_BUF) ··· 838 836 839 837 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, 840 838 ctx1->fcp_cmnd_dma); 841 - list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); 842 - ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; 843 - ha->gbl_dsd_avail += ctx1->dsd_use_cnt; 839 + list_splice(&ctx1->dsd_list, &sp->qpair->dsd_list); 840 + sp->qpair->dsd_inuse -= ctx1->dsd_use_cnt; 841 + sp->qpair->dsd_avail += ctx1->dsd_use_cnt; 844 842 sp->flags &= ~SRB_FCP_CMND_DMA_VALID; 845 843 } 846 844 ··· 3009 3007 ha->max_exchg = FW_MAX_EXCHANGES_CNT; 3010 3008 atomic_set(&ha->num_pend_mbx_stage1, 0); 3011 3009 atomic_set(&ha->num_pend_mbx_stage2, 0); 3012 - atomic_set(&ha->num_pend_mbx_stage3, 0); 3013 3010 atomic_set(&ha->zio_threshold, DEFAULT_ZIO_THRESHOLD); 3014 3011 ha->last_zio_threshold = DEFAULT_ZIO_THRESHOLD; 3015 3012 INIT_LIST_HEAD(&ha->tmf_pending); ··· 3289 3288 host->max_id = ha->max_fibre_devices; 3290 3289 host->cmd_per_lun = 3; 3291 3290 host->unique_id = host->host_no; 3291 + 3292 + if (ql2xenabledif && ql2xenabledif != 2) { 3293 + ql_log(ql_log_warn, base_vha, 0x302d, 3294 + "Invalid value for ql2xenabledif, resetting it to default (2)\n"); 3295 + ql2xenabledif = 2; 3296 + } 3297 + 3292 3298 if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) 3293 3299 host->max_cmd_len = 32; 3294 3300 else ··· 3532 3524 base_vha->flags.difdix_supported = 1; 3533 3525 ql_dbg(ql_dbg_init, base_vha, 0x00f1, 3534 3526 "Registering for DIF/DIX type 1 and 3 protection.\n"); 3535 - if (ql2xenabledif == 1) 3536 - prot = SHOST_DIX_TYPE0_PROTECTION; 3537 3527 if (ql2xprotmask) 3538 3528 scsi_host_set_prot(host, ql2xprotmask); 3539 3529 else ··· 4408 4402 "sf_init_cb=%p.\n", ha->sf_init_cb); 4409 4403 } 4410 4404 4411 - INIT_LIST_HEAD(&ha->gbl_dsd_list); 4412 4405 4413 4406 /* Get consistent memory allocated for Async Port-Database. */ 4414 4407 if (!IS_FWI2_CAPABLE(ha)) { ··· 4462 4457 4463 4458 ha->elsrej.size = sizeof(struct fc_els_ls_rjt) + 16; 4464 4459 ha->elsrej.c = dma_alloc_coherent(&ha->pdev->dev, 4465 - ha->elsrej.size, &ha->elsrej.cdma, GFP_KERNEL); 4466 - 4460 + ha->elsrej.size, 4461 + &ha->elsrej.cdma, 4462 + GFP_KERNEL); 4467 4463 if (!ha->elsrej.c) { 4468 4464 ql_dbg_pci(ql_dbg_init, ha->pdev, 0xffff, 4469 4465 "Alloc failed for els reject cmd.\n"); ··· 4473 4467 ha->elsrej.c->er_cmd = ELS_LS_RJT; 4474 4468 ha->elsrej.c->er_reason = ELS_RJT_LOGIC; 4475 4469 ha->elsrej.c->er_explan = ELS_EXPL_UNAB_DATA; 4470 + 4471 + ha->lsrjt.size = sizeof(struct fcnvme_ls_rjt); 4472 + ha->lsrjt.c = dma_alloc_coherent(&ha->pdev->dev, ha->lsrjt.size, 4473 + &ha->lsrjt.cdma, GFP_KERNEL); 4474 + if (!ha->lsrjt.c) { 4475 + ql_dbg_pci(ql_dbg_init, ha->pdev, 0xffff, 4476 + "Alloc failed for nvme fc reject cmd.\n"); 4477 + goto fail_lsrjt; 4478 + } 4479 + 4476 4480 return 0; 4477 4481 4482 + fail_lsrjt: 4483 + dma_free_coherent(&ha->pdev->dev, ha->elsrej.size, 4484 + ha->elsrej.c, ha->elsrej.cdma); 4478 4485 fail_elsrej: 4479 4486 dma_pool_destroy(ha->purex_dma_pool); 4480 4487 fail_flt: ··· 4953 4934 ha->gid_list = NULL; 4954 4935 ha->gid_list_dma = 0; 4955 4936 4956 - if (IS_QLA82XX(ha)) { 4957 - if (!list_empty(&ha->gbl_dsd_list)) { 4958 - struct dsd_dma *dsd_ptr, *tdsd_ptr; 4937 + if (!list_empty(&ha->base_qpair->dsd_list)) { 4938 + struct dsd_dma *dsd_ptr, *tdsd_ptr; 4959 4939 4960 - /* clean up allocated prev pool */ 4961 - list_for_each_entry_safe(dsd_ptr, 4962 - tdsd_ptr, &ha->gbl_dsd_list, list) { 4963 - dma_pool_free(ha->dl_dma_pool, 4964 - dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); 4965 - list_del(&dsd_ptr->list); 4966 - kfree(dsd_ptr); 4967 - } 4940 + /* clean up allocated prev pool */ 4941 + list_for_each_entry_safe(dsd_ptr, tdsd_ptr, 4942 + &ha->base_qpair->dsd_list, list) { 4943 + dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr, 4944 + dsd_ptr->dsd_list_dma); 4945 + list_del(&dsd_ptr->list); 4946 + kfree(dsd_ptr); 4968 4947 } 4969 4948 } 4970 4949 ··· 5015 4998 dma_free_coherent(&ha->pdev->dev, ha->elsrej.size, 5016 4999 ha->elsrej.c, ha->elsrej.cdma); 5017 5000 ha->elsrej.c = NULL; 5001 + } 5002 + 5003 + if (ha->lsrjt.c) { 5004 + dma_free_coherent(&ha->pdev->dev, ha->lsrjt.size, ha->lsrjt.c, 5005 + ha->lsrjt.cdma); 5006 + ha->lsrjt.c = NULL; 5018 5007 } 5019 5008 5020 5009 ha->init_cb = NULL;
+3 -3
drivers/scsi/qla2xxx/qla_version.h
··· 6 6 /* 7 7 * Driver version 8 8 */ 9 - #define QLA2XXX_VERSION "10.02.08.500-k" 9 + #define QLA2XXX_VERSION "10.02.09.100-k" 10 10 11 11 #define QLA_DRIVER_MAJOR_VER 10 12 12 #define QLA_DRIVER_MINOR_VER 2 13 - #define QLA_DRIVER_PATCH_VER 8 14 - #define QLA_DRIVER_BETA_VER 500 13 + #define QLA_DRIVER_PATCH_VER 9 14 + #define QLA_DRIVER_BETA_VER 100
+23 -3
drivers/scsi/scsi_debugfs.c
··· 3 3 #include <linux/seq_file.h> 4 4 #include <scsi/scsi_cmnd.h> 5 5 #include <scsi/scsi_dbg.h> 6 + #include <scsi/scsi_host.h> 6 7 #include "scsi_debugfs.h" 7 8 8 9 #define SCSI_CMD_FLAG_NAME(name)[const_ilog2(SCMD_##name)] = #name ··· 34 33 35 34 void scsi_show_rq(struct seq_file *m, struct request *rq) 36 35 { 37 - struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); 36 + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq), *cmd2; 37 + struct Scsi_Host *shost = cmd->device->host; 38 38 int alloc_ms = jiffies_to_msecs(jiffies - cmd->jiffies_at_alloc); 39 39 int timeout_ms = jiffies_to_msecs(rq->timeout); 40 + const char *list_info = NULL; 40 41 char buf[80] = "(?)"; 41 42 43 + spin_lock_irq(shost->host_lock); 44 + list_for_each_entry(cmd2, &shost->eh_abort_list, eh_entry) { 45 + if (cmd == cmd2) { 46 + list_info = "on eh_abort_list"; 47 + goto unlock; 48 + } 49 + } 50 + list_for_each_entry(cmd2, &shost->eh_cmd_q, eh_entry) { 51 + if (cmd == cmd2) { 52 + list_info = "on eh_cmd_q"; 53 + goto unlock; 54 + } 55 + } 56 + unlock: 57 + spin_unlock_irq(shost->host_lock); 58 + 42 59 __scsi_format_command(buf, sizeof(buf), cmd->cmnd, cmd->cmd_len); 43 - seq_printf(m, ", .cmd=%s, .retries=%d, .result = %#x, .flags=", buf, 44 - cmd->retries, cmd->result); 60 + seq_printf(m, ", .cmd=%s, .retries=%d, .allowed=%d, .result = %#x, %s%s.flags=", 61 + buf, cmd->retries, cmd->allowed, cmd->result, 62 + list_info ? : "", list_info ? ", " : ""); 45 63 scsi_flags_show(m, cmd->flags, scsi_cmd_flags, 46 64 ARRAY_SIZE(scsi_cmd_flags)); 47 65 seq_printf(m, ", .timeout=%d.%03d, allocated %d.%03d s ago",
+1 -1
drivers/scsi/scsi_lib.c
··· 2454 2454 envp[idx++] = "SDEV_MEDIA_CHANGE=1"; 2455 2455 break; 2456 2456 case SDEV_EVT_INQUIRY_CHANGE_REPORTED: 2457 - scsi_rescan_device(&sdev->sdev_gendev); 2457 + scsi_rescan_device(sdev); 2458 2458 envp[idx++] = "SDEV_UA=INQUIRY_DATA_HAS_CHANGED"; 2459 2459 break; 2460 2460 case SDEV_EVT_CAPACITY_CHANGE_REPORTED:
-1
drivers/scsi/scsi_priv.h
··· 137 137 extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int, 138 138 unsigned int, u64, enum scsi_scan_mode); 139 139 extern void scsi_forget_host(struct Scsi_Host *); 140 - extern void scsi_rescan_device(struct device *); 141 140 142 141 /* scsi_sysctl.c */ 143 142 #ifdef CONFIG_SYSCTL
+2 -2
drivers/scsi/scsi_scan.c
··· 1619 1619 } 1620 1620 EXPORT_SYMBOL(scsi_add_device); 1621 1621 1622 - void scsi_rescan_device(struct device *dev) 1622 + void scsi_rescan_device(struct scsi_device *sdev) 1623 1623 { 1624 - struct scsi_device *sdev = to_scsi_device(dev); 1624 + struct device *dev = &sdev->sdev_gendev; 1625 1625 1626 1626 device_lock(dev); 1627 1627
+2 -2
drivers/scsi/scsi_sysfs.c
··· 747 747 store_rescan_field (struct device *dev, struct device_attribute *attr, 748 748 const char *buf, size_t count) 749 749 { 750 - scsi_rescan_device(dev); 750 + scsi_rescan_device(to_scsi_device(dev)); 751 751 return count; 752 752 } 753 753 static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field); ··· 840 840 * waiting for pending I/O to finish. 841 841 */ 842 842 blk_mq_run_hw_queues(sdev->request_queue, true); 843 - scsi_rescan_device(dev); 843 + scsi_rescan_device(sdev); 844 844 } 845 845 846 846 return ret == 0 ? count : -EINVAL;
+27 -39
drivers/scsi/sd.c
··· 104 104 static void sd_config_write_same(struct scsi_disk *); 105 105 static int sd_revalidate_disk(struct gendisk *); 106 106 static void sd_unlock_native_capacity(struct gendisk *disk); 107 - static int sd_probe(struct device *); 108 - static int sd_remove(struct device *); 109 107 static void sd_shutdown(struct device *); 110 - static int sd_suspend_system(struct device *); 111 - static int sd_suspend_runtime(struct device *); 112 - static int sd_resume_system(struct device *); 113 - static int sd_resume_runtime(struct device *); 114 - static void sd_rescan(struct device *); 115 - static blk_status_t sd_init_command(struct scsi_cmnd *SCpnt); 116 - static void sd_uninit_command(struct scsi_cmnd *SCpnt); 117 - static int sd_done(struct scsi_cmnd *); 118 - static void sd_eh_reset(struct scsi_cmnd *); 119 - static int sd_eh_action(struct scsi_cmnd *, int); 120 108 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 121 109 static void scsi_disk_release(struct device *cdev); 122 110 ··· 578 590 .name = "scsi_disk", 579 591 .dev_release = scsi_disk_release, 580 592 .dev_groups = sd_disk_groups, 581 - }; 582 - 583 - static const struct dev_pm_ops sd_pm_ops = { 584 - .suspend = sd_suspend_system, 585 - .resume = sd_resume_system, 586 - .poweroff = sd_suspend_system, 587 - .restore = sd_resume_system, 588 - .runtime_suspend = sd_suspend_runtime, 589 - .runtime_resume = sd_resume_runtime, 590 - }; 591 - 592 - static struct scsi_driver sd_template = { 593 - .gendrv = { 594 - .name = "sd", 595 - .owner = THIS_MODULE, 596 - .probe = sd_probe, 597 - .probe_type = PROBE_PREFER_ASYNCHRONOUS, 598 - .remove = sd_remove, 599 - .shutdown = sd_shutdown, 600 - .pm = &sd_pm_ops, 601 - }, 602 - .rescan = sd_rescan, 603 - .init_command = sd_init_command, 604 - .uninit_command = sd_uninit_command, 605 - .done = sd_done, 606 - .eh_action = sd_eh_action, 607 - .eh_reset = sd_eh_reset, 608 593 }; 609 594 610 595 /* ··· 3889 3928 3890 3929 return sd_resume(dev); 3891 3930 } 3931 + 3932 + static const struct dev_pm_ops sd_pm_ops = { 3933 + .suspend = sd_suspend_system, 3934 + .resume = sd_resume_system, 3935 + .poweroff = sd_suspend_system, 3936 + .restore = sd_resume_system, 3937 + .runtime_suspend = sd_suspend_runtime, 3938 + .runtime_resume = sd_resume_runtime, 3939 + }; 3940 + 3941 + static struct scsi_driver sd_template = { 3942 + .gendrv = { 3943 + .name = "sd", 3944 + .owner = THIS_MODULE, 3945 + .probe = sd_probe, 3946 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 3947 + .remove = sd_remove, 3948 + .shutdown = sd_shutdown, 3949 + .pm = &sd_pm_ops, 3950 + }, 3951 + .rescan = sd_rescan, 3952 + .init_command = sd_init_command, 3953 + .uninit_command = sd_uninit_command, 3954 + .done = sd_done, 3955 + .eh_action = sd_eh_action, 3956 + .eh_reset = sd_eh_reset, 3957 + }; 3892 3958 3893 3959 /** 3894 3960 * init_sd - entry point for this driver (both when built in or when
+14 -2
drivers/scsi/smartpqi/smartpqi.h
··· 710 710 #define SOP_TMF_COMPLETE 0x0 711 711 #define SOP_TMF_REJECTED 0x4 712 712 #define SOP_TMF_FUNCTION_SUCCEEDED 0x8 713 - #define SOP_RC_INCORRECT_LOGICAL_UNIT 0x9 713 + #define SOP_TMF_INCORRECT_LOGICAL_UNIT 0x9 714 714 715 715 /* additional CDB bytes usage field codes */ 716 716 #define SOP_ADDITIONAL_CDB_BYTES_0 0 /* 16-byte CDB */ ··· 1085 1085 u32 last_accessed; 1086 1086 }; 1087 1087 1088 - #define PQI_MAX_LUNS_PER_DEVICE 256 1088 + #define PQI_MAX_LUNS_PER_DEVICE 256 1089 + 1090 + struct pqi_tmf_work { 1091 + struct work_struct work_struct; 1092 + struct scsi_cmnd *scmd; 1093 + struct pqi_ctrl_info *ctrl_info; 1094 + struct pqi_scsi_dev *device; 1095 + u8 lun; 1096 + u8 scsi_opcode; 1097 + }; 1089 1098 1090 1099 struct pqi_scsi_dev { 1091 1100 int devtype; /* as reported by INQUIRY command */ ··· 1120 1111 u8 erase_in_progress : 1; 1121 1112 bool aio_enabled; /* only valid for physical disks */ 1122 1113 bool in_remove; 1114 + bool in_reset[PQI_MAX_LUNS_PER_DEVICE]; 1123 1115 bool device_offline; 1124 1116 u8 vendor[8]; /* bytes 8-15 of inquiry data */ 1125 1117 u8 model[16]; /* bytes 16-31 of inquiry data */ ··· 1159 1149 struct pqi_stream_data stream_data[NUM_STREAMS_PER_LUN]; 1160 1150 atomic_t scsi_cmds_outstanding[PQI_MAX_LUNS_PER_DEVICE]; 1161 1151 unsigned int raid_bypass_cnt; 1152 + 1153 + struct pqi_tmf_work tmf_work[PQI_MAX_LUNS_PER_DEVICE]; 1162 1154 }; 1163 1155 1164 1156 /* VPD inquiry pages */
+206 -58
drivers/scsi/smartpqi/smartpqi_init.c
··· 33 33 #define BUILD_TIMESTAMP 34 34 #endif 35 35 36 - #define DRIVER_VERSION "2.1.22-040" 36 + #define DRIVER_VERSION "2.1.24-046" 37 37 #define DRIVER_MAJOR 2 38 38 #define DRIVER_MINOR 1 39 - #define DRIVER_RELEASE 22 40 - #define DRIVER_REVISION 40 39 + #define DRIVER_RELEASE 24 40 + #define DRIVER_REVISION 46 41 41 42 42 #define DRIVER_NAME "Microchip SmartPQI Driver (v" \ 43 43 DRIVER_VERSION BUILD_TIMESTAMP ")" ··· 47 47 48 48 #define PQI_POST_RESET_DELAY_SECS 5 49 49 #define PQI_POST_OFA_RESET_DELAY_UPON_TIMEOUT_SECS 10 50 + 51 + #define PQI_NO_COMPLETION ((void *)-1) 50 52 51 53 MODULE_AUTHOR("Microchip"); 52 54 MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version " ··· 98 96 static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info, 99 97 struct pqi_scsi_dev *device, u8 lun, unsigned long timeout_msecs); 100 98 static void pqi_fail_all_outstanding_requests(struct pqi_ctrl_info *ctrl_info); 99 + static void pqi_tmf_worker(struct work_struct *work); 101 100 102 101 /* for flags argument to pqi_submit_raid_request_synchronous() */ 103 102 #define PQI_SYNC_FLAGS_INTERRUPTABLE 0x1 ··· 456 453 static inline bool pqi_device_in_remove(struct pqi_scsi_dev *device) 457 454 { 458 455 return device->in_remove; 456 + } 457 + 458 + static inline void pqi_device_reset_start(struct pqi_scsi_dev *device, u8 lun) 459 + { 460 + device->in_reset[lun] = true; 461 + } 462 + 463 + static inline void pqi_device_reset_done(struct pqi_scsi_dev *device, u8 lun) 464 + { 465 + device->in_reset[lun] = false; 466 + } 467 + 468 + static inline bool pqi_device_in_reset(struct pqi_scsi_dev *device, u8 lun) 469 + { 470 + return device->in_reset[lun]; 459 471 } 460 472 461 473 static inline int pqi_event_type_to_event_index(unsigned int event_type) ··· 2155 2137 return device->sdev != NULL; 2156 2138 } 2157 2139 2140 + static inline void pqi_init_device_tmf_work(struct pqi_scsi_dev *device) 2141 + { 2142 + unsigned int lun; 2143 + struct pqi_tmf_work *tmf_work; 2144 + 2145 + for (lun = 0, tmf_work = device->tmf_work; lun < PQI_MAX_LUNS_PER_DEVICE; lun++, tmf_work++) 2146 + INIT_WORK(&tmf_work->work_struct, pqi_tmf_worker); 2147 + } 2148 + 2158 2149 static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info, 2159 2150 struct pqi_scsi_dev *new_device_list[], unsigned int num_new_devices) 2160 2151 { ··· 2244 2217 list_add_tail(&device->add_list_entry, &add_list); 2245 2218 /* To prevent this device structure from being freed later. */ 2246 2219 device->keep_device = true; 2220 + pqi_init_device_tmf_work(device); 2247 2221 } 2248 2222 2249 2223 spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags); ··· 2285 2257 device->advertised_queue_depth = device->queue_depth; 2286 2258 scsi_change_queue_depth(device->sdev, device->advertised_queue_depth); 2287 2259 if (device->rescan) { 2288 - scsi_rescan_device(&device->sdev->sdev_gendev); 2260 + scsi_rescan_device(device->sdev); 2289 2261 device->rescan = false; 2290 2262 } 2291 2263 } ··· 3358 3330 case SOP_TMF_REJECTED: 3359 3331 rc = -EAGAIN; 3360 3332 break; 3361 - case SOP_RC_INCORRECT_LOGICAL_UNIT: 3333 + case SOP_TMF_INCORRECT_LOGICAL_UNIT: 3362 3334 rc = -ENODEV; 3363 3335 break; 3364 3336 default: ··· 5656 5628 int rc; 5657 5629 struct pqi_io_request *io_request; 5658 5630 struct pqi_aio_path_request *request; 5659 - struct pqi_scsi_dev *device; 5660 5631 5661 5632 io_request = pqi_alloc_io_request(ctrl_info, scmd); 5662 5633 if (!io_request) ··· 5675 5648 request->command_priority = io_high_prio; 5676 5649 put_unaligned_le16(io_request->index, &request->request_id); 5677 5650 request->error_index = request->request_id; 5678 - device = scmd->device->hostdata; 5679 - if (!pqi_is_logical_device(device) && ctrl_info->multi_lun_device_supported) 5680 - put_unaligned_le64(((scmd->device->lun) << 8), &request->lun_number); 5651 + if (!raid_bypass && ctrl_info->multi_lun_device_supported) 5652 + put_unaligned_le64(scmd->device->lun << 8, &request->lun_number); 5681 5653 if (cdb_length > sizeof(request->cdb)) 5682 5654 cdb_length = sizeof(request->cdb); 5683 5655 request->cdb_length = cdb_length; ··· 5876 5850 void pqi_prep_for_scsi_done(struct scsi_cmnd *scmd) 5877 5851 { 5878 5852 struct pqi_scsi_dev *device; 5853 + struct completion *wait; 5879 5854 5880 5855 if (!scmd->device) { 5881 5856 set_host_byte(scmd, DID_NO_CONNECT); ··· 5890 5863 } 5891 5864 5892 5865 atomic_dec(&device->scsi_cmds_outstanding[scmd->device->lun]); 5866 + 5867 + wait = (struct completion *)xchg(&scmd->host_scribble, NULL); 5868 + if (wait != PQI_NO_COMPLETION) 5869 + complete(wait); 5893 5870 } 5894 5871 5895 5872 static bool pqi_is_parity_write_stream(struct pqi_ctrl_info *ctrl_info, ··· 5979 5948 u16 hw_queue; 5980 5949 struct pqi_queue_group *queue_group; 5981 5950 bool raid_bypassed; 5951 + u8 lun; 5952 + 5953 + scmd->host_scribble = PQI_NO_COMPLETION; 5982 5954 5983 5955 device = scmd->device->hostdata; 5984 5956 ··· 5991 5957 return 0; 5992 5958 } 5993 5959 5994 - atomic_inc(&device->scsi_cmds_outstanding[scmd->device->lun]); 5960 + lun = (u8)scmd->device->lun; 5961 + 5962 + atomic_inc(&device->scsi_cmds_outstanding[lun]); 5995 5963 5996 5964 ctrl_info = shost_to_hba(shost); 5997 5965 ··· 6003 5967 return 0; 6004 5968 } 6005 5969 6006 - if (pqi_ctrl_blocked(ctrl_info)) { 5970 + if (pqi_ctrl_blocked(ctrl_info) || pqi_device_in_reset(device, lun)) { 6007 5971 rc = SCSI_MLQUEUE_HOST_BUSY; 6008 5972 goto out; 6009 5973 } ··· 6038 6002 } 6039 6003 6040 6004 out: 6041 - if (rc) 6042 - atomic_dec(&device->scsi_cmds_outstanding[scmd->device->lun]); 6005 + if (rc) { 6006 + scmd->host_scribble = NULL; 6007 + atomic_dec(&device->scsi_cmds_outstanding[lun]); 6008 + } 6043 6009 6044 6010 return rc; 6045 6011 } ··· 6135 6097 } 6136 6098 6137 6099 static void pqi_fail_io_queued_for_device(struct pqi_ctrl_info *ctrl_info, 6138 - struct pqi_scsi_dev *device) 6100 + struct pqi_scsi_dev *device, u8 lun) 6139 6101 { 6140 6102 unsigned int i; 6141 6103 unsigned int path; ··· 6163 6125 6164 6126 scsi_device = scmd->device->hostdata; 6165 6127 if (scsi_device != device) 6128 + continue; 6129 + 6130 + if ((u8)scmd->device->lun != lun) 6166 6131 continue; 6167 6132 6168 6133 list_del(&io_request->request_list_entry); ··· 6265 6224 6266 6225 #define PQI_LUN_RESET_FIRMWARE_TIMEOUT_SECS 30 6267 6226 6268 - static int pqi_lun_reset(struct pqi_ctrl_info *ctrl_info, struct scsi_cmnd *scmd) 6227 + static int pqi_lun_reset(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, u8 lun) 6269 6228 { 6270 6229 int rc; 6271 6230 struct pqi_io_request *io_request; 6272 6231 DECLARE_COMPLETION_ONSTACK(wait); 6273 6232 struct pqi_task_management_request *request; 6274 - struct pqi_scsi_dev *device; 6275 6233 6276 - device = scmd->device->hostdata; 6277 6234 io_request = pqi_alloc_io_request(ctrl_info, NULL); 6278 6235 io_request->io_complete_callback = pqi_lun_reset_complete; 6279 6236 io_request->context = &wait; ··· 6286 6247 memcpy(request->lun_number, device->scsi3addr, 6287 6248 sizeof(request->lun_number)); 6288 6249 if (!pqi_is_logical_device(device) && ctrl_info->multi_lun_device_supported) 6289 - request->ml_device_lun_number = (u8)scmd->device->lun; 6250 + request->ml_device_lun_number = lun; 6290 6251 request->task_management_function = SOP_TASK_MANAGEMENT_LUN_RESET; 6291 6252 if (ctrl_info->tmf_iu_timeout_supported) 6292 6253 put_unaligned_le16(PQI_LUN_RESET_FIRMWARE_TIMEOUT_SECS, &request->timeout); ··· 6294 6255 pqi_start_io(ctrl_info, &ctrl_info->queue_groups[PQI_DEFAULT_QUEUE_GROUP], RAID_PATH, 6295 6256 io_request); 6296 6257 6297 - rc = pqi_wait_for_lun_reset_completion(ctrl_info, device, (u8)scmd->device->lun, &wait); 6258 + rc = pqi_wait_for_lun_reset_completion(ctrl_info, device, lun, &wait); 6298 6259 if (rc == 0) 6299 6260 rc = io_request->status; 6300 6261 ··· 6308 6269 #define PQI_LUN_RESET_PENDING_IO_TIMEOUT_MSECS (10 * 60 * 1000) 6309 6270 #define PQI_LUN_RESET_FAILED_PENDING_IO_TIMEOUT_MSECS (2 * 60 * 1000) 6310 6271 6311 - static int pqi_lun_reset_with_retries(struct pqi_ctrl_info *ctrl_info, struct scsi_cmnd *scmd) 6272 + static int pqi_lun_reset_with_retries(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, u8 lun) 6312 6273 { 6313 6274 int reset_rc; 6314 6275 int wait_rc; 6315 6276 unsigned int retries; 6316 6277 unsigned long timeout_msecs; 6317 - struct pqi_scsi_dev *device; 6318 6278 6319 - device = scmd->device->hostdata; 6320 6279 for (retries = 0;;) { 6321 - reset_rc = pqi_lun_reset(ctrl_info, scmd); 6322 - if (reset_rc == 0 || reset_rc == -ENODEV || ++retries > PQI_LUN_RESET_RETRIES) 6280 + reset_rc = pqi_lun_reset(ctrl_info, device, lun); 6281 + if (reset_rc == 0 || reset_rc == -ENODEV || reset_rc == -ENXIO || ++retries > PQI_LUN_RESET_RETRIES) 6323 6282 break; 6324 6283 msleep(PQI_LUN_RESET_RETRY_INTERVAL_MSECS); 6325 6284 } ··· 6325 6288 timeout_msecs = reset_rc ? PQI_LUN_RESET_FAILED_PENDING_IO_TIMEOUT_MSECS : 6326 6289 PQI_LUN_RESET_PENDING_IO_TIMEOUT_MSECS; 6327 6290 6328 - wait_rc = pqi_device_wait_for_pending_io(ctrl_info, device, scmd->device->lun, timeout_msecs); 6291 + wait_rc = pqi_device_wait_for_pending_io(ctrl_info, device, lun, timeout_msecs); 6329 6292 if (wait_rc && reset_rc == 0) 6330 6293 reset_rc = wait_rc; 6331 6294 6332 6295 return reset_rc == 0 ? SUCCESS : FAILED; 6333 6296 } 6334 6297 6335 - static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, struct scsi_cmnd *scmd) 6298 + static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, u8 lun) 6336 6299 { 6337 6300 int rc; 6338 - struct pqi_scsi_dev *device; 6339 6301 6340 - device = scmd->device->hostdata; 6341 6302 pqi_ctrl_block_requests(ctrl_info); 6342 6303 pqi_ctrl_wait_until_quiesced(ctrl_info); 6343 - pqi_fail_io_queued_for_device(ctrl_info, device); 6304 + pqi_fail_io_queued_for_device(ctrl_info, device, lun); 6344 6305 rc = pqi_wait_until_inbound_queues_empty(ctrl_info); 6306 + pqi_device_reset_start(device, lun); 6307 + pqi_ctrl_unblock_requests(ctrl_info); 6345 6308 if (rc) 6346 6309 rc = FAILED; 6347 6310 else 6348 - rc = pqi_lun_reset_with_retries(ctrl_info, scmd); 6349 - pqi_ctrl_unblock_requests(ctrl_info); 6311 + rc = pqi_lun_reset_with_retries(ctrl_info, device, lun); 6312 + pqi_device_reset_done(device, lun); 6313 + 6314 + return rc; 6315 + } 6316 + 6317 + static int pqi_device_reset_handler(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, u8 lun, struct scsi_cmnd *scmd, u8 scsi_opcode) 6318 + { 6319 + int rc; 6320 + 6321 + mutex_lock(&ctrl_info->lun_reset_mutex); 6322 + 6323 + dev_err(&ctrl_info->pci_dev->dev, 6324 + "resetting scsi %d:%d:%d:%u SCSI cmd at %p due to cmd opcode 0x%02x\n", 6325 + ctrl_info->scsi_host->host_no, device->bus, device->target, lun, scmd, scsi_opcode); 6326 + 6327 + pqi_check_ctrl_health(ctrl_info); 6328 + if (pqi_ctrl_offline(ctrl_info)) 6329 + rc = FAILED; 6330 + else 6331 + rc = pqi_device_reset(ctrl_info, device, lun); 6332 + 6333 + dev_err(&ctrl_info->pci_dev->dev, 6334 + "reset of scsi %d:%d:%d:%u: %s\n", 6335 + ctrl_info->scsi_host->host_no, device->bus, device->target, lun, 6336 + rc == SUCCESS ? "SUCCESS" : "FAILED"); 6337 + 6338 + mutex_unlock(&ctrl_info->lun_reset_mutex); 6350 6339 6351 6340 return rc; 6352 6341 } 6353 6342 6354 6343 static int pqi_eh_device_reset_handler(struct scsi_cmnd *scmd) 6355 6344 { 6356 - int rc; 6357 6345 struct Scsi_Host *shost; 6358 6346 struct pqi_ctrl_info *ctrl_info; 6359 6347 struct pqi_scsi_dev *device; 6348 + u8 scsi_opcode; 6349 + 6350 + shost = scmd->device->host; 6351 + ctrl_info = shost_to_hba(shost); 6352 + device = scmd->device->hostdata; 6353 + scsi_opcode = scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff; 6354 + 6355 + return pqi_device_reset_handler(ctrl_info, device, (u8)scmd->device->lun, scmd, scsi_opcode); 6356 + } 6357 + 6358 + static void pqi_tmf_worker(struct work_struct *work) 6359 + { 6360 + struct pqi_tmf_work *tmf_work; 6361 + struct scsi_cmnd *scmd; 6362 + 6363 + tmf_work = container_of(work, struct pqi_tmf_work, work_struct); 6364 + scmd = (struct scsi_cmnd *)xchg(&tmf_work->scmd, NULL); 6365 + 6366 + pqi_device_reset_handler(tmf_work->ctrl_info, tmf_work->device, tmf_work->lun, scmd, tmf_work->scsi_opcode); 6367 + } 6368 + 6369 + static int pqi_eh_abort_handler(struct scsi_cmnd *scmd) 6370 + { 6371 + struct Scsi_Host *shost; 6372 + struct pqi_ctrl_info *ctrl_info; 6373 + struct pqi_scsi_dev *device; 6374 + struct pqi_tmf_work *tmf_work; 6375 + DECLARE_COMPLETION_ONSTACK(wait); 6360 6376 6361 6377 shost = scmd->device->host; 6362 6378 ctrl_info = shost_to_hba(shost); 6363 6379 device = scmd->device->hostdata; 6364 6380 6365 - mutex_lock(&ctrl_info->lun_reset_mutex); 6381 + dev_err(&ctrl_info->pci_dev->dev, 6382 + "attempting TASK ABORT on scsi %d:%d:%d:%d for SCSI cmd at %p\n", 6383 + shost->host_no, device->bus, device->target, (int)scmd->device->lun, scmd); 6384 + 6385 + if (cmpxchg(&scmd->host_scribble, PQI_NO_COMPLETION, (void *)&wait) == NULL) { 6386 + dev_err(&ctrl_info->pci_dev->dev, 6387 + "scsi %d:%d:%d:%d for SCSI cmd at %p already completed\n", 6388 + shost->host_no, device->bus, device->target, (int)scmd->device->lun, scmd); 6389 + scmd->result = DID_RESET << 16; 6390 + goto out; 6391 + } 6392 + 6393 + tmf_work = &device->tmf_work[scmd->device->lun]; 6394 + 6395 + if (cmpxchg(&tmf_work->scmd, NULL, scmd) == NULL) { 6396 + tmf_work->ctrl_info = ctrl_info; 6397 + tmf_work->device = device; 6398 + tmf_work->lun = (u8)scmd->device->lun; 6399 + tmf_work->scsi_opcode = scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff; 6400 + schedule_work(&tmf_work->work_struct); 6401 + } 6402 + 6403 + wait_for_completion(&wait); 6366 6404 6367 6405 dev_err(&ctrl_info->pci_dev->dev, 6368 - "resetting scsi %d:%d:%d:%d due to cmd 0x%02x\n", 6369 - shost->host_no, 6370 - device->bus, device->target, (u32)scmd->device->lun, 6371 - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff); 6406 + "TASK ABORT on scsi %d:%d:%d:%d for SCSI cmd at %p: SUCCESS\n", 6407 + shost->host_no, device->bus, device->target, (int)scmd->device->lun, scmd); 6372 6408 6373 - pqi_check_ctrl_health(ctrl_info); 6374 - if (pqi_ctrl_offline(ctrl_info)) 6375 - rc = FAILED; 6376 - else 6377 - rc = pqi_device_reset(ctrl_info, scmd); 6409 + out: 6378 6410 6379 - dev_err(&ctrl_info->pci_dev->dev, 6380 - "reset of scsi %d:%d:%d:%d: %s\n", 6381 - shost->host_no, device->bus, device->target, (u32)scmd->device->lun, 6382 - rc == SUCCESS ? "SUCCESS" : "FAILED"); 6383 - 6384 - mutex_unlock(&ctrl_info->lun_reset_mutex); 6385 - 6386 - return rc; 6411 + return SUCCESS; 6387 6412 } 6388 6413 6389 6414 static int pqi_slave_alloc(struct scsi_device *sdev) ··· 6569 6470 struct pci_dev *pci_dev; 6570 6471 u32 subsystem_vendor; 6571 6472 u32 subsystem_device; 6572 - cciss_pci_info_struct pciinfo; 6473 + cciss_pci_info_struct pci_info; 6573 6474 6574 6475 if (!arg) 6575 6476 return -EINVAL; 6576 6477 6577 6478 pci_dev = ctrl_info->pci_dev; 6578 6479 6579 - pciinfo.domain = pci_domain_nr(pci_dev->bus); 6580 - pciinfo.bus = pci_dev->bus->number; 6581 - pciinfo.dev_fn = pci_dev->devfn; 6480 + pci_info.domain = pci_domain_nr(pci_dev->bus); 6481 + pci_info.bus = pci_dev->bus->number; 6482 + pci_info.dev_fn = pci_dev->devfn; 6582 6483 subsystem_vendor = pci_dev->subsystem_vendor; 6583 6484 subsystem_device = pci_dev->subsystem_device; 6584 - pciinfo.board_id = ((subsystem_device << 16) & 0xffff0000) | subsystem_vendor; 6485 + pci_info.board_id = ((subsystem_device << 16) & 0xffff0000) | subsystem_vendor; 6585 6486 6586 - if (copy_to_user(arg, &pciinfo, sizeof(pciinfo))) 6487 + if (copy_to_user(arg, &pci_info, sizeof(pci_info))) 6587 6488 return -EFAULT; 6588 6489 6589 6490 return 0; ··· 7461 7362 .scan_finished = pqi_scan_finished, 7462 7363 .this_id = -1, 7463 7364 .eh_device_reset_handler = pqi_eh_device_reset_handler, 7365 + .eh_abort_handler = pqi_eh_abort_handler, 7464 7366 .ioctl = pqi_ioctl, 7465 7367 .slave_alloc = pqi_slave_alloc, 7466 7368 .slave_configure = pqi_slave_configure, ··· 9004 8904 pqi_take_ctrl_offline_deferred(ctrl_info); 9005 8905 } 9006 8906 8907 + static char *pqi_ctrl_shutdown_reason_to_string(enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) 8908 + { 8909 + char *string; 8910 + 8911 + switch (ctrl_shutdown_reason) { 8912 + case PQI_IQ_NOT_DRAINED_TIMEOUT: 8913 + string = "inbound queue not drained timeout"; 8914 + break; 8915 + case PQI_LUN_RESET_TIMEOUT: 8916 + string = "LUN reset timeout"; 8917 + break; 8918 + case PQI_IO_PENDING_POST_LUN_RESET_TIMEOUT: 8919 + string = "I/O pending timeout after LUN reset"; 8920 + break; 8921 + case PQI_NO_HEARTBEAT: 8922 + string = "no controller heartbeat detected"; 8923 + break; 8924 + case PQI_FIRMWARE_KERNEL_NOT_UP: 8925 + string = "firmware kernel not ready"; 8926 + break; 8927 + case PQI_OFA_RESPONSE_TIMEOUT: 8928 + string = "OFA response timeout"; 8929 + break; 8930 + case PQI_INVALID_REQ_ID: 8931 + string = "invalid request ID"; 8932 + break; 8933 + case PQI_UNMATCHED_REQ_ID: 8934 + string = "unmatched request ID"; 8935 + break; 8936 + case PQI_IO_PI_OUT_OF_RANGE: 8937 + string = "I/O queue producer index out of range"; 8938 + break; 8939 + case PQI_EVENT_PI_OUT_OF_RANGE: 8940 + string = "event queue producer index out of range"; 8941 + break; 8942 + case PQI_UNEXPECTED_IU_TYPE: 8943 + string = "unexpected IU type"; 8944 + break; 8945 + default: 8946 + string = "unknown reason"; 8947 + break; 8948 + } 8949 + 8950 + return string; 8951 + } 8952 + 9007 8953 static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info, 9008 8954 enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason) 9009 8955 { ··· 9062 8916 if (!pqi_disable_ctrl_shutdown) 9063 8917 sis_shutdown_ctrl(ctrl_info, ctrl_shutdown_reason); 9064 8918 pci_disable_device(ctrl_info->pci_dev); 9065 - dev_err(&ctrl_info->pci_dev->dev, "controller offline\n"); 8919 + dev_err(&ctrl_info->pci_dev->dev, 8920 + "controller offline: reason code 0x%x (%s)\n", 8921 + ctrl_shutdown_reason, pqi_ctrl_shutdown_reason_to_string(ctrl_shutdown_reason)); 9066 8922 schedule_work(&ctrl_info->ctrl_offline_work); 9067 8923 } 9068 8924 ··· 9210 9062 rc = pqi_flush_cache(ctrl_info, shutdown_event); 9211 9063 if (rc) 9212 9064 dev_err(&pci_dev->dev, 9213 - "unable to flush controller cache\n"); 9065 + "unable to flush controller cache during shutdown\n"); 9214 9066 9215 9067 pqi_crash_if_pending_command(ctrl_info); 9216 9068 pqi_reset(ctrl_info);
+2
drivers/scsi/st.c
··· 414 414 if (cmdstatp->have_sense && 415 415 cmdstatp->sense_hdr.asc == 0 && cmdstatp->sense_hdr.ascq == 0x17) 416 416 STp->cleaning_req = 1; /* ASC and ASCQ => cleaning requested */ 417 + if (cmdstatp->have_sense && scode == UNIT_ATTENTION && cmdstatp->sense_hdr.asc == 0x29) 418 + STp->pos_unknown = 1; /* ASC => power on / reset */ 417 419 418 420 STp->pos_unknown |= STp->device->was_reset; 419 421
+1 -1
drivers/scsi/storvsc_drv.c
··· 475 475 sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); 476 476 if (!sdev) 477 477 goto done; 478 - scsi_rescan_device(&sdev->sdev_gendev); 478 + scsi_rescan_device(sdev); 479 479 scsi_device_put(sdev); 480 480 481 481 done:
+1 -1
drivers/scsi/virtio_scsi.c
··· 325 325 /* Handle "Parameters changed", "Mode parameters changed", and 326 326 "Capacity data has changed". */ 327 327 if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09)) 328 - scsi_rescan_device(&sdev->sdev_gendev); 328 + scsi_rescan_device(sdev); 329 329 330 330 scsi_device_put(sdev); 331 331 }
+3 -3
drivers/scsi/xen-scsifront.c
··· 743 743 if (info->host_active == STATE_ERROR) 744 744 return -EIO; 745 745 746 - if (info && current == info->curr) { 746 + if (current == info->curr) { 747 747 err = xenbus_printf(XBT_NIL, info->dev->nodename, 748 748 info->dev_state_path, "%d", XenbusStateConnected); 749 749 if (err) { ··· 761 761 struct vscsifrnt_info *info = shost_priv(sdev->host); 762 762 int err; 763 763 764 - if (info && current == info->curr) { 764 + if (current == info->curr) { 765 765 err = xenbus_printf(XBT_NIL, info->dev->nodename, 766 766 info->dev_state_path, "%d", XenbusStateClosed); 767 767 if (err) ··· 903 903 xenbus_dev_fatal(dev, err, "fail to allocate scsi host"); 904 904 return err; 905 905 } 906 - info = (struct vscsifrnt_info *)host->hostdata; 906 + info = shost_priv(host); 907 907 908 908 dev_set_drvdata(&dev->dev, info); 909 909 info->dev = dev;
+1 -2
drivers/ufs/core/ufs_bsg.c
··· 76 76 int ret; 77 77 int data_len; 78 78 79 - if (hba->ufs_version < ufshci_version(4, 0) || !hba->dev_info.b_advanced_rpmb_en || 80 - !(hba->capabilities & MASK_EHSLUTRD_SUPPORTED)) 79 + if (hba->ufs_version < ufshci_version(4, 0) || !hba->dev_info.b_advanced_rpmb_en) 81 80 return -EINVAL; 82 81 83 82 if (rpmb_request->ehs_req.length != 2 || rpmb_request->ehs_req.ehs_type != 1)
+10 -4
drivers/ufs/core/ufshcd.c
··· 7240 7240 /* Advanced RPMB starts from UFS 4.0, so its command type is UTP_CMD_TYPE_UFS_STORAGE */ 7241 7241 lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE; 7242 7242 7243 - ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2); 7243 + /* 7244 + * According to UFSHCI 4.0 specification page 24, if EHSLUTRDS is 0, host controller takes 7245 + * EHS length from CMD UPIU, and SW driver use EHS Length field in CMD UPIU. if it is 1, 7246 + * HW controller takes EHS length from UTRD. 7247 + */ 7248 + if (hba->capabilities & MASK_EHSLUTRD_SUPPORTED) 7249 + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2); 7250 + else 7251 + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 0); 7244 7252 7245 - /* update the task tag and LUN in the request upiu */ 7246 - req_upiu->header.flags = upiu_flags; 7247 - req_upiu->header.lun = UFS_UPIU_RPMB_WLUN; 7253 + /* update the task tag */ 7248 7254 req_upiu->header.task_tag = tag; 7249 7255 7250 7256 /* copy the UPIU(contains CDB) request as it is */
+3 -3
include/linux/nvme-fc-driver.h
··· 53 53 struct nvmefc_ls_req { 54 54 void *rqstaddr; 55 55 dma_addr_t rqstdma; 56 - u32 rqstlen; 56 + __le32 rqstlen; 57 57 void *rspaddr; 58 58 dma_addr_t rspdma; 59 - u32 rsplen; 59 + __le32 rsplen; 60 60 u32 timeout; 61 61 62 62 void *private; ··· 120 120 struct nvmefc_ls_rsp { 121 121 void *rspbuf; 122 122 dma_addr_t rspdma; 123 - u16 rsplen; 123 + __le32 rsplen; 124 124 125 125 void (*done)(struct nvmefc_ls_rsp *rsp); 126 126 void *nvme_fc_private; /* LLDD is not to access !! */
+1 -1
include/scsi/scsi_host.h
··· 764 764 #define scsi_template_proc_dir(sht) NULL 765 765 #endif 766 766 extern void scsi_scan_host(struct Scsi_Host *); 767 - extern void scsi_rescan_device(struct device *); 767 + extern void scsi_rescan_device(struct scsi_device *); 768 768 extern void scsi_remove_host(struct Scsi_Host *); 769 769 extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *); 770 770 extern int scsi_host_busy(struct Scsi_Host *shost);
+1 -1
include/uapi/scsi/scsi_bsg_ufs.h
··· 83 83 union { 84 84 __u8 tm_function; 85 85 __u8 query_function; 86 - }; 86 + } __attribute__((packed)); 87 87 __u8 response; 88 88 __u8 status; 89 89 __u8 ehs_length;