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

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

Pull more SCSI updates from James Bottomley:
"Updates that missed the first pull, mostly because of needing more
soak time.

Driver updates (zfcp, ufs, mpi3mr, plus two ipr bug fixes), an
enclosure services (ses) update (mostly bug fixes) and other minor bug
fixes and changes"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (32 commits)
scsi: zfcp: Trace when request remove fails after qdio send fails
scsi: zfcp: Change the type of all fsf request id fields and variables to u64
scsi: zfcp: Make the type for accessing request hashtable buckets size_t
scsi: ufs: core: Simplify ufshcd_execute_start_stop()
scsi: ufs: core: Rely on the block layer for setting RQF_PM
scsi: core: Extend struct scsi_exec_args
scsi: lpfc: Fix double word in comments
scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
scsi: core: Fix a source code comment
scsi: cxgbi: Remove unneeded version.h include
scsi: qedi: Remove unneeded version.h include
scsi: mpi3mr: Remove unneeded version.h include
scsi: mpi3mr: Fix missing mrioc->evtack_cmds initialization
scsi: mpi3mr: Use number of bits to manage bitmap sizes
scsi: mpi3mr: Remove unnecessary memcpy() to alltgt_info->dmi
scsi: mpi3mr: Fix issues in mpi3mr_get_all_tgt_info()
scsi: mpi3mr: Fix an issue found by KASAN
scsi: mpi3mr: Replace 1-element array with flex-array
scsi: ipr: Work around fortify-string warning
scsi: ipr: Make ipr_probe_ioa_part2() return void
...

+291 -252
+44 -2
drivers/s390/scsi/zfcp_dbf.c
··· 4 4 * 5 5 * Debug traces for zfcp. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #define KMSG_COMPONENT "zfcp" ··· 140 140 rec->u.fces.wwpn = wwpn; 141 141 rec->u.fces.fc_security_old = fc_security_old; 142 142 rec->u.fces.fc_security_new = fc_security_new; 143 + 144 + debug_event(dbf->hba, level, rec, sizeof(*rec)); 145 + spin_unlock_irqrestore(&dbf->hba_lock, flags); 146 + } 147 + 148 + /** 149 + * zfcp_dbf_hba_fsf_reqid - trace only the tag and a request ID 150 + * @tag: tag documenting the source 151 + * @level: trace level 152 + * @adapter: adapter instance the request ID belongs to 153 + * @req_id: the request ID to trace 154 + */ 155 + void zfcp_dbf_hba_fsf_reqid(const char *const tag, const int level, 156 + struct zfcp_adapter *const adapter, 157 + const u64 req_id) 158 + { 159 + struct zfcp_dbf *const dbf = adapter->dbf; 160 + struct zfcp_dbf_hba *const rec = &dbf->hba_buf; 161 + struct zfcp_dbf_hba_res *const res = &rec->u.res; 162 + unsigned long flags; 163 + 164 + if (unlikely(!debug_level_enabled(dbf->hba, level))) 165 + return; 166 + 167 + spin_lock_irqsave(&dbf->hba_lock, flags); 168 + memset(rec, 0, sizeof(*rec)); 169 + 170 + memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); 171 + 172 + rec->id = ZFCP_DBF_HBA_RES; 173 + rec->fsf_req_id = req_id; 174 + rec->fsf_req_status = ~0u; 175 + rec->fsf_cmd = ~0u; 176 + rec->fsf_seq_no = ~0u; 177 + 178 + res->req_issued = ~0ull; 179 + res->prot_status = ~0u; 180 + memset(res->prot_status_qual, 0xff, sizeof(res->prot_status_qual)); 181 + res->fsf_status = ~0u; 182 + memset(res->fsf_status_qual, 0xff, sizeof(res->fsf_status_qual)); 183 + res->port_handle = ~0u; 184 + res->lun_handle = ~0u; 143 185 144 186 debug_event(dbf->hba, level, rec, sizeof(*rec)); 145 187 spin_unlock_irqrestore(&dbf->hba_lock, flags); ··· 691 649 rec->scsi_id = sc->device->id; 692 650 rec->scsi_lun = (u32)sc->device->lun; 693 651 rec->scsi_lun_64_hi = (u32)(sc->device->lun >> 32); 694 - rec->host_scribble = (unsigned long)sc->host_scribble; 652 + rec->host_scribble = (u64)sc->host_scribble; 695 653 696 654 memcpy(rec->scsi_opcode, sc->cmnd, 697 655 min_t(int, sc->cmd_len, ZFCP_DBF_SCSI_OPCODE));
+3 -3
drivers/s390/scsi/zfcp_def.h
··· 129 129 struct scsi_device *sdev; 130 130 u32 status; /* recovery status */ 131 131 enum zfcp_erp_steps step; /* active step of this erp action */ 132 - unsigned long fsf_req_id; 132 + u64 fsf_req_id; 133 133 struct timer_list timer; 134 134 }; 135 135 ··· 163 163 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ 164 164 struct list_head port_list; /* remote port list */ 165 165 rwlock_t port_list_lock; /* port list lock */ 166 - unsigned long req_no; /* unique FSF req number */ 166 + u64 req_no; /* unique FSF req number */ 167 167 struct zfcp_reqlist *req_list; 168 168 u32 fsf_req_seq_no; /* FSF cmnd seq number */ 169 169 rwlock_t abort_lock; /* Protects against SCSI ··· 325 325 */ 326 326 struct zfcp_fsf_req { 327 327 struct list_head list; 328 - unsigned long req_id; 328 + u64 req_id; 329 329 struct zfcp_adapter *adapter; 330 330 struct zfcp_qdio_req qdio_req; 331 331 struct completion completion;
+4 -1
drivers/s390/scsi/zfcp_ext.h
··· 4 4 * 5 5 * External function declarations. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #ifndef ZFCP_EXT_H ··· 46 46 extern void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, 47 47 u64 wwpn, u32 fc_security_old, 48 48 u32 fc_security_new); 49 + extern void zfcp_dbf_hba_fsf_reqid(const char *const tag, const int level, 50 + struct zfcp_adapter *const adapter, 51 + const u64 req_id); 49 52 extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *); 50 53 extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **); 51 54 extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32);
+13 -9
drivers/s390/scsi/zfcp_fsf.c
··· 4 4 * 5 5 * Implementation of FSF commands. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #define KMSG_COMPONENT "zfcp" ··· 884 884 const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req); 885 885 struct zfcp_adapter *adapter = req->adapter; 886 886 struct zfcp_qdio *qdio = adapter->qdio; 887 - unsigned long req_id = req->req_id; 887 + u64 req_id = req->req_id; 888 888 889 889 zfcp_reqlist_add(adapter->req_list, req); 890 890 ··· 892 892 req->issued = get_tod_clock(); 893 893 if (zfcp_qdio_send(qdio, &req->qdio_req)) { 894 894 del_timer_sync(&req->timer); 895 + 895 896 /* lookup request again, list might have changed */ 896 - zfcp_reqlist_find_rm(adapter->req_list, req_id); 897 + if (zfcp_reqlist_find_rm(adapter->req_list, req_id) == NULL) 898 + zfcp_dbf_hba_fsf_reqid("fsrsrmf", 1, adapter, req_id); 899 + 897 900 zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1"); 898 901 return -EIO; 899 902 } ··· 1045 1042 struct scsi_device *sdev = scmnd->device; 1046 1043 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); 1047 1044 struct zfcp_qdio *qdio = zfcp_sdev->port->adapter->qdio; 1048 - unsigned long old_req_id = (unsigned long) scmnd->host_scribble; 1045 + u64 old_req_id = (u64) scmnd->host_scribble; 1049 1046 1050 1047 spin_lock_irq(&qdio->req_q_lock); 1051 1048 if (zfcp_qdio_sbal_get(qdio)) ··· 1068 1065 req->handler = zfcp_fsf_abort_fcp_command_handler; 1069 1066 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; 1070 1067 req->qtcb->header.port_handle = zfcp_sdev->port->handle; 1071 - req->qtcb->bottom.support.req_handle = (u64) old_req_id; 1068 + req->qtcb->bottom.support.req_handle = old_req_id; 1072 1069 1073 1070 zfcp_fsf_start_timer(req, ZFCP_FSF_SCSI_ER_TIMEOUT); 1074 1071 if (!zfcp_fsf_req_send(req)) { ··· 1922 1919 { 1923 1920 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1924 1921 struct zfcp_fsf_req *req; 1925 - unsigned long req_id = 0; 1922 + u64 req_id = 0; 1926 1923 int retval = -EIO; 1927 1924 1928 1925 spin_lock_irq(&qdio->req_q_lock); ··· 1981 1978 { 1982 1979 struct zfcp_qdio *qdio = wka_port->adapter->qdio; 1983 1980 struct zfcp_fsf_req *req; 1984 - unsigned long req_id = 0; 1981 + u64 req_id = 0; 1985 1982 int retval = -EIO; 1986 1983 1987 1984 spin_lock_irq(&qdio->req_q_lock); ··· 2590 2587 goto out; 2591 2588 } 2592 2589 2590 + BUILD_BUG_ON(sizeof(scsi_cmnd->host_scribble) < sizeof(req->req_id)); 2593 2591 scsi_cmnd->host_scribble = (unsigned char *) req->req_id; 2594 2592 2595 2593 io = &req->qtcb->bottom.io; ··· 2736 2732 struct qdio_buffer *sbal = qdio->res_q[sbal_idx]; 2737 2733 struct qdio_buffer_element *sbale; 2738 2734 struct zfcp_fsf_req *fsf_req; 2739 - unsigned long req_id; 2735 + u64 req_id; 2740 2736 int idx; 2741 2737 2742 2738 for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) { ··· 2751 2747 * corruption and must stop the machine immediately. 2752 2748 */ 2753 2749 zfcp_qdio_siosl(adapter); 2754 - panic("error: unknown req_id (%lx) on adapter %s.\n", 2750 + panic("error: unknown req_id (%llx) on adapter %s.\n", 2755 2751 req_id, dev_name(&adapter->ccw_device->dev)); 2756 2752 } 2757 2753
+1 -1
drivers/s390/scsi/zfcp_qdio.h
··· 115 115 */ 116 116 static inline 117 117 void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, 118 - unsigned long req_id, u8 sbtype, void *data, u32 len) 118 + u64 req_id, u8 sbtype, void *data, u32 len) 119 119 { 120 120 struct qdio_buffer_element *sbale; 121 121 int count = min(atomic_read(&qdio->req_q_free),
+14 -12
drivers/s390/scsi/zfcp_reqlist.h
··· 5 5 * Data structure and helper functions for tracking pending FSF 6 6 * requests. 7 7 * 8 - * Copyright IBM Corp. 2009, 2016 8 + * Copyright IBM Corp. 2009, 2023 9 9 */ 10 10 11 11 #ifndef ZFCP_REQLIST_H 12 12 #define ZFCP_REQLIST_H 13 13 14 + #include <linux/types.h> 15 + 14 16 /* number of hash buckets */ 15 - #define ZFCP_REQ_LIST_BUCKETS 128 17 + #define ZFCP_REQ_LIST_BUCKETS 128u 16 18 17 19 /** 18 20 * struct zfcp_reqlist - Container for request list (reqlist) ··· 26 24 struct list_head buckets[ZFCP_REQ_LIST_BUCKETS]; 27 25 }; 28 26 29 - static inline int zfcp_reqlist_hash(unsigned long req_id) 27 + static inline size_t zfcp_reqlist_hash(u64 req_id) 30 28 { 31 29 return req_id % ZFCP_REQ_LIST_BUCKETS; 32 30 } ··· 39 37 */ 40 38 static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void) 41 39 { 42 - unsigned int i; 40 + size_t i; 43 41 struct zfcp_reqlist *rl; 44 42 45 43 rl = kzalloc(sizeof(struct zfcp_reqlist), GFP_KERNEL); ··· 62 60 */ 63 61 static inline int zfcp_reqlist_isempty(struct zfcp_reqlist *rl) 64 62 { 65 - unsigned int i; 63 + size_t i; 66 64 67 65 for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++) 68 66 if (!list_empty(&rl->buckets[i])) ··· 83 81 } 84 82 85 83 static inline struct zfcp_fsf_req * 86 - _zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id) 84 + _zfcp_reqlist_find(struct zfcp_reqlist *rl, u64 req_id) 87 85 { 88 86 struct zfcp_fsf_req *req; 89 - unsigned int i; 87 + size_t i; 90 88 91 89 i = zfcp_reqlist_hash(req_id); 92 90 list_for_each_entry(req, &rl->buckets[i], list) ··· 104 102 * or NULL if there is no known FSF request with this id. 105 103 */ 106 104 static inline struct zfcp_fsf_req * 107 - zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id) 105 + zfcp_reqlist_find(struct zfcp_reqlist *rl, u64 req_id) 108 106 { 109 107 unsigned long flags; 110 108 struct zfcp_fsf_req *req; ··· 129 127 * NULL if it has not been found. 130 128 */ 131 129 static inline struct zfcp_fsf_req * 132 - zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, unsigned long req_id) 130 + zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, u64 req_id) 133 131 { 134 132 unsigned long flags; 135 133 struct zfcp_fsf_req *req; ··· 156 154 static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl, 157 155 struct zfcp_fsf_req *req) 158 156 { 159 - unsigned int i; 157 + size_t i; 160 158 unsigned long flags; 161 159 162 160 i = zfcp_reqlist_hash(req->req_id); ··· 174 172 static inline void zfcp_reqlist_move(struct zfcp_reqlist *rl, 175 173 struct list_head *list) 176 174 { 177 - unsigned int i; 175 + size_t i; 178 176 unsigned long flags; 179 177 180 178 spin_lock_irqsave(&rl->lock, flags); ··· 202 200 { 203 201 struct zfcp_fsf_req *req; 204 202 unsigned long flags; 205 - unsigned int i; 203 + size_t i; 206 204 207 205 spin_lock_irqsave(&rl->lock, flags); 208 206 for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++)
+1 -1
drivers/s390/scsi/zfcp_scsi.c
··· 170 170 (struct zfcp_adapter *) scsi_host->hostdata[0]; 171 171 struct zfcp_fsf_req *old_req, *abrt_req; 172 172 unsigned long flags; 173 - unsigned long old_reqid = (unsigned long) scpnt->host_scribble; 173 + u64 old_reqid = (u64) scpnt->host_scribble; 174 174 int retval = SUCCESS, ret; 175 175 int retry = 3; 176 176 char *dbf_tag;
-1
drivers/scsi/cxgbi/libcxgbi.h
··· 24 24 #include <linux/scatterlist.h> 25 25 #include <linux/skbuff.h> 26 26 #include <linux/vmalloc.h> 27 - #include <linux/version.h> 28 27 #include <scsi/scsi_device.h> 29 28 #include <scsi/libiscsi_tcp.h> 30 29
+3 -1
drivers/scsi/hosts.c
··· 181 181 scsi_forget_host(shost); 182 182 mutex_unlock(&shost->scan_mutex); 183 183 scsi_proc_host_rm(shost); 184 + scsi_proc_hostdir_rm(shost->hostt); 184 185 185 186 /* 186 187 * New SCSI devices cannot be attached anymore because of the SCSI host ··· 341 340 struct Scsi_Host *shost = dev_to_shost(dev); 342 341 struct device *parent = dev->parent; 343 342 343 + /* In case scsi_remove_host() has not been called. */ 344 344 scsi_proc_hostdir_rm(shost->hostt); 345 345 346 346 /* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */ ··· 358 356 /* 359 357 * Free the shost_dev device name here if scsi_host_alloc() 360 358 * and scsi_host_put() have been called but neither 361 - * scsi_host_add() nor scsi_host_remove() has been called. 359 + * scsi_host_add() nor scsi_remove_host() has been called. 362 360 * This avoids that the memory allocated for the shost_dev 363 361 * name is leaked. 364 362 */
+24 -30
drivers/scsi/ipr.c
··· 1516 1516 } 1517 1517 1518 1518 /** 1519 - * strip_and_pad_whitespace - Strip and pad trailing whitespace. 1520 - * @i: index into buffer 1521 - * @buf: string to modify 1519 + * strip_whitespace - Strip and pad trailing whitespace. 1520 + * @i: size of buffer 1521 + * @buf: string to modify 1522 1522 * 1523 - * This function will strip all trailing whitespace, pad the end 1524 - * of the string with a single space, and NULL terminate the string. 1523 + * This function will strip all trailing whitespace and 1524 + * NUL terminate the string. 1525 1525 * 1526 - * Return value: 1527 - * new length of string 1528 1526 **/ 1529 - static int strip_and_pad_whitespace(int i, char *buf) 1527 + static void strip_whitespace(int i, char *buf) 1530 1528 { 1529 + if (i < 1) 1530 + return; 1531 + i--; 1531 1532 while (i && buf[i] == ' ') 1532 1533 i--; 1533 - buf[i+1] = ' '; 1534 - buf[i+2] = '\0'; 1535 - return i + 2; 1534 + buf[i+1] = '\0'; 1536 1535 } 1537 1536 1538 1537 /** ··· 1546 1547 static void ipr_log_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb, 1547 1548 struct ipr_vpd *vpd) 1548 1549 { 1549 - char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN + IPR_SERIAL_NUM_LEN + 3]; 1550 - int i = 0; 1550 + char vendor_id[IPR_VENDOR_ID_LEN + 1]; 1551 + char product_id[IPR_PROD_ID_LEN + 1]; 1552 + char sn[IPR_SERIAL_NUM_LEN + 1]; 1551 1553 1552 - memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN); 1553 - i = strip_and_pad_whitespace(IPR_VENDOR_ID_LEN - 1, buffer); 1554 + memcpy(vendor_id, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN); 1555 + strip_whitespace(IPR_VENDOR_ID_LEN, vendor_id); 1554 1556 1555 - memcpy(&buffer[i], vpd->vpids.product_id, IPR_PROD_ID_LEN); 1556 - i = strip_and_pad_whitespace(i + IPR_PROD_ID_LEN - 1, buffer); 1557 + memcpy(product_id, vpd->vpids.product_id, IPR_PROD_ID_LEN); 1558 + strip_whitespace(IPR_PROD_ID_LEN, product_id); 1557 1559 1558 - memcpy(&buffer[i], vpd->sn, IPR_SERIAL_NUM_LEN); 1559 - buffer[IPR_SERIAL_NUM_LEN + i] = '\0'; 1560 + memcpy(sn, vpd->sn, IPR_SERIAL_NUM_LEN); 1561 + strip_whitespace(IPR_SERIAL_NUM_LEN, sn); 1560 1562 1561 - ipr_hcam_err(hostrcb, "%s VPID/SN: %s\n", prefix, buffer); 1563 + ipr_hcam_err(hostrcb, "%s VPID/SN: %s %s %s\n", prefix, 1564 + vendor_id, product_id, sn); 1562 1565 } 1563 1566 1564 1567 /** ··· 9496 9495 * This function takes care of initilizing the adapter to the point 9497 9496 * where it can accept new commands. 9498 9497 * Return value: 9499 - * 0 on success / -EIO on failure 9498 + * none 9500 9499 **/ 9501 - static int ipr_probe_ioa_part2(struct ipr_ioa_cfg *ioa_cfg) 9500 + static void ipr_probe_ioa_part2(struct ipr_ioa_cfg *ioa_cfg) 9502 9501 { 9503 - int rc = 0; 9504 9502 unsigned long host_lock_flags = 0; 9505 9503 9506 9504 ENTER; ··· 9515 9515 spin_unlock_irqrestore(ioa_cfg->host->host_lock, host_lock_flags); 9516 9516 9517 9517 LEAVE; 9518 - return rc; 9519 9518 } 9520 9519 9521 9520 /** ··· 10557 10558 return rc; 10558 10559 10559 10560 ioa_cfg = pci_get_drvdata(pdev); 10560 - rc = ipr_probe_ioa_part2(ioa_cfg); 10561 - 10562 - if (rc) { 10563 - __ipr_remove(pdev); 10564 - return rc; 10565 - } 10561 + ipr_probe_ioa_part2(ioa_cfg); 10566 10562 10567 10563 rc = scsi_add_host(ioa_cfg->host, &pdev->dev); 10568 10564
+5 -5
drivers/scsi/lpfc/lpfc_attr.c
··· 2541 2541 2542 2542 /** 2543 2543 * lpfc_enable_bbcr_set: Sets an attribute value. 2544 - * @phba: pointer the the adapter structure. 2544 + * @phba: pointer to the adapter structure. 2545 2545 * @val: integer attribute value. 2546 2546 * 2547 2547 * Description: ··· 2632 2632 * takes a default argument, a minimum and maximum argument. 2633 2633 * 2634 2634 * lpfc_##attr##_init: Initializes an attribute. 2635 - * @phba: pointer the the adapter structure. 2635 + * @phba: pointer to the adapter structure. 2636 2636 * @val: integer attribute value. 2637 2637 * 2638 2638 * Validates the min and max values then sets the adapter config field ··· 2665 2665 * into a function with the name lpfc_hba_queue_depth_set 2666 2666 * 2667 2667 * lpfc_##attr##_set: Sets an attribute value. 2668 - * @phba: pointer the the adapter structure. 2668 + * @phba: pointer to the adapter structure. 2669 2669 * @val: integer attribute value. 2670 2670 * 2671 2671 * Description: ··· 2794 2794 * lpfc_##attr##_init: validates the min and max values then sets the 2795 2795 * adapter config field accordingly, or uses the default if out of range 2796 2796 * and prints an error message. 2797 - * @phba: pointer the the adapter structure. 2797 + * @phba: pointer to the adapter structure. 2798 2798 * @val: integer attribute value. 2799 2799 * 2800 2800 * Returns: ··· 2826 2826 * lpfc_##attr##_set: validates the min and max values then sets the 2827 2827 * adapter config field if in the valid range. prints error message 2828 2828 * and does not set the parameter if invalid. 2829 - * @phba: pointer the the adapter structure. 2829 + * @phba: pointer to the adapter structure. 2830 2830 * @val: integer attribute value. 2831 2831 * 2832 2832 * Returns:
+2 -2
drivers/scsi/lpfc/lpfc_els.c
··· 8886 8886 * @rrq: Pointer to the rrq struct. 8887 8887 * 8888 8888 * Build a ELS RRQ command and send it to the target. If the issue_iocb is 8889 - * Successful the the completion handler will clear the RRQ. 8889 + * successful, the completion handler will clear the RRQ. 8890 8890 * 8891 8891 * Return codes 8892 8892 * 0 - Successfully sent rrq els iocb. ··· 10287 10287 /* Send every descriptor individually to the upper layer */ 10288 10288 if (deliver) 10289 10289 fc_host_fpin_rcv(lpfc_shost_from_vport(vport), 10290 - fpin_length, (char *)fpin); 10290 + fpin_length, (char *)fpin, 0); 10291 10291 desc_cnt++; 10292 10292 } 10293 10293 }
+1 -1
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 2459 2459 * @phba: pointer to lpfc hba data structure. 2460 2460 * @fcf_index: the index of the fcf record to update 2461 2461 * This routine acquires the hbalock and then set the LPFC_FCF_FLOGI_FAILED 2462 - * flag so the the round robin slection for the particular priority level 2462 + * flag so the round robin selection for the particular priority level 2463 2463 * will try a different fcf record that does not have this bit set. 2464 2464 * If the fcf record is re-read for any reason this flag is cleared brfore 2465 2465 * adding it to the priority list.
+2 -2
drivers/scsi/lpfc/lpfc_init.c
··· 5502 5502 bf_set(lpfc_mbx_read_top_link_spd, la, 5503 5503 (bf_get(lpfc_acqe_link_speed, acqe_link))); 5504 5504 5505 - /* Fake the the following irrelvant fields */ 5505 + /* Fake the following irrelevant fields */ 5506 5506 bf_set(lpfc_mbx_read_top_topology, la, LPFC_TOPOLOGY_PT_PT); 5507 5507 bf_set(lpfc_mbx_read_top_alpa_granted, la, 0); 5508 5508 bf_set(lpfc_mbx_read_top_il, la, 0); ··· 12549 12549 /* Mark CPU as IRQ not assigned by the kernel */ 12550 12550 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; 12551 12551 12552 - /* If so, find a new_cpup thats on the the SAME 12552 + /* If so, find a new_cpup that is on the SAME 12553 12553 * phys_id as cpup. start_cpu will start where we 12554 12554 * left off so all unassigned entries don't get assgined 12555 12555 * the IRQ of the first entry.
+2 -2
drivers/scsi/lpfc/lpfc_mbox.c
··· 2509 2509 * information via a READ_FCF mailbox command. This mailbox command also is used 2510 2510 * to indicate where received unsolicited frames from this FCF will be sent. By 2511 2511 * default this routine will set up the FCF to forward all unsolicited frames 2512 - * the the RQ ID passed in the @phba. This can be overridden by the caller for 2512 + * to the RQ ID passed in the @phba. This can be overridden by the caller for 2513 2513 * more complicated setups. 2514 2514 **/ 2515 2515 void ··· 2577 2577 * information via a READ_FCF mailbox command. This mailbox command also is used 2578 2578 * to indicate where received unsolicited frames from this FCF will be sent. By 2579 2579 * default this routine will set up the FCF to forward all unsolicited frames 2580 - * the the RQ ID passed in the @phba. This can be overridden by the caller for 2580 + * to the RQ ID passed in the @phba. This can be overridden by the caller for 2581 2581 * more complicated setups. 2582 2582 **/ 2583 2583 void
+1 -1
drivers/scsi/lpfc/lpfc_nvmet.c
··· 1469 1469 if (!infop) 1470 1470 return; 1471 1471 1472 - /* Cycle the the entire CPU context list for every MRQ */ 1472 + /* Cycle the entire CPU context list for every MRQ */ 1473 1473 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { 1474 1474 for_each_present_cpu(j) { 1475 1475 infop = lpfc_get_ctx_list(phba, j, i);
+1 -1
drivers/scsi/lpfc/lpfc_sli.c
··· 20804 20804 * the offset after the write object mailbox has completed. @size is used to 20805 20805 * determine the end of the object and whether the eof bit should be set. 20806 20806 * 20807 - * Return 0 is successful and offset will contain the the new offset to use 20807 + * Return 0 is successful and offset will contain the new offset to use 20808 20808 * for the next write. 20809 20809 * Return negative value for error cases. 20810 20810 **/
+2 -9
drivers/scsi/mpi3mr/mpi3mr.h
··· 29 29 #include <linux/types.h> 30 30 #include <linux/uaccess.h> 31 31 #include <linux/utsname.h> 32 - #include <linux/version.h> 33 32 #include <linux/workqueue.h> 34 33 #include <asm/unaligned.h> 35 34 #include <scsi/scsi.h> ··· 954 955 * @chain_buf_count: Chain buffer count 955 956 * @chain_buf_pool: Chain buffer pool 956 957 * @chain_sgl_list: Chain SGL list 957 - * @chain_bitmap_sz: Chain buffer allocator bitmap size 958 958 * @chain_bitmap: Chain buffer allocator bitmap 959 959 * @chain_buf_lock: Chain buffer list lock 960 960 * @bsg_cmds: Command tracker for BSG command 961 961 * @host_tm_cmds: Command tracker for task management commands 962 962 * @dev_rmhs_cmds: Command tracker for device removal commands 963 963 * @evtack_cmds: Command tracker for event ack commands 964 - * @devrem_bitmap_sz: Device removal bitmap size 965 964 * @devrem_bitmap: Device removal bitmap 966 - * @dev_handle_bitmap_sz: Device handle bitmap size 965 + * @dev_handle_bitmap_bits: Number of bits in device handle bitmap 967 966 * @removepend_bitmap: Remove pending bitmap 968 967 * @delayed_rmhs_list: Delayed device removal list 969 - * @evtack_cmds_bitmap_sz: Event Ack bitmap size 970 968 * @evtack_cmds_bitmap: Event Ack bitmap 971 969 * @delayed_evtack_cmds_list: Delayed event acknowledgment list 972 970 * @ts_update_counter: Timestamp update counter ··· 1124 1128 u32 chain_buf_count; 1125 1129 struct dma_pool *chain_buf_pool; 1126 1130 struct chain_element *chain_sgl_list; 1127 - u16 chain_bitmap_sz; 1128 1131 void *chain_bitmap; 1129 1132 spinlock_t chain_buf_lock; 1130 1133 ··· 1131 1136 struct mpi3mr_drv_cmd host_tm_cmds; 1132 1137 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD]; 1133 1138 struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD]; 1134 - u16 devrem_bitmap_sz; 1135 1139 void *devrem_bitmap; 1136 - u16 dev_handle_bitmap_sz; 1140 + u16 dev_handle_bitmap_bits; 1137 1141 void *removepend_bitmap; 1138 1142 struct list_head delayed_rmhs_list; 1139 - u16 evtack_cmds_bitmap_sz; 1140 1143 void *evtack_cmds_bitmap; 1141 1144 struct list_head delayed_evtack_cmds_list; 1142 1145
+10 -18
drivers/scsi/mpi3mr/mpi3mr_app.c
··· 293 293 static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc, 294 294 struct bsg_job *job) 295 295 { 296 - long rval = -EINVAL; 297 296 u16 num_devices = 0, i = 0, size; 298 297 unsigned long flags; 299 298 struct mpi3mr_tgt_dev *tgtdev; ··· 303 304 if (job->request_payload.payload_len < sizeof(u32)) { 304 305 dprint_bsg_err(mrioc, "%s: invalid size argument\n", 305 306 __func__); 306 - return rval; 307 + return -EINVAL; 307 308 } 308 309 309 310 spin_lock_irqsave(&mrioc->tgtdev_lock, flags); ··· 311 312 num_devices++; 312 313 spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); 313 314 314 - if ((job->request_payload.payload_len == sizeof(u32)) || 315 + if ((job->request_payload.payload_len <= sizeof(u64)) || 315 316 list_empty(&mrioc->tgtdev_list)) { 316 317 sg_copy_from_buffer(job->request_payload.sg_list, 317 318 job->request_payload.sg_cnt, ··· 319 320 return 0; 320 321 } 321 322 322 - kern_entrylen = (num_devices - 1) * sizeof(*devmap_info); 323 - size = sizeof(*alltgt_info) + kern_entrylen; 323 + kern_entrylen = num_devices * sizeof(*devmap_info); 324 + size = sizeof(u64) + kern_entrylen; 324 325 alltgt_info = kzalloc(size, GFP_KERNEL); 325 326 if (!alltgt_info) 326 327 return -ENOMEM; 327 328 328 329 devmap_info = alltgt_info->dmi; 329 - memset((u8 *)devmap_info, 0xFF, (kern_entrylen + sizeof(*devmap_info))); 330 + memset((u8 *)devmap_info, 0xFF, kern_entrylen); 330 331 spin_lock_irqsave(&mrioc->tgtdev_lock, flags); 331 332 list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) { 332 333 if (i < num_devices) { ··· 343 344 num_devices = i; 344 345 spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); 345 346 346 - memcpy(&alltgt_info->num_devices, &num_devices, sizeof(num_devices)); 347 + alltgt_info->num_devices = num_devices; 347 348 348 - usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info); 349 + usr_entrylen = (job->request_payload.payload_len - sizeof(u64)) / 350 + sizeof(*devmap_info); 349 351 usr_entrylen *= sizeof(*devmap_info); 350 352 min_entrylen = min(usr_entrylen, kern_entrylen); 351 - if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) { 352 - dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n", 353 - __func__, __LINE__); 354 - rval = -EFAULT; 355 - goto out; 356 - } 357 353 358 354 sg_copy_from_buffer(job->request_payload.sg_list, 359 355 job->request_payload.sg_cnt, 360 - alltgt_info, job->request_payload.payload_len); 361 - rval = 0; 362 - out: 356 + alltgt_info, (min_entrylen + sizeof(u64))); 363 357 kfree(alltgt_info); 364 - return rval; 358 + return 0; 365 359 } 366 360 /** 367 361 * mpi3mr_get_change_count - Get topology change count
+31 -44
drivers/scsi/mpi3mr/mpi3mr_fw.c
··· 1128 1128 static int 1129 1129 mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc) 1130 1130 { 1131 - u16 dev_handle_bitmap_sz; 1132 1131 void *removepend_bitmap; 1133 1132 1134 1133 if (mrioc->facts.reply_sz > mrioc->reply_sz) { ··· 1159 1160 "\tcontroller while sas transport support is enabled at the\n" 1160 1161 "\tdriver, please reboot the system or reload the driver\n"); 1161 1162 1162 - dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8; 1163 - if (mrioc->facts.max_devhandle % 8) 1164 - dev_handle_bitmap_sz++; 1165 - if (dev_handle_bitmap_sz > mrioc->dev_handle_bitmap_sz) { 1166 - removepend_bitmap = krealloc(mrioc->removepend_bitmap, 1167 - dev_handle_bitmap_sz, GFP_KERNEL); 1163 + if (mrioc->facts.max_devhandle > mrioc->dev_handle_bitmap_bits) { 1164 + removepend_bitmap = bitmap_zalloc(mrioc->facts.max_devhandle, 1165 + GFP_KERNEL); 1168 1166 if (!removepend_bitmap) { 1169 1167 ioc_err(mrioc, 1170 - "failed to increase removepend_bitmap sz from: %d to %d\n", 1171 - mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz); 1168 + "failed to increase removepend_bitmap bits from %d to %d\n", 1169 + mrioc->dev_handle_bitmap_bits, 1170 + mrioc->facts.max_devhandle); 1172 1171 return -EPERM; 1173 1172 } 1174 - memset(removepend_bitmap + mrioc->dev_handle_bitmap_sz, 0, 1175 - dev_handle_bitmap_sz - mrioc->dev_handle_bitmap_sz); 1173 + bitmap_free(mrioc->removepend_bitmap); 1176 1174 mrioc->removepend_bitmap = removepend_bitmap; 1177 1175 ioc_info(mrioc, 1178 - "increased dev_handle_bitmap_sz from %d to %d\n", 1179 - mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz); 1180 - mrioc->dev_handle_bitmap_sz = dev_handle_bitmap_sz; 1176 + "increased bits of dev_handle_bitmap from %d to %d\n", 1177 + mrioc->dev_handle_bitmap_bits, 1178 + mrioc->facts.max_devhandle); 1179 + mrioc->dev_handle_bitmap_bits = mrioc->facts.max_devhandle; 1181 1180 } 1182 1181 1183 1182 return 0; ··· 2954 2957 if (!mrioc->pel_abort_cmd.reply) 2955 2958 goto out_failed; 2956 2959 2957 - mrioc->dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8; 2958 - if (mrioc->facts.max_devhandle % 8) 2959 - mrioc->dev_handle_bitmap_sz++; 2960 - mrioc->removepend_bitmap = kzalloc(mrioc->dev_handle_bitmap_sz, 2961 - GFP_KERNEL); 2960 + mrioc->dev_handle_bitmap_bits = mrioc->facts.max_devhandle; 2961 + mrioc->removepend_bitmap = bitmap_zalloc(mrioc->dev_handle_bitmap_bits, 2962 + GFP_KERNEL); 2962 2963 if (!mrioc->removepend_bitmap) 2963 2964 goto out_failed; 2964 2965 2965 - mrioc->devrem_bitmap_sz = MPI3MR_NUM_DEVRMCMD / 8; 2966 - if (MPI3MR_NUM_DEVRMCMD % 8) 2967 - mrioc->devrem_bitmap_sz++; 2968 - mrioc->devrem_bitmap = kzalloc(mrioc->devrem_bitmap_sz, 2969 - GFP_KERNEL); 2966 + mrioc->devrem_bitmap = bitmap_zalloc(MPI3MR_NUM_DEVRMCMD, GFP_KERNEL); 2970 2967 if (!mrioc->devrem_bitmap) 2971 2968 goto out_failed; 2972 2969 2973 - mrioc->evtack_cmds_bitmap_sz = MPI3MR_NUM_EVTACKCMD / 8; 2974 - if (MPI3MR_NUM_EVTACKCMD % 8) 2975 - mrioc->evtack_cmds_bitmap_sz++; 2976 - mrioc->evtack_cmds_bitmap = kzalloc(mrioc->evtack_cmds_bitmap_sz, 2977 - GFP_KERNEL); 2970 + mrioc->evtack_cmds_bitmap = bitmap_zalloc(MPI3MR_NUM_EVTACKCMD, 2971 + GFP_KERNEL); 2978 2972 if (!mrioc->evtack_cmds_bitmap) 2979 2973 goto out_failed; 2980 2974 ··· 3403 3415 if (!mrioc->chain_sgl_list[i].addr) 3404 3416 goto out_failed; 3405 3417 } 3406 - mrioc->chain_bitmap_sz = num_chains / 8; 3407 - if (num_chains % 8) 3408 - mrioc->chain_bitmap_sz++; 3409 - mrioc->chain_bitmap = kzalloc(mrioc->chain_bitmap_sz, GFP_KERNEL); 3418 + mrioc->chain_bitmap = bitmap_zalloc(num_chains, GFP_KERNEL); 3410 3419 if (!mrioc->chain_bitmap) 3411 3420 goto out_failed; 3412 3421 return retval; ··· 4174 4189 for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) 4175 4190 memset(mrioc->evtack_cmds[i].reply, 0, 4176 4191 sizeof(*mrioc->evtack_cmds[i].reply)); 4177 - memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); 4178 - memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); 4179 - memset(mrioc->evtack_cmds_bitmap, 0, 4180 - mrioc->evtack_cmds_bitmap_sz); 4192 + bitmap_clear(mrioc->removepend_bitmap, 0, 4193 + mrioc->dev_handle_bitmap_bits); 4194 + bitmap_clear(mrioc->devrem_bitmap, 0, MPI3MR_NUM_DEVRMCMD); 4195 + bitmap_clear(mrioc->evtack_cmds_bitmap, 0, 4196 + MPI3MR_NUM_EVTACKCMD); 4181 4197 } 4182 4198 4183 4199 for (i = 0; i < mrioc->num_queues; i++) { ··· 4304 4318 mrioc->evtack_cmds[i].reply = NULL; 4305 4319 } 4306 4320 4307 - kfree(mrioc->removepend_bitmap); 4321 + bitmap_free(mrioc->removepend_bitmap); 4308 4322 mrioc->removepend_bitmap = NULL; 4309 4323 4310 - kfree(mrioc->devrem_bitmap); 4324 + bitmap_free(mrioc->devrem_bitmap); 4311 4325 mrioc->devrem_bitmap = NULL; 4312 4326 4313 - kfree(mrioc->evtack_cmds_bitmap); 4327 + bitmap_free(mrioc->evtack_cmds_bitmap); 4314 4328 mrioc->evtack_cmds_bitmap = NULL; 4315 4329 4316 - kfree(mrioc->chain_bitmap); 4330 + bitmap_free(mrioc->chain_bitmap); 4317 4331 mrioc->chain_bitmap = NULL; 4318 4332 4319 4333 kfree(mrioc->transport_cmds.reply); ··· 4872 4886 4873 4887 mpi3mr_flush_delayed_cmd_lists(mrioc); 4874 4888 mpi3mr_flush_drv_cmds(mrioc); 4875 - memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); 4876 - memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); 4877 - memset(mrioc->evtack_cmds_bitmap, 0, mrioc->evtack_cmds_bitmap_sz); 4889 + bitmap_clear(mrioc->devrem_bitmap, 0, MPI3MR_NUM_DEVRMCMD); 4890 + bitmap_clear(mrioc->removepend_bitmap, 0, 4891 + mrioc->dev_handle_bitmap_bits); 4892 + bitmap_clear(mrioc->evtack_cmds_bitmap, 0, MPI3MR_NUM_EVTACKCMD); 4878 4893 mpi3mr_flush_host_io(mrioc); 4879 4894 mpi3mr_cleanup_fwevt_list(mrioc); 4880 4895 mpi3mr_invalidate_devhandles(mrioc);
+4
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 4952 4952 mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i], 4953 4953 MPI3MR_HOSTTAG_DEVRMCMD_MIN + i); 4954 4954 4955 + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) 4956 + mpi3mr_init_drv_cmd(&mrioc->evtack_cmds[i], 4957 + MPI3MR_HOSTTAG_EVTACKCMD_MIN + i); 4958 + 4955 4959 if (pdev->revision) 4956 4960 mrioc->enable_segqueue = true; 4957 4961
+1 -1
drivers/scsi/mpi3mr/mpi3mr_transport.c
··· 1280 1280 1281 1281 if (mrioc->sas_hba.enclosure_handle) { 1282 1282 if (!(mpi3mr_cfg_get_enclosure_pg0(mrioc, &ioc_status, 1283 - &encl_pg0, sizeof(dev_pg0), 1283 + &encl_pg0, sizeof(encl_pg0), 1284 1284 MPI3_ENCLOS_PGAD_FORM_HANDLE, 1285 1285 mrioc->sas_hba.enclosure_handle)) && 1286 1286 (ioc_status == MPI3_IOCSTATUS_SUCCESS))
-1
drivers/scsi/qedi/qedi_dbg.h
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/compiler.h> 13 13 #include <linux/string.h> 14 - #include <linux/version.h> 15 14 #include <linux/pci.h> 16 15 #include <linux/delay.h> 17 16 #include <scsi/scsi_transport.h>
+1 -1
drivers/scsi/qla2xxx/qla_isr.c
··· 45 45 ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, 0x508f, 46 46 pkt, pkt_size); 47 47 48 - fc_host_fpin_rcv(vha->host, pkt_size, (char *)pkt); 48 + fc_host_fpin_rcv(vha->host, pkt_size, (char *)pkt, 0); 49 49 } 50 50 51 51 const char *const port_state_str[] = {
+1
drivers/scsi/scsi_lib.c
··· 229 229 scmd->cmd_len = COMMAND_SIZE(cmd[0]); 230 230 memcpy(scmd->cmnd, cmd, scmd->cmd_len); 231 231 scmd->allowed = retries; 232 + scmd->flags |= args->scmd_flags; 232 233 req->timeout = timeout; 233 234 req->rq_flags |= RQF_QUIET; 234 235
+7 -3
drivers/scsi/scsi_transport_fc.c
··· 137 137 { FCH_EVT_PORT_FABRIC, "port_fabric" }, 138 138 { FCH_EVT_LINK_UNKNOWN, "link_unknown" }, 139 139 { FCH_EVT_LINK_FPIN, "link_FPIN" }, 140 + { FCH_EVT_LINK_FPIN_ACK, "link_FPIN_ACK" }, 140 141 { FCH_EVT_VENDOR_UNIQUE, "vendor_unique" }, 141 142 }; 142 143 fc_enum_name_search(host_event_code, fc_host_event_code, ··· 895 894 * @shost: host the FPIN was received on 896 895 * @fpin_len: length of FPIN payload, in bytes 897 896 * @fpin_buf: pointer to FPIN payload 898 - * 897 + * @event_acknowledge: 1, if LLDD handles this event. 899 898 * Notes: 900 899 * This routine assumes no locks are held on entry. 901 900 */ 902 901 void 903 - fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf) 902 + fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf, 903 + u8 event_acknowledge) 904 904 { 905 905 struct fc_els_fpin *fpin = (struct fc_els_fpin *)fpin_buf; 906 906 struct fc_tlv_desc *tlv; 907 907 u32 desc_cnt = 0, bytes_remain; 908 908 u32 dtag; 909 + enum fc_host_event_code event_code = 910 + event_acknowledge ? FCH_EVT_LINK_FPIN_ACK : FCH_EVT_LINK_FPIN; 909 911 910 912 /* Update Statistics */ 911 913 tlv = (struct fc_tlv_desc *)&fpin->fpin_desc[0]; ··· 938 934 } 939 935 940 936 fc_host_post_fc_event(shost, fc_get_event_number(), 941 - FCH_EVT_LINK_FPIN, fpin_len, fpin_buf, 0); 937 + event_code, fpin_len, fpin_buf, 0); 942 938 } 943 939 EXPORT_SYMBOL(fc_host_fpin_rcv); 944 940
+6 -23
drivers/scsi/sd.c
··· 121 121 122 122 static DEFINE_IDA(sd_index_ida); 123 123 124 - static struct kmem_cache *sd_cdb_cache; 125 124 static mempool_t *sd_page_pool; 126 125 static struct lock_class_key sd_bio_compl_lkclass; 127 126 ··· 2251 2252 { 2252 2253 struct scsi_device *sdp = sdkp->device; 2253 2254 2254 - if (!sdkp->first_scan) 2255 - return; 2256 - 2257 2255 sd_dif_config_host(sdkp); 2258 2256 2259 2257 if (!sdkp->protection_type) 2260 2258 return; 2261 2259 2262 2260 if (!scsi_host_dif_capable(sdp->host, sdkp->protection_type)) { 2263 - sd_printk(KERN_NOTICE, sdkp, 2264 - "Disabling DIF Type %u protection\n", 2265 - sdkp->protection_type); 2261 + sd_first_printk(KERN_NOTICE, sdkp, 2262 + "Disabling DIF Type %u protection\n", 2263 + sdkp->protection_type); 2266 2264 sdkp->protection_type = 0; 2267 2265 } 2268 2266 2269 - sd_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n", 2270 - sdkp->protection_type); 2267 + sd_first_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n", 2268 + sdkp->protection_type); 2271 2269 } 2272 2270 2273 2271 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, ··· 3847 3851 if (err) 3848 3852 goto err_out; 3849 3853 3850 - sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE, 3851 - 0, 0, NULL); 3852 - if (!sd_cdb_cache) { 3853 - printk(KERN_ERR "sd: can't init extended cdb cache\n"); 3854 - err = -ENOMEM; 3855 - goto err_out_class; 3856 - } 3857 - 3858 3854 sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, 0); 3859 3855 if (!sd_page_pool) { 3860 3856 printk(KERN_ERR "sd: can't init discard page pool\n"); 3861 3857 err = -ENOMEM; 3862 - goto err_out_cache; 3858 + goto err_out_class; 3863 3859 } 3864 3860 3865 3861 err = scsi_register_driver(&sd_template.gendrv); ··· 3862 3874 3863 3875 err_out_driver: 3864 3876 mempool_destroy(sd_page_pool); 3865 - 3866 - err_out_cache: 3867 - kmem_cache_destroy(sd_cdb_cache); 3868 - 3869 3877 err_out_class: 3870 3878 class_unregister(&sd_disk_class); 3871 3879 err_out: ··· 3883 3899 3884 3900 scsi_unregister_driver(&sd_template.gendrv); 3885 3901 mempool_destroy(sd_page_pool); 3886 - kmem_cache_destroy(sd_cdb_cache); 3887 3902 3888 3903 class_unregister(&sd_disk_class); 3889 3904
+6 -4
drivers/scsi/sd_dif.c
··· 39 39 dif = 0; dix = 1; 40 40 } 41 41 42 - if (!dix) 42 + if (!dix) { 43 + blk_integrity_unregister(disk); 43 44 return; 45 + } 44 46 45 47 memset(&bi, 0, sizeof(bi)); 46 48 ··· 74 72 bi.tag_size = sizeof(u16); 75 73 } 76 74 77 - sd_printk(KERN_NOTICE, sdkp, 78 - "Enabling DIX %s, application tag size %u bytes\n", 79 - bi.profile->name, bi.tag_size); 75 + sd_first_printk(KERN_NOTICE, sdkp, 76 + "Enabling DIX %s, application tag size %u bytes\n", 77 + bi.profile->name, bi.tag_size); 80 78 out: 81 79 blk_integrity_register(disk, &bi); 82 80 }
+47 -17
drivers/scsi/ses.c
··· 439 439 } 440 440 #endif /* 0 */ 441 441 442 - static void ses_process_descriptor(struct enclosure_component *ecomp, 443 - unsigned char *desc) 442 + static int ses_process_descriptor(struct enclosure_component *ecomp, 443 + unsigned char *desc, int max_desc_len) 444 444 { 445 445 int eip = desc[0] & 0x10; 446 446 int invalid = desc[0] & 0x80; ··· 451 451 unsigned char *d; 452 452 453 453 if (invalid) 454 - return; 454 + return 0; 455 455 456 456 switch (proto) { 457 457 case SCSI_PROTOCOL_FCP: 458 458 if (eip) { 459 + if (max_desc_len <= 7) 460 + return 1; 459 461 d = desc + 4; 460 462 slot = d[3]; 461 463 } 462 464 break; 463 465 case SCSI_PROTOCOL_SAS: 466 + 464 467 if (eip) { 468 + if (max_desc_len <= 27) 469 + return 1; 465 470 d = desc + 4; 466 471 slot = d[3]; 467 472 d = desc + 8; 468 - } else 473 + } else { 474 + if (max_desc_len <= 23) 475 + return 1; 469 476 d = desc + 4; 477 + } 478 + 479 + 470 480 /* only take the phy0 addr */ 471 481 addr = (u64)d[12] << 56 | 472 482 (u64)d[13] << 48 | ··· 493 483 } 494 484 ecomp->slot = slot; 495 485 scomp->addr = addr; 486 + 487 + return 0; 496 488 } 497 489 498 490 struct efd { ··· 567 555 /* skip past overall descriptor */ 568 556 desc_ptr += len + 4; 569 557 } 570 - if (ses_dev->page10) 558 + if (ses_dev->page10 && ses_dev->page10_len > 9) 571 559 addl_desc_ptr = ses_dev->page10 + 8; 572 560 type_ptr = ses_dev->page1_types; 573 561 components = 0; ··· 575 563 for (j = 0; j < type_ptr[1]; j++) { 576 564 char *name = NULL; 577 565 struct enclosure_component *ecomp; 566 + int max_desc_len; 578 567 579 568 if (desc_ptr) { 580 - if (desc_ptr >= buf + page7_len) { 569 + if (desc_ptr + 3 >= buf + page7_len) { 581 570 desc_ptr = NULL; 582 571 } else { 583 572 len = (desc_ptr[2] << 8) + desc_ptr[3]; 584 573 desc_ptr += 4; 585 - /* Add trailing zero - pushes into 586 - * reserved space */ 587 - desc_ptr[len] = '\0'; 588 - name = desc_ptr; 574 + if (desc_ptr + len > buf + page7_len) 575 + desc_ptr = NULL; 576 + else { 577 + /* Add trailing zero - pushes into 578 + * reserved space */ 579 + desc_ptr[len] = '\0'; 580 + name = desc_ptr; 581 + } 589 582 } 590 583 } 591 584 if (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE || ··· 606 589 ecomp = &edev->component[components++]; 607 590 608 591 if (!IS_ERR(ecomp)) { 609 - if (addl_desc_ptr) 610 - ses_process_descriptor( 611 - ecomp, 612 - addl_desc_ptr); 592 + if (addl_desc_ptr) { 593 + max_desc_len = ses_dev->page10_len - 594 + (addl_desc_ptr - ses_dev->page10); 595 + if (ses_process_descriptor(ecomp, 596 + addl_desc_ptr, 597 + max_desc_len)) 598 + addl_desc_ptr = NULL; 599 + } 613 600 if (create) 614 601 enclosure_component_register( 615 602 ecomp); ··· 630 609 /* these elements are optional */ 631 610 type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_TARGET_PORT || 632 611 type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT || 633 - type_ptr[0] == ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS)) 612 + type_ptr[0] == ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS)) { 634 613 addl_desc_ptr += addl_desc_ptr[1] + 2; 635 - 614 + if (addl_desc_ptr + 1 >= ses_dev->page10 + ses_dev->page10_len) 615 + addl_desc_ptr = NULL; 616 + } 636 617 } 637 618 } 638 619 kfree(buf); ··· 733 710 type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) 734 711 components += type_ptr[1]; 735 712 } 713 + 714 + if (components == 0) { 715 + sdev_printk(KERN_WARNING, sdev, "enclosure has no enumerated components\n"); 716 + goto err_free; 717 + } 718 + 736 719 ses_dev->page1 = buf; 737 720 ses_dev->page1_len = len; 738 721 buf = NULL; ··· 862 833 kfree(ses_dev->page2); 863 834 kfree(ses_dev); 864 835 865 - kfree(edev->component[0].scratch); 836 + if (edev->components) 837 + kfree(edev->component[0].scratch); 866 838 867 839 put_device(&edev->edev); 868 840 enclosure_unregister(edev);
+45 -47
drivers/ufs/core/ufshcd.c
··· 1409 1409 struct ufs_clk_info *clki; 1410 1410 unsigned long irq_flags; 1411 1411 1412 + /* 1413 + * Skip devfreq if UFS initialization is not finished. 1414 + * Otherwise ufs could be in a inconsistent state. 1415 + */ 1416 + if (!smp_load_acquire(&hba->logical_unit_scan_finished)) 1417 + return 0; 1418 + 1412 1419 if (!ufshcd_is_clkscaling_supported(hba)) 1413 1420 return -EINVAL; 1414 1421 ··· 8399 8392 if (ret) 8400 8393 goto out; 8401 8394 8402 - /* Initialize devfreq after UFS device is detected */ 8403 - if (ufshcd_is_clkscaling_supported(hba)) { 8404 - memcpy(&hba->clk_scaling.saved_pwr_info.info, 8405 - &hba->pwr_info, 8406 - sizeof(struct ufs_pa_layer_attr)); 8407 - hba->clk_scaling.saved_pwr_info.is_valid = true; 8408 - hba->clk_scaling.is_allowed = true; 8409 - 8410 - ret = ufshcd_devfreq_init(hba); 8411 - if (ret) 8412 - goto out; 8413 - 8414 - hba->clk_scaling.is_enabled = true; 8415 - ufshcd_init_clk_scaling_sysfs(hba); 8416 - } 8417 - 8418 8395 ufs_bsg_probe(hba); 8419 8396 ufshpb_init(hba); 8420 8397 scsi_scan_host(hba->host); ··· 8529 8538 return ret; 8530 8539 if (is_mcq_supported(hba) && !hba->scsi_host_added) { 8531 8540 ret = ufshcd_alloc_mcq(hba); 8532 - if (ret) { 8541 + if (!ret) { 8542 + ufshcd_config_mcq(hba); 8543 + } else { 8533 8544 /* Continue with SDB mode */ 8534 8545 use_mcq_mode = false; 8535 8546 dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", ··· 8543 8550 return ret; 8544 8551 } 8545 8552 hba->scsi_host_added = true; 8546 - } 8547 - /* MCQ may be disabled if ufshcd_alloc_mcq() fails */ 8548 - if (is_mcq_supported(hba) && use_mcq_mode) 8553 + } else if (is_mcq_supported(hba)) { 8554 + /* UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is set */ 8549 8555 ufshcd_config_mcq(hba); 8556 + } 8550 8557 } 8551 8558 8552 8559 ufshcd_tune_unipro_params(hba); ··· 8670 8677 if (ret) { 8671 8678 pm_runtime_put_sync(hba->dev); 8672 8679 ufshcd_hba_exit(hba); 8680 + } else { 8681 + /* 8682 + * Make sure that when reader code sees UFS initialization has finished, 8683 + * all initialization steps have really been executed. 8684 + */ 8685 + smp_store_release(&hba->logical_unit_scan_finished, true); 8673 8686 } 8674 8687 } 8675 8688 ··· 9142 9143 enum ufs_dev_pwr_mode pwr_mode, 9143 9144 struct scsi_sense_hdr *sshdr) 9144 9145 { 9145 - unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; 9146 - struct request *req; 9147 - struct scsi_cmnd *scmd; 9148 - int ret; 9146 + const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; 9147 + const struct scsi_exec_args args = { 9148 + .sshdr = sshdr, 9149 + .req_flags = BLK_MQ_REQ_PM, 9150 + .scmd_flags = SCMD_FAIL_IF_RECOVERING, 9151 + }; 9149 9152 9150 - req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, 9151 - BLK_MQ_REQ_PM); 9152 - if (IS_ERR(req)) 9153 - return PTR_ERR(req); 9154 - 9155 - scmd = blk_mq_rq_to_pdu(req); 9156 - scmd->cmd_len = COMMAND_SIZE(cdb[0]); 9157 - memcpy(scmd->cmnd, cdb, scmd->cmd_len); 9158 - scmd->allowed = 0/*retries*/; 9159 - scmd->flags |= SCMD_FAIL_IF_RECOVERING; 9160 - req->timeout = 1 * HZ; 9161 - req->rq_flags |= RQF_PM | RQF_QUIET; 9162 - 9163 - blk_execute_rq(req, /*at_head=*/true); 9164 - 9165 - if (sshdr) 9166 - scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len, 9167 - sshdr); 9168 - ret = scmd->result; 9169 - 9170 - blk_mq_free_request(req); 9171 - 9172 - return ret; 9153 + return scsi_execute_cmd(sdev, cdb, REQ_OP_DRV_IN, /*buffer=*/NULL, 9154 + /*bufflen=*/0, /*timeout=*/HZ, /*retries=*/0, &args); 9173 9155 } 9174 9156 9175 9157 /** ··· 10316 10336 */ 10317 10337 ufshcd_set_ufs_dev_active(hba); 10318 10338 10339 + /* Initialize devfreq */ 10340 + if (ufshcd_is_clkscaling_supported(hba)) { 10341 + memcpy(&hba->clk_scaling.saved_pwr_info.info, 10342 + &hba->pwr_info, 10343 + sizeof(struct ufs_pa_layer_attr)); 10344 + hba->clk_scaling.saved_pwr_info.is_valid = true; 10345 + hba->clk_scaling.is_allowed = true; 10346 + 10347 + err = ufshcd_devfreq_init(hba); 10348 + if (err) 10349 + goto rpm_put_sync; 10350 + 10351 + hba->clk_scaling.is_enabled = true; 10352 + ufshcd_init_clk_scaling_sysfs(hba); 10353 + } 10354 + 10319 10355 async_schedule(ufshcd_async_scan, hba); 10320 10356 ufs_sysfs_add_nodes(hba->dev); 10321 10357 10322 10358 device_enable_async_suspend(dev); 10323 10359 return 0; 10324 10360 10361 + rpm_put_sync: 10362 + pm_runtime_put_sync(dev); 10325 10363 free_tmf_queue: 10326 10364 blk_mq_destroy_queue(hba->tmf_queue); 10327 10365 blk_put_queue(hba->tmf_queue);
+1 -1
drivers/ufs/host/Kconfig
··· 48 48 49 49 config SCSI_UFS_DWC_TC_PLATFORM 50 50 tristate "DesignWare platform support using a G210 Test Chip" 51 - depends on SCSI_UFSHCD_PLATFORM 51 + depends on OF && SCSI_UFSHCD_PLATFORM 52 52 help 53 53 Synopsys Test Chip is a PHY for prototyping purposes. 54 54
+2
drivers/ufs/host/ufs-mediatek.c
··· 1613 1613 } 1614 1614 #endif 1615 1615 1616 + #ifdef CONFIG_PM 1616 1617 static int ufs_mtk_runtime_suspend(struct device *dev) 1617 1618 { 1618 1619 struct ufs_hba *hba = dev_get_drvdata(dev); ··· 1636 1635 1637 1636 return ufshcd_runtime_resume(dev); 1638 1637 } 1638 + #endif 1639 1639 1640 1640 static const struct dev_pm_ops ufs_mtk_pm_ops = { 1641 1641 SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend,
+1
include/scsi/scsi_device.h
··· 462 462 unsigned int sense_len; /* sense buffer len */ 463 463 struct scsi_sense_hdr *sshdr; /* decoded sense header */ 464 464 blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */ 465 + int scmd_flags; /* SCMD flags */ 465 466 int *resid; /* residual length */ 466 467 }; 467 468
+3 -1
include/scsi/scsi_transport_fc.h
··· 496 496 FCH_EVT_PORT_FABRIC = 0x204, 497 497 FCH_EVT_LINK_UNKNOWN = 0x500, 498 498 FCH_EVT_LINK_FPIN = 0x501, 499 + FCH_EVT_LINK_FPIN_ACK = 0x502, 499 500 FCH_EVT_VENDOR_UNIQUE = 0xffff, 500 501 }; 501 502 ··· 857 856 * Note: when calling fc_host_post_fc_event(), vendor_id may be 858 857 * specified as 0. 859 858 */ 860 - void fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf); 859 + void fc_host_fpin_rcv(struct Scsi_Host *shost, u32 fpin_len, char *fpin_buf, 860 + u8 event_acknowledge); 861 861 struct fc_vport *fc_vport_create(struct Scsi_Host *shost, int channel, 862 862 struct fc_vport_identifiers *); 863 863 int fc_vport_terminate(struct fc_vport *vport);
+1 -7
include/uapi/scsi/scsi_bsg_mpi3mr.h
··· 455 455 } cmd; 456 456 }; 457 457 458 - 459 - /* MPI3: NVMe Encasulation related definitions */ 460 - #ifndef MPI3_NVME_ENCAP_CMD_MAX 461 - #define MPI3_NVME_ENCAP_CMD_MAX (1) 462 - #endif 463 - 464 458 struct mpi3_nvme_encapsulated_request { 465 459 __le16 host_tag; 466 460 __u8 ioc_use_only02; ··· 468 474 __le16 flags; 469 475 __le32 data_length; 470 476 __le32 reserved14[3]; 471 - __le32 command[MPI3_NVME_ENCAP_CMD_MAX]; 477 + __le32 command[]; 472 478 }; 473 479 474 480 struct mpi3_nvme_encapsulated_error_reply {
+1
include/ufs/ufshcd.h
··· 979 979 struct completion *uic_async_done; 980 980 981 981 enum ufshcd_state ufshcd_state; 982 + bool logical_unit_scan_finished; 982 983 u32 eh_flags; 983 984 u32 intr_mask; 984 985 u16 ee_ctrl_mask;