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 SCSI updates from James Bottomley:
"Only a couple of driver updates this time (lpfc and mpt3sas) plus the
usual assorted minor fixes and updates. The major core update is a set
of patches moving retries out of the drivers and into the core"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (84 commits)
scsi: core: Constify the struct device_type usage
scsi: libfc: replace deprecated strncpy() with memcpy()
scsi: lpfc: Replace deprecated strncpy() with strscpy()
scsi: bfa: Fix function pointer type mismatch for state machines
scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn
scsi: bfa: Remove additional unnecessary struct declarations
scsi: csiostor: Avoid function pointer casts
scsi: qla1280: Remove redundant assignment to variable 'mr'
scsi: core: Make scsi_bus_type const
scsi: core: Really include kunit tests with SCSI_LIB_KUNIT_TEST
scsi: target: tcm_loop: Make tcm_loop_lld_bus const
scsi: scsi_debug: Make pseudo_lld_bus const
scsi: iscsi: Make iscsi_flashnode_bus const
scsi: fcoe: Make fcoe_bus_type const
scsi: lpfc: Copyright updates for 14.4.0.0 patches
scsi: lpfc: Update lpfc version to 14.4.0.0
scsi: lpfc: Change lpfc_vport load_flag member into a bitmask
scsi: lpfc: Change lpfc_vport fc_flag member into a bitmask
scsi: lpfc: Protect vport fc_nodes list with an explicit spin lock
scsi: lpfc: Change nlp state statistic counters into atomic_t
...

+2752 -1841
+1 -3
drivers/message/fusion/mptfc.c
··· 1401 1401 static int 1402 1402 mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) 1403 1403 { 1404 - MPT_SCSI_HOST *hd; 1405 1404 u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; 1406 1405 unsigned long flags; 1407 1406 int rc=1; ··· 1411 1412 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", 1412 1413 ioc->name, event)); 1413 1414 1414 - if (ioc->sh == NULL || 1415 - ((hd = shost_priv(ioc->sh)) == NULL)) 1415 + if (ioc->sh == NULL || shost_priv(ioc->sh) == NULL) 1416 1416 return 1; 1417 1417 1418 1418 switch (event) {
+22 -22
drivers/scsi/3w-9xxx.c
··· 161 161 ssize_t len; 162 162 163 163 spin_lock_irqsave(tw_dev->host->host_lock, flags); 164 - len = snprintf(buf, PAGE_SIZE, "3w-9xxx Driver version: %s\n" 165 - "Current commands posted: %4d\n" 166 - "Max commands posted: %4d\n" 167 - "Current pending commands: %4d\n" 168 - "Max pending commands: %4d\n" 169 - "Last sgl length: %4d\n" 170 - "Max sgl length: %4d\n" 171 - "Last sector count: %4d\n" 172 - "Max sector count: %4d\n" 173 - "SCSI Host Resets: %4d\n" 174 - "AEN's: %4d\n", 175 - TW_DRIVER_VERSION, 176 - tw_dev->posted_request_count, 177 - tw_dev->max_posted_request_count, 178 - tw_dev->pending_request_count, 179 - tw_dev->max_pending_request_count, 180 - tw_dev->sgl_entries, 181 - tw_dev->max_sgl_entries, 182 - tw_dev->sector_count, 183 - tw_dev->max_sector_count, 184 - tw_dev->num_resets, 185 - tw_dev->aen_count); 164 + len = sysfs_emit(buf, "3w-9xxx Driver version: %s\n" 165 + "Current commands posted: %4d\n" 166 + "Max commands posted: %4d\n" 167 + "Current pending commands: %4d\n" 168 + "Max pending commands: %4d\n" 169 + "Last sgl length: %4d\n" 170 + "Max sgl length: %4d\n" 171 + "Last sector count: %4d\n" 172 + "Max sector count: %4d\n" 173 + "SCSI Host Resets: %4d\n" 174 + "AEN's: %4d\n", 175 + TW_DRIVER_VERSION, 176 + tw_dev->posted_request_count, 177 + tw_dev->max_posted_request_count, 178 + tw_dev->pending_request_count, 179 + tw_dev->max_pending_request_count, 180 + tw_dev->sgl_entries, 181 + tw_dev->max_sgl_entries, 182 + tw_dev->sector_count, 183 + tw_dev->max_sector_count, 184 + tw_dev->num_resets, 185 + tw_dev->aen_count); 186 186 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); 187 187 return len; 188 188 } /* End twa_show_stats() */
+18 -18
drivers/scsi/3w-sas.c
··· 166 166 ssize_t len; 167 167 168 168 spin_lock_irqsave(tw_dev->host->host_lock, flags); 169 - len = snprintf(buf, PAGE_SIZE, "3w-sas Driver version: %s\n" 170 - "Current commands posted: %4d\n" 171 - "Max commands posted: %4d\n" 172 - "Last sgl length: %4d\n" 173 - "Max sgl length: %4d\n" 174 - "Last sector count: %4d\n" 175 - "Max sector count: %4d\n" 176 - "SCSI Host Resets: %4d\n" 177 - "AEN's: %4d\n", 178 - TW_DRIVER_VERSION, 179 - tw_dev->posted_request_count, 180 - tw_dev->max_posted_request_count, 181 - tw_dev->sgl_entries, 182 - tw_dev->max_sgl_entries, 183 - tw_dev->sector_count, 184 - tw_dev->max_sector_count, 185 - tw_dev->num_resets, 186 - tw_dev->aen_count); 169 + len = sysfs_emit(buf, "3w-sas Driver version: %s\n" 170 + "Current commands posted: %4d\n" 171 + "Max commands posted: %4d\n" 172 + "Last sgl length: %4d\n" 173 + "Max sgl length: %4d\n" 174 + "Last sector count: %4d\n" 175 + "Max sector count: %4d\n" 176 + "SCSI Host Resets: %4d\n" 177 + "AEN's: %4d\n", 178 + TW_DRIVER_VERSION, 179 + tw_dev->posted_request_count, 180 + tw_dev->max_posted_request_count, 181 + tw_dev->sgl_entries, 182 + tw_dev->max_sgl_entries, 183 + tw_dev->sector_count, 184 + tw_dev->max_sector_count, 185 + tw_dev->num_resets, 186 + tw_dev->aen_count); 187 187 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); 188 188 return len; 189 189 } /* End twl_show_stats() */
+22 -22
drivers/scsi/3w-xxxx.c
··· 496 496 ssize_t len; 497 497 498 498 spin_lock_irqsave(tw_dev->host->host_lock, flags); 499 - len = snprintf(buf, PAGE_SIZE, "3w-xxxx Driver version: %s\n" 500 - "Current commands posted: %4d\n" 501 - "Max commands posted: %4d\n" 502 - "Current pending commands: %4d\n" 503 - "Max pending commands: %4d\n" 504 - "Last sgl length: %4d\n" 505 - "Max sgl length: %4d\n" 506 - "Last sector count: %4d\n" 507 - "Max sector count: %4d\n" 508 - "SCSI Host Resets: %4d\n" 509 - "AEN's: %4d\n", 510 - TW_DRIVER_VERSION, 511 - tw_dev->posted_request_count, 512 - tw_dev->max_posted_request_count, 513 - tw_dev->pending_request_count, 514 - tw_dev->max_pending_request_count, 515 - tw_dev->sgl_entries, 516 - tw_dev->max_sgl_entries, 517 - tw_dev->sector_count, 518 - tw_dev->max_sector_count, 519 - tw_dev->num_resets, 520 - tw_dev->aen_count); 499 + len = sysfs_emit(buf, "3w-xxxx Driver version: %s\n" 500 + "Current commands posted: %4d\n" 501 + "Max commands posted: %4d\n" 502 + "Current pending commands: %4d\n" 503 + "Max pending commands: %4d\n" 504 + "Last sgl length: %4d\n" 505 + "Max sgl length: %4d\n" 506 + "Last sector count: %4d\n" 507 + "Max sector count: %4d\n" 508 + "SCSI Host Resets: %4d\n" 509 + "AEN's: %4d\n", 510 + TW_DRIVER_VERSION, 511 + tw_dev->posted_request_count, 512 + tw_dev->max_posted_request_count, 513 + tw_dev->pending_request_count, 514 + tw_dev->max_pending_request_count, 515 + tw_dev->sgl_entries, 516 + tw_dev->max_sgl_entries, 517 + tw_dev->sector_count, 518 + tw_dev->max_sector_count, 519 + tw_dev->num_resets, 520 + tw_dev->aen_count); 521 521 spin_unlock_irqrestore(tw_dev->host->host_lock, flags); 522 522 return len; 523 523 } /* End tw_show_stats() */
+1 -1
drivers/scsi/53c700.c
··· 2071 2071 { 2072 2072 struct scsi_device *SDp = to_scsi_device(dev); 2073 2073 2074 - return snprintf(buf, 20, "%d\n", NCR_700_get_depth(SDp)); 2074 + return sysfs_emit(buf, "%d\n", NCR_700_get_depth(SDp)); 2075 2075 } 2076 2076 2077 2077 static struct device_attribute NCR_700_active_tags_attr = {
+9
drivers/scsi/Kconfig
··· 67 67 68 68 If unsure say Y. 69 69 70 + config SCSI_LIB_KUNIT_TEST 71 + tristate "KUnit tests for SCSI Mid Layer's scsi_lib" if !KUNIT_ALL_TESTS 72 + depends on KUNIT 73 + default KUNIT_ALL_TESTS 74 + help 75 + Run SCSI Mid Layer's KUnit tests for scsi_lib. 76 + 77 + If unsure say N. 78 + 70 79 comment "SCSI support type (disk, tape, CD-ROM)" 71 80 depends on SCSI 72 81
+3 -3
drivers/scsi/aacraid/aachba.c
··· 1099 1099 sp[0] = INQD_PDT_DA; 1100 1100 sp[1] = scsicmd->cmnd[2]; 1101 1101 sp[2] = 0; 1102 - sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X", 1102 + sp[3] = scnprintf(sp+4, sizeof(sp)-4, "%08X", 1103 1103 le32_to_cpu(get_serial_reply->uid)); 1104 1104 scsi_sg_copy_from_buffer(scsicmd, sp, 1105 1105 sizeof(sp)); ··· 1169 1169 /* 1170 1170 * This breaks array migration. 1171 1171 */ 1172 - return snprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X", 1173 - le32_to_cpu(dev->adapter_info.serial[0]), cid); 1172 + return scnprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X", 1173 + le32_to_cpu(dev->adapter_info.serial[0]), cid); 1174 1174 } 1175 1175 1176 1176 static inline void set_sense(struct sense_data *sense_data, u8 sense_key,
+28 -2
drivers/scsi/bfa/bfa.h
··· 20 20 struct bfa_s; 21 21 22 22 typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m); 23 - typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status); 24 23 25 24 /* 26 25 * Interrupt message handlers ··· 215 216 bfa_boolean_t busy; 216 217 }; 217 218 219 + /* 220 + * IOCFC state machine definitions/declarations 221 + */ 222 + enum iocfc_event { 223 + IOCFC_E_INIT = 1, /* IOCFC init request */ 224 + IOCFC_E_START = 2, /* IOCFC mod start request */ 225 + IOCFC_E_STOP = 3, /* IOCFC stop request */ 226 + IOCFC_E_ENABLE = 4, /* IOCFC enable request */ 227 + IOCFC_E_DISABLE = 5, /* IOCFC disable request */ 228 + IOCFC_E_IOC_ENABLED = 6, /* IOC enabled message */ 229 + IOCFC_E_IOC_DISABLED = 7, /* IOC disabled message */ 230 + IOCFC_E_IOC_FAILED = 8, /* failure notice by IOC sm */ 231 + IOCFC_E_DCONF_DONE = 9, /* dconf read/write done */ 232 + IOCFC_E_CFG_DONE = 10, /* IOCFC config complete */ 233 + }; 234 + 235 + struct bfa_iocfc_s; 236 + typedef void (*bfa_iocfs_fsm_t)(struct bfa_iocfc_s *, enum iocfc_event); 237 + 218 238 struct bfa_iocfc_s { 219 - bfa_fsm_t fsm; 239 + bfa_iocfs_fsm_t fsm; 220 240 struct bfa_s *bfa; 221 241 struct bfa_iocfc_cfg_s cfg; 222 242 u32 req_cq_pi[BFI_IOC_MAX_CQS]; ··· 450 432 #define bfa_pending_q_init(__qe, __cbfn, __cbarg, __data) do { \ 451 433 bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \ 452 434 (__qe)->hcb_qe.cbfn = (__cbfn); \ 435 + (__qe)->hcb_qe.cbarg = (__cbarg); \ 436 + (__qe)->hcb_qe.pre_rmv = BFA_TRUE; \ 437 + (__qe)->data = (__data); \ 438 + } while (0) 439 + 440 + #define bfa_pending_q_init_status(__qe, __cbfn, __cbarg, __data) do { \ 441 + bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \ 442 + (__qe)->hcb_qe.cbfn_status = (__cbfn); \ 453 443 (__qe)->hcb_qe.cbarg = (__cbarg); \ 454 444 (__qe)->hcb_qe.pre_rmv = BFA_TRUE; \ 455 445 (__qe)->data = (__data); \
+1 -3
drivers/scsi/bfa/bfa_core.c
··· 1907 1907 struct list_head *qe; 1908 1908 struct list_head *qen; 1909 1909 struct bfa_cb_qe_s *hcb_qe; 1910 - bfa_cb_cbfn_status_t cbfn; 1911 1910 1912 1911 list_for_each_safe(qe, qen, comp_q) { 1913 1912 hcb_qe = (struct bfa_cb_qe_s *) qe; 1914 1913 if (hcb_qe->pre_rmv) { 1915 1914 /* qe is invalid after return, dequeue before cbfn() */ 1916 1915 list_del(qe); 1917 - cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn); 1918 - cbfn(hcb_qe->cbarg, hcb_qe->fw_status); 1916 + hcb_qe->cbfn_status(hcb_qe->cbarg, hcb_qe->fw_status); 1919 1917 } else 1920 1918 hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE); 1921 1919 }
+5 -16
drivers/scsi/bfa/bfa_cs.h
··· 187 187 #define bfa_sm_state_decl(oc, st, otype, etype) \ 188 188 static void oc ## _sm_ ## st(otype * fsm, etype event) 189 189 190 - #define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state)) 190 + #define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (_state)) 191 191 #define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event))) 192 192 #define bfa_sm_get_state(_sm) ((_sm)->sm) 193 - #define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (bfa_sm_t)(_state)) 193 + #define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (_state)) 194 194 195 195 /* 196 196 * For converting from state machine function to state encoding. ··· 200 200 int state; /* state machine encoding */ 201 201 char *name; /* state name for display */ 202 202 }; 203 - #define BFA_SM(_sm) ((bfa_sm_t)(_sm)) 203 + #define BFA_SM(_sm) (_sm) 204 204 205 205 /* 206 206 * State machine with entry actions. ··· 218 218 static void oc ## _sm_ ## st ## _entry(otype * fsm) 219 219 220 220 #define bfa_fsm_set_state(_fsm, _state) do { \ 221 - (_fsm)->fsm = (bfa_fsm_t)(_state); \ 221 + (_fsm)->fsm = (_state); \ 222 222 _state ## _entry(_fsm); \ 223 223 } while (0) 224 224 225 225 #define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event))) 226 226 #define bfa_fsm_get_state(_fsm) ((_fsm)->fsm) 227 - #define bfa_fsm_cmp_state(_fsm, _state) \ 228 - ((_fsm)->fsm == (bfa_fsm_t)(_state)) 229 - 230 - static inline int 231 - bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm) 232 - { 233 - int i = 0; 234 - 235 - while (smt[i].sm && smt[i].sm != sm) 236 - i++; 237 - return smt[i].state; 238 - } 227 + #define bfa_fsm_cmp_state(_fsm, _state) ((_fsm)->fsm == (_state)) 239 228 240 229 /* 241 230 * @ Generic wait counter.
-51
drivers/scsi/bfa/bfa_fcpim.c
··· 65 65 }; 66 66 67 67 /* 68 - * itnim state machine event 69 - */ 70 - enum bfa_itnim_event { 71 - BFA_ITNIM_SM_CREATE = 1, /* itnim is created */ 72 - BFA_ITNIM_SM_ONLINE = 2, /* itnim is online */ 73 - BFA_ITNIM_SM_OFFLINE = 3, /* itnim is offline */ 74 - BFA_ITNIM_SM_FWRSP = 4, /* firmware response */ 75 - BFA_ITNIM_SM_DELETE = 5, /* deleting an existing itnim */ 76 - BFA_ITNIM_SM_CLEANUP = 6, /* IO cleanup completion */ 77 - BFA_ITNIM_SM_SLER = 7, /* second level error recovery */ 78 - BFA_ITNIM_SM_HWFAIL = 8, /* IOC h/w failure event */ 79 - BFA_ITNIM_SM_QRESUME = 9, /* queue space available */ 80 - }; 81 - 82 - /* 83 68 * BFA IOIM related definitions 84 69 */ 85 70 #define bfa_ioim_move_to_comp_q(__ioim) do { \ ··· 82 97 if ((__fcpim)->profile_start) \ 83 98 (__fcpim)->profile_start(__ioim); \ 84 99 } while (0) 85 - 86 - /* 87 - * IO state machine events 88 - */ 89 - enum bfa_ioim_event { 90 - BFA_IOIM_SM_START = 1, /* io start request from host */ 91 - BFA_IOIM_SM_COMP_GOOD = 2, /* io good comp, resource free */ 92 - BFA_IOIM_SM_COMP = 3, /* io comp, resource is free */ 93 - BFA_IOIM_SM_COMP_UTAG = 4, /* io comp, resource is free */ 94 - BFA_IOIM_SM_DONE = 5, /* io comp, resource not free */ 95 - BFA_IOIM_SM_FREE = 6, /* io resource is freed */ 96 - BFA_IOIM_SM_ABORT = 7, /* abort request from scsi stack */ 97 - BFA_IOIM_SM_ABORT_COMP = 8, /* abort from f/w */ 98 - BFA_IOIM_SM_ABORT_DONE = 9, /* abort completion from f/w */ 99 - BFA_IOIM_SM_QRESUME = 10, /* CQ space available to queue IO */ 100 - BFA_IOIM_SM_SGALLOCED = 11, /* SG page allocation successful */ 101 - BFA_IOIM_SM_SQRETRY = 12, /* sequence recovery retry */ 102 - BFA_IOIM_SM_HCB = 13, /* bfa callback complete */ 103 - BFA_IOIM_SM_CLEANUP = 14, /* IO cleanup from itnim */ 104 - BFA_IOIM_SM_TMSTART = 15, /* IO cleanup from tskim */ 105 - BFA_IOIM_SM_TMDONE = 16, /* IO cleanup from tskim */ 106 - BFA_IOIM_SM_HWFAIL = 17, /* IOC h/w failure event */ 107 - BFA_IOIM_SM_IOTOV = 18, /* ITN offline TOV */ 108 - }; 109 100 110 101 111 102 /* ··· 101 140 bfa_itnim_tskdone((__tskim)->itnim); \ 102 141 } while (0) 103 142 104 - 105 - enum bfa_tskim_event { 106 - BFA_TSKIM_SM_START = 1, /* TM command start */ 107 - BFA_TSKIM_SM_DONE = 2, /* TM completion */ 108 - BFA_TSKIM_SM_QRESUME = 3, /* resume after qfull */ 109 - BFA_TSKIM_SM_HWFAIL = 5, /* IOC h/w failure event */ 110 - BFA_TSKIM_SM_HCB = 6, /* BFA callback completion */ 111 - BFA_TSKIM_SM_IOS_DONE = 7, /* IO and sub TM completions */ 112 - BFA_TSKIM_SM_CLEANUP = 8, /* TM cleanup on ITN offline */ 113 - BFA_TSKIM_SM_CLEANUP_DONE = 9, /* TM abort completion */ 114 - BFA_TSKIM_SM_UTAG = 10, /* TM completion unknown tag */ 115 - }; 116 143 117 144 /* 118 145 * forward declaration for BFA ITNIM functions
+63 -3
drivers/scsi/bfa/bfa_fcpim.h
··· 155 155 }; 156 156 157 157 /* 158 + * IO state machine events 159 + */ 160 + enum bfa_ioim_event { 161 + BFA_IOIM_SM_START = 1, /* io start request from host */ 162 + BFA_IOIM_SM_COMP_GOOD = 2, /* io good comp, resource free */ 163 + BFA_IOIM_SM_COMP = 3, /* io comp, resource is free */ 164 + BFA_IOIM_SM_COMP_UTAG = 4, /* io comp, resource is free */ 165 + BFA_IOIM_SM_DONE = 5, /* io comp, resource not free */ 166 + BFA_IOIM_SM_FREE = 6, /* io resource is freed */ 167 + BFA_IOIM_SM_ABORT = 7, /* abort request from scsi stack */ 168 + BFA_IOIM_SM_ABORT_COMP = 8, /* abort from f/w */ 169 + BFA_IOIM_SM_ABORT_DONE = 9, /* abort completion from f/w */ 170 + BFA_IOIM_SM_QRESUME = 10, /* CQ space available to queue IO */ 171 + BFA_IOIM_SM_SGALLOCED = 11, /* SG page allocation successful */ 172 + BFA_IOIM_SM_SQRETRY = 12, /* sequence recovery retry */ 173 + BFA_IOIM_SM_HCB = 13, /* bfa callback complete */ 174 + BFA_IOIM_SM_CLEANUP = 14, /* IO cleanup from itnim */ 175 + BFA_IOIM_SM_TMSTART = 15, /* IO cleanup from tskim */ 176 + BFA_IOIM_SM_TMDONE = 16, /* IO cleanup from tskim */ 177 + BFA_IOIM_SM_HWFAIL = 17, /* IOC h/w failure event */ 178 + BFA_IOIM_SM_IOTOV = 18, /* ITN offline TOV */ 179 + }; 180 + 181 + struct bfa_ioim_s; 182 + typedef void (*bfa_ioim_sm_t)(struct bfa_ioim_s *, enum bfa_ioim_event); 183 + 184 + /* 158 185 * BFA IO (initiator mode) 159 186 */ 160 187 struct bfa_ioim_s { 161 188 struct list_head qe; /* queue elememt */ 162 - bfa_sm_t sm; /* BFA ioim state machine */ 189 + bfa_ioim_sm_t sm; /* BFA ioim state machine */ 163 190 struct bfa_s *bfa; /* BFA module */ 164 191 struct bfa_fcpim_s *fcpim; /* parent fcpim module */ 165 192 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ ··· 213 186 struct bfa_tskim_s *tskim; /* Relevant TM cmd */ 214 187 }; 215 188 189 + enum bfa_tskim_event { 190 + BFA_TSKIM_SM_START = 1, /* TM command start */ 191 + BFA_TSKIM_SM_DONE = 2, /* TM completion */ 192 + BFA_TSKIM_SM_QRESUME = 3, /* resume after qfull */ 193 + BFA_TSKIM_SM_HWFAIL = 5, /* IOC h/w failure event */ 194 + BFA_TSKIM_SM_HCB = 6, /* BFA callback completion */ 195 + BFA_TSKIM_SM_IOS_DONE = 7, /* IO and sub TM completions */ 196 + BFA_TSKIM_SM_CLEANUP = 8, /* TM cleanup on ITN offline */ 197 + BFA_TSKIM_SM_CLEANUP_DONE = 9, /* TM abort completion */ 198 + BFA_TSKIM_SM_UTAG = 10, /* TM completion unknown tag */ 199 + }; 200 + 201 + struct bfa_tskim_s; 202 + typedef void (*bfa_tskim_sm_t)(struct bfa_tskim_s *, enum bfa_tskim_event); 203 + 216 204 /* 217 205 * BFA Task management command (initiator mode) 218 206 */ 219 207 struct bfa_tskim_s { 220 208 struct list_head qe; 221 - bfa_sm_t sm; 209 + bfa_tskim_sm_t sm; 222 210 struct bfa_s *bfa; /* BFA module */ 223 211 struct bfa_fcpim_s *fcpim; /* parent fcpim module */ 224 212 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */ ··· 251 209 }; 252 210 253 211 /* 212 + * itnim state machine event 213 + */ 214 + enum bfa_itnim_event { 215 + BFA_ITNIM_SM_CREATE = 1, /* itnim is created */ 216 + BFA_ITNIM_SM_ONLINE = 2, /* itnim is online */ 217 + BFA_ITNIM_SM_OFFLINE = 3, /* itnim is offline */ 218 + BFA_ITNIM_SM_FWRSP = 4, /* firmware response */ 219 + BFA_ITNIM_SM_DELETE = 5, /* deleting an existing itnim */ 220 + BFA_ITNIM_SM_CLEANUP = 6, /* IO cleanup completion */ 221 + BFA_ITNIM_SM_SLER = 7, /* second level error recovery */ 222 + BFA_ITNIM_SM_HWFAIL = 8, /* IOC h/w failure event */ 223 + BFA_ITNIM_SM_QRESUME = 9, /* queue space available */ 224 + }; 225 + 226 + struct bfa_itnim_s; 227 + typedef void (*bfa_itnim_sm_t)(struct bfa_itnim_s *, enum bfa_itnim_event); 228 + 229 + /* 254 230 * BFA i-t-n (initiator mode) 255 231 */ 256 232 struct bfa_itnim_s { 257 233 struct list_head qe; /* queue element */ 258 - bfa_sm_t sm; /* i-t-n im BFA state machine */ 234 + bfa_itnim_sm_t sm; /* i-t-n im BFA state machine */ 259 235 struct bfa_s *bfa; /* bfa instance */ 260 236 struct bfa_rport_s *rport; /* bfa rport */ 261 237 void *ditn; /* driver i-t-n structure */
+212 -100
drivers/scsi/bfa/bfa_fcs.h
··· 20 20 #define BFA_FCS_OS_STR_LEN 64 21 21 22 22 /* 23 - * lps_pvt BFA LPS private functions 24 - */ 25 - 26 - enum bfa_lps_event { 27 - BFA_LPS_SM_LOGIN = 1, /* login request from user */ 28 - BFA_LPS_SM_LOGOUT = 2, /* logout request from user */ 29 - BFA_LPS_SM_FWRSP = 3, /* f/w response to login/logout */ 30 - BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */ 31 - BFA_LPS_SM_DELETE = 5, /* lps delete from user */ 32 - BFA_LPS_SM_OFFLINE = 6, /* Link is offline */ 33 - BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */ 34 - BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */ 35 - }; 36 - 37 - 38 - /* 39 23 * !!! Only append to the enums defined here to avoid any versioning 40 24 * !!! needed between trace utility and driver version 41 25 */ ··· 43 59 #define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0) 44 60 #define BFA_FCS_MAX_RPORT_LOGINS 1024 45 61 62 + /* 63 + * VPort NS State Machine events 64 + */ 65 + enum vport_ns_event { 66 + NSSM_EVENT_PORT_ONLINE = 1, 67 + NSSM_EVENT_PORT_OFFLINE = 2, 68 + NSSM_EVENT_PLOGI_SENT = 3, 69 + NSSM_EVENT_RSP_OK = 4, 70 + NSSM_EVENT_RSP_ERROR = 5, 71 + NSSM_EVENT_TIMEOUT = 6, 72 + NSSM_EVENT_NS_QUERY = 7, 73 + NSSM_EVENT_RSPNID_SENT = 8, 74 + NSSM_EVENT_RFTID_SENT = 9, 75 + NSSM_EVENT_RFFID_SENT = 10, 76 + NSSM_EVENT_GIDFT_SENT = 11, 77 + NSSM_EVENT_RNNID_SENT = 12, 78 + NSSM_EVENT_RSNN_NN_SENT = 13, 79 + }; 80 + 81 + struct bfa_fcs_lport_ns_s; 82 + typedef void (*bfa_fcs_lport_ns_sm_t)(struct bfa_fcs_lport_ns_s *fsm, enum vport_ns_event); 83 + 46 84 struct bfa_fcs_lport_ns_s { 47 - bfa_sm_t sm; /* state machine */ 85 + bfa_fcs_lport_ns_sm_t sm; /* state machine */ 48 86 struct bfa_timer_s timer; 49 87 struct bfa_fcs_lport_s *port; /* parent port */ 50 88 struct bfa_fcxp_s *fcxp; ··· 75 69 u8 num_rsnn_nn_retries; 76 70 }; 77 71 72 + /* 73 + * VPort SCN State Machine events 74 + */ 75 + enum port_scn_event { 76 + SCNSM_EVENT_PORT_ONLINE = 1, 77 + SCNSM_EVENT_PORT_OFFLINE = 2, 78 + SCNSM_EVENT_RSP_OK = 3, 79 + SCNSM_EVENT_RSP_ERROR = 4, 80 + SCNSM_EVENT_TIMEOUT = 5, 81 + SCNSM_EVENT_SCR_SENT = 6, 82 + }; 83 + 84 + struct bfa_fcs_lport_scn_s; 85 + typedef void (*bfa_fcs_lport_scn_sm_t)(struct bfa_fcs_lport_scn_s *fsm, enum port_scn_event); 78 86 79 87 struct bfa_fcs_lport_scn_s { 80 - bfa_sm_t sm; /* state machine */ 88 + bfa_fcs_lport_scn_sm_t sm; /* state machine */ 81 89 struct bfa_timer_s timer; 82 90 struct bfa_fcs_lport_s *port; /* parent port */ 83 91 struct bfa_fcxp_s *fcxp; ··· 99 79 }; 100 80 101 81 82 + /* 83 + * FDMI State Machine events 84 + */ 85 + enum port_fdmi_event { 86 + FDMISM_EVENT_PORT_ONLINE = 1, 87 + FDMISM_EVENT_PORT_OFFLINE = 2, 88 + FDMISM_EVENT_RSP_OK = 4, 89 + FDMISM_EVENT_RSP_ERROR = 5, 90 + FDMISM_EVENT_TIMEOUT = 6, 91 + FDMISM_EVENT_RHBA_SENT = 7, 92 + FDMISM_EVENT_RPRT_SENT = 8, 93 + FDMISM_EVENT_RPA_SENT = 9, 94 + }; 95 + 96 + struct bfa_fcs_lport_fdmi_s; 97 + typedef void (*bfa_fcs_lport_fdmi_sm_t)(struct bfa_fcs_lport_fdmi_s *fsm, enum port_fdmi_event); 98 + 102 99 struct bfa_fcs_lport_fdmi_s { 103 - bfa_sm_t sm; /* state machine */ 100 + bfa_fcs_lport_fdmi_sm_t sm; /* state machine */ 104 101 struct bfa_timer_s timer; 105 102 struct bfa_fcs_lport_ms_s *ms; /* parent ms */ 106 103 struct bfa_fcxp_s *fcxp; ··· 125 88 u8 retry_cnt; /* retry count */ 126 89 u8 rsvd[3]; 127 90 }; 91 + /* 92 + * MS State Machine events 93 + */ 94 + enum port_ms_event { 95 + MSSM_EVENT_PORT_ONLINE = 1, 96 + MSSM_EVENT_PORT_OFFLINE = 2, 97 + MSSM_EVENT_RSP_OK = 3, 98 + MSSM_EVENT_RSP_ERROR = 4, 99 + MSSM_EVENT_TIMEOUT = 5, 100 + MSSM_EVENT_FCXP_SENT = 6, 101 + MSSM_EVENT_PORT_FABRIC_RSCN = 7 102 + }; 128 103 104 + struct bfa_fcs_lport_ms_s; 105 + typedef void (*bfa_fcs_lport_ms_sm_t)(struct bfa_fcs_lport_ms_s *fsm, enum port_ms_event); 129 106 130 107 struct bfa_fcs_lport_ms_s { 131 - bfa_sm_t sm; /* state machine */ 108 + bfa_fcs_lport_ms_sm_t sm; /* state machine */ 132 109 struct bfa_timer_s timer; 133 110 struct bfa_fcs_lport_s *port; /* parent port */ 134 111 struct bfa_fcxp_s *fcxp; ··· 182 131 struct bfa_fcs_lport_n2n_s pn2n; 183 132 }; 184 133 134 + /* 135 + * fcs_port_sm FCS logical port state machine 136 + */ 137 + 138 + enum bfa_fcs_lport_event { 139 + BFA_FCS_PORT_SM_CREATE = 1, 140 + BFA_FCS_PORT_SM_ONLINE = 2, 141 + BFA_FCS_PORT_SM_OFFLINE = 3, 142 + BFA_FCS_PORT_SM_DELETE = 4, 143 + BFA_FCS_PORT_SM_DELRPORT = 5, 144 + BFA_FCS_PORT_SM_STOP = 6, 145 + }; 146 + 147 + struct bfa_fcs_lport_s; 148 + typedef void (*bfa_fcs_lport_sm_t)(struct bfa_fcs_lport_s *fsm, enum bfa_fcs_lport_event); 185 149 186 150 struct bfa_fcs_lport_s { 187 151 struct list_head qe; /* used by port/vport */ 188 - bfa_sm_t sm; /* state machine */ 152 + bfa_fcs_lport_sm_t sm; /* state machine */ 189 153 struct bfa_fcs_fabric_s *fabric; /* parent fabric */ 190 154 struct bfa_lport_cfg_s port_cfg; /* port configuration */ 191 155 struct bfa_timer_s link_timer; /* timer for link offline */ ··· 237 171 BFA_FCS_FABRIC_LOOP = 3, 238 172 }; 239 173 174 + /* 175 + * Fabric state machine events 176 + */ 177 + enum bfa_fcs_fabric_event { 178 + BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */ 179 + BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */ 180 + BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */ 181 + BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */ 182 + BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */ 183 + BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */ 184 + BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */ 185 + BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */ 186 + BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */ 187 + BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */ 188 + BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */ 189 + BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */ 190 + BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */ 191 + BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */ 192 + BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */ 193 + BFA_FCS_FABRIC_SM_START = 16, /* from driver */ 194 + BFA_FCS_FABRIC_SM_STOP = 17, /* Stop from driver */ 195 + BFA_FCS_FABRIC_SM_STOPCOMP = 18, /* Stop completion */ 196 + BFA_FCS_FABRIC_SM_LOGOCOMP = 19, /* FLOGO completion */ 197 + }; 198 + 199 + struct bfa_fcs_fabric_s; 200 + typedef void (*bfa_fcs_fabric_sm_t)(struct bfa_fcs_fabric_s *fsm, enum bfa_fcs_fabric_event); 240 201 241 202 struct bfa_fcs_fabric_s { 242 203 struct list_head qe; /* queue element */ 243 - bfa_sm_t sm; /* state machine */ 204 + bfa_fcs_fabric_sm_t sm; /* state machine */ 244 205 struct bfa_fcs_s *fcs; /* FCS instance */ 245 206 struct bfa_fcs_lport_s bport; /* base logical port */ 246 207 enum bfa_fcs_fabric_type fab_type; /* fabric type */ ··· 437 344 struct fchs_s *rx_frame, u32 len); 438 345 void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port); 439 346 347 + /* 348 + * VPort State Machine events 349 + */ 350 + enum bfa_fcs_vport_event { 351 + BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */ 352 + BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */ 353 + BFA_FCS_VPORT_SM_START = 3, /* vport start request */ 354 + BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */ 355 + BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */ 356 + BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */ 357 + BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */ 358 + BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */ 359 + BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */ 360 + BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */ 361 + BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */ 362 + BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error*/ 363 + BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */ 364 + BFA_FCS_VPORT_SM_STOPCOMP = 14, /* vport delete completion */ 365 + BFA_FCS_VPORT_SM_FABRIC_MAX = 15, /* max vports on fabric */ 366 + }; 367 + 368 + struct bfa_fcs_vport_s; 369 + typedef void (*bfa_fcs_vport_sm_t)(struct bfa_fcs_vport_s *fsm, enum bfa_fcs_vport_event); 370 + 440 371 struct bfa_fcs_vport_s { 441 372 struct list_head qe; /* queue elem */ 442 - bfa_sm_t sm; /* state machine */ 373 + bfa_fcs_vport_sm_t sm; /* state machine */ 443 374 bfa_fcs_lport_t lport; /* logical port */ 444 375 struct bfa_timer_s timer; 445 376 struct bfad_vport_s *vport_drv; /* Driver private */ ··· 514 397 struct bfa_fcs_tin_s; 515 398 struct bfa_fcs_iprp_s; 516 399 400 + /* 401 + * fcs_rport_ftrs_sm FCS rport state machine events 402 + */ 403 + 404 + enum rpf_event { 405 + RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */ 406 + RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */ 407 + RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */ 408 + RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */ 409 + RPFSM_EVENT_RPSC_COMP = 5, 410 + RPFSM_EVENT_RPSC_FAIL = 6, 411 + RPFSM_EVENT_RPSC_ERROR = 7, 412 + }; 413 + 414 + struct bfa_fcs_rpf_s; 415 + typedef void (*bfa_fcs_rpf_sm_t)(struct bfa_fcs_rpf_s *, enum rpf_event); 416 + 517 417 /* Rport Features (RPF) */ 518 418 struct bfa_fcs_rpf_s { 519 - bfa_sm_t sm; /* state machine */ 419 + bfa_fcs_rpf_sm_t sm; /* state machine */ 520 420 struct bfa_fcs_rport_s *rport; /* parent rport */ 521 421 struct bfa_timer_s timer; /* general purpose timer */ 522 422 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */ ··· 547 413 * not supported by the rport. 548 414 */ 549 415 }; 416 + 417 + /* 418 + * fcs_rport_sm FCS rport state machine events 419 + */ 420 + enum rport_event { 421 + RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */ 422 + RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */ 423 + RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */ 424 + RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */ 425 + RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */ 426 + RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */ 427 + RPSM_EVENT_DELETE = 7, /* RPORT delete request */ 428 + RPSM_EVENT_FAB_SCN = 8, /* state change notification */ 429 + RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */ 430 + RPSM_EVENT_FAILED = 10, /* Request to rport failed. */ 431 + RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */ 432 + RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */ 433 + RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */ 434 + RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */ 435 + RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */ 436 + RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */ 437 + RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */ 438 + RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */ 439 + RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */ 440 + RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */ 441 + RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */ 442 + }; 443 + 444 + struct bfa_fcs_rport_s; 445 + typedef void (*bfa_fcs_rport_sm_t)(struct bfa_fcs_rport_s *, enum rport_event); 550 446 551 447 struct bfa_fcs_rport_s { 552 448 struct list_head qe; /* used by port/vport */ ··· 594 430 wwn_t pwwn; /* port wwn of rport */ 595 431 wwn_t nwwn; /* node wwn of rport */ 596 432 struct bfa_rport_symname_s psym_name; /* port symbolic name */ 597 - bfa_sm_t sm; /* state machine */ 433 + bfa_fcs_rport_sm_t sm; /* state machine */ 598 434 struct bfa_timer_s timer; /* general purpose timer */ 599 435 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */ 600 436 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */ ··· 652 488 void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport); 653 489 654 490 /* 491 + * fcs_itnim_sm FCS itnim state machine events 492 + */ 493 + enum bfa_fcs_itnim_event { 494 + BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */ 495 + BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */ 496 + BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */ 497 + BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */ 498 + BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */ 499 + BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */ 500 + BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */ 501 + BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */ 502 + BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */ 503 + BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */ 504 + BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */ 505 + BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */ 506 + BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */ 507 + }; 508 + 509 + struct bfa_fcs_itnim_s; 510 + typedef void (*bfa_fcs_itnim_sm_t)(struct bfa_fcs_itnim_s *, enum bfa_fcs_itnim_event); 511 + 512 + /* 655 513 * forward declarations 656 514 */ 657 515 struct bfad_itnim_s; 658 516 659 517 struct bfa_fcs_itnim_s { 660 - bfa_sm_t sm; /* state machine */ 518 + bfa_fcs_itnim_sm_t sm; /* state machine */ 661 519 struct bfa_fcs_rport_s *rport; /* parent remote rport */ 662 520 struct bfad_itnim_s *itnim_drv; /* driver peer instance */ 663 521 struct bfa_fcs_s *fcs; /* fcs instance */ ··· 889 703 */ 890 704 891 705 /* 892 - * Fabric state machine events 893 - */ 894 - enum bfa_fcs_fabric_event { 895 - BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */ 896 - BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */ 897 - BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */ 898 - BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */ 899 - BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */ 900 - BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */ 901 - BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */ 902 - BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */ 903 - BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */ 904 - BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */ 905 - BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */ 906 - BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */ 907 - BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */ 908 - BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */ 909 - BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */ 910 - BFA_FCS_FABRIC_SM_START = 16, /* from driver */ 911 - BFA_FCS_FABRIC_SM_STOP = 17, /* Stop from driver */ 912 - BFA_FCS_FABRIC_SM_STOPCOMP = 18, /* Stop completion */ 913 - BFA_FCS_FABRIC_SM_LOGOCOMP = 19, /* FLOGO completion */ 914 - }; 915 - 916 - /* 917 - * fcs_rport_sm FCS rport state machine events 918 - */ 919 - 920 - enum rport_event { 921 - RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */ 922 - RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */ 923 - RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */ 924 - RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */ 925 - RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */ 926 - RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */ 927 - RPSM_EVENT_DELETE = 7, /* RPORT delete request */ 928 - RPSM_EVENT_FAB_SCN = 8, /* state change notification */ 929 - RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */ 930 - RPSM_EVENT_FAILED = 10, /* Request to rport failed. */ 931 - RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */ 932 - RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */ 933 - RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */ 934 - RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */ 935 - RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */ 936 - RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */ 937 - RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */ 938 - RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */ 939 - RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */ 940 - RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */ 941 - RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */ 942 - }; 943 - 944 - /* 945 - * fcs_itnim_sm FCS itnim state machine events 946 - */ 947 - enum bfa_fcs_itnim_event { 948 - BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */ 949 - BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */ 950 - BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */ 951 - BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */ 952 - BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */ 953 - BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */ 954 - BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */ 955 - BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */ 956 - BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */ 957 - BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */ 958 - BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */ 959 - BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */ 960 - BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */ 961 - }; 962 - 963 - /* 964 706 * bfa fcs API functions 965 707 */ 966 708 void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, ··· 945 831 */ 946 832 947 833 struct bfad_port_s; 948 - struct bfad_vf_s; 949 834 struct bfad_vport_s; 950 - struct bfad_rport_s; 951 835 952 836 /* 953 837 * lport callbacks
+20 -3
drivers/scsi/bfa/bfa_fcs_fcpim.c
··· 16 16 #include "bfa_fcs.h" 17 17 #include "bfa_fcbuild.h" 18 18 #include "bfad_im.h" 19 + #include "bfa_fcpim.h" 19 20 20 21 BFA_TRC_FILE(FCS, FCPIM); 21 22 ··· 53 52 static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, 54 53 enum bfa_fcs_itnim_event event); 55 54 56 - static struct bfa_sm_table_s itnim_sm_table[] = { 55 + struct bfa_fcs_itnim_sm_table_s { 56 + bfa_fcs_itnim_sm_t sm; /* state machine function */ 57 + enum bfa_itnim_state state; /* state machine encoding */ 58 + char *name; /* state name for display */ 59 + }; 60 + 61 + static inline enum bfa_itnim_state 62 + bfa_fcs_itnim_sm_to_state(struct bfa_fcs_itnim_sm_table_s *smt, bfa_fcs_itnim_sm_t sm) 63 + { 64 + int i = 0; 65 + 66 + while (smt[i].sm && smt[i].sm != sm) 67 + i++; 68 + return smt[i].state; 69 + } 70 + 71 + static struct bfa_fcs_itnim_sm_table_s itnim_sm_table[] = { 57 72 {BFA_SM(bfa_fcs_itnim_sm_offline), BFA_ITNIM_OFFLINE}, 58 73 {BFA_SM(bfa_fcs_itnim_sm_prli_send), BFA_ITNIM_PRLI_SEND}, 59 74 {BFA_SM(bfa_fcs_itnim_sm_prli), BFA_ITNIM_PRLI_SENT}, ··· 682 665 bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim) 683 666 { 684 667 bfa_trc(itnim->fcs, itnim->rport->pid); 685 - switch (bfa_sm_to_state(itnim_sm_table, itnim->sm)) { 668 + switch (bfa_fcs_itnim_sm_to_state(itnim_sm_table, itnim->sm)) { 686 669 case BFA_ITNIM_ONLINE: 687 670 case BFA_ITNIM_INITIATIOR: 688 671 return BFA_STATUS_OK; ··· 782 765 if (itnim == NULL) 783 766 return BFA_STATUS_NO_FCPIM_NEXUS; 784 767 785 - attr->state = bfa_sm_to_state(itnim_sm_table, itnim->sm); 768 + attr->state = bfa_fcs_itnim_sm_to_state(itnim_sm_table, itnim->sm); 786 769 attr->retry = itnim->seq_rec; 787 770 attr->rec_support = itnim->rec_support; 788 771 attr->conf_comp = itnim->conf_comp;
+18 -94
drivers/scsi/bfa/bfa_fcs_lport.c
··· 103 103 }, 104 104 }; 105 105 106 - /* 107 - * fcs_port_sm FCS logical port state machine 108 - */ 109 - 110 - enum bfa_fcs_lport_event { 111 - BFA_FCS_PORT_SM_CREATE = 1, 112 - BFA_FCS_PORT_SM_ONLINE = 2, 113 - BFA_FCS_PORT_SM_OFFLINE = 3, 114 - BFA_FCS_PORT_SM_DELETE = 4, 115 - BFA_FCS_PORT_SM_DELRPORT = 5, 116 - BFA_FCS_PORT_SM_STOP = 6, 117 - }; 118 - 119 106 static void bfa_fcs_lport_sm_uninit(struct bfa_fcs_lport_s *port, 120 107 enum bfa_fcs_lport_event event); 121 108 static void bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s *port, ··· 1412 1425 /* 1413 1426 * fcs_fdmi_sm FCS FDMI state machine 1414 1427 */ 1415 - 1416 - /* 1417 - * FDMI State Machine events 1418 - */ 1419 - enum port_fdmi_event { 1420 - FDMISM_EVENT_PORT_ONLINE = 1, 1421 - FDMISM_EVENT_PORT_OFFLINE = 2, 1422 - FDMISM_EVENT_RSP_OK = 4, 1423 - FDMISM_EVENT_RSP_ERROR = 5, 1424 - FDMISM_EVENT_TIMEOUT = 6, 1425 - FDMISM_EVENT_RHBA_SENT = 7, 1426 - FDMISM_EVENT_RPRT_SENT = 8, 1427 - FDMISM_EVENT_RPA_SENT = 9, 1428 - }; 1429 1428 1430 1429 static void bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s *fdmi, 1431 1430 enum port_fdmi_event event); ··· 2836 2863 * fcs_ms_sm FCS MS state machine 2837 2864 */ 2838 2865 2839 - /* 2840 - * MS State Machine events 2841 - */ 2842 - enum port_ms_event { 2843 - MSSM_EVENT_PORT_ONLINE = 1, 2844 - MSSM_EVENT_PORT_OFFLINE = 2, 2845 - MSSM_EVENT_RSP_OK = 3, 2846 - MSSM_EVENT_RSP_ERROR = 4, 2847 - MSSM_EVENT_TIMEOUT = 5, 2848 - MSSM_EVENT_FCXP_SENT = 6, 2849 - MSSM_EVENT_PORT_FABRIC_RSCN = 7 2850 - }; 2851 - 2852 2866 static void bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s *ms, 2853 2867 enum port_ms_event event); 2854 2868 static void bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s *ms, ··· 3603 3643 /* 3604 3644 * fcs_ns_sm FCS nameserver interface state machine 3605 3645 */ 3606 - 3607 - /* 3608 - * VPort NS State Machine events 3609 - */ 3610 - enum vport_ns_event { 3611 - NSSM_EVENT_PORT_ONLINE = 1, 3612 - NSSM_EVENT_PORT_OFFLINE = 2, 3613 - NSSM_EVENT_PLOGI_SENT = 3, 3614 - NSSM_EVENT_RSP_OK = 4, 3615 - NSSM_EVENT_RSP_ERROR = 5, 3616 - NSSM_EVENT_TIMEOUT = 6, 3617 - NSSM_EVENT_NS_QUERY = 7, 3618 - NSSM_EVENT_RSPNID_SENT = 8, 3619 - NSSM_EVENT_RFTID_SENT = 9, 3620 - NSSM_EVENT_RFFID_SENT = 10, 3621 - NSSM_EVENT_GIDFT_SENT = 11, 3622 - NSSM_EVENT_RNNID_SENT = 12, 3623 - NSSM_EVENT_RSNN_NN_SENT = 13, 3624 - }; 3625 3646 3626 3647 static void bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s *ns, 3627 3648 enum vport_ns_event event); ··· 5180 5239 * fcs_scm_sm FCS SCN state machine 5181 5240 */ 5182 5241 5183 - /* 5184 - * VPort SCN State Machine events 5185 - */ 5186 - enum port_scn_event { 5187 - SCNSM_EVENT_PORT_ONLINE = 1, 5188 - SCNSM_EVENT_PORT_OFFLINE = 2, 5189 - SCNSM_EVENT_RSP_OK = 3, 5190 - SCNSM_EVENT_RSP_ERROR = 4, 5191 - SCNSM_EVENT_TIMEOUT = 5, 5192 - SCNSM_EVENT_SCR_SENT = 6, 5193 - }; 5194 - 5195 5242 static void bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s *scn, 5196 5243 enum port_scn_event event); 5197 5244 static void bfa_fcs_lport_scn_sm_sending_scr( ··· 5918 5989 * fcs_vport_sm FCS virtual port state machine 5919 5990 */ 5920 5991 5921 - /* 5922 - * VPort State Machine events 5923 - */ 5924 - enum bfa_fcs_vport_event { 5925 - BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */ 5926 - BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */ 5927 - BFA_FCS_VPORT_SM_START = 3, /* vport start request */ 5928 - BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */ 5929 - BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */ 5930 - BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */ 5931 - BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */ 5932 - BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */ 5933 - BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */ 5934 - BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */ 5935 - BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */ 5936 - BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error*/ 5937 - BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */ 5938 - BFA_FCS_VPORT_SM_STOPCOMP = 14, /* vport delete completion */ 5939 - BFA_FCS_VPORT_SM_FABRIC_MAX = 15, /* max vports on fabric */ 5940 - }; 5941 - 5942 5992 static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport, 5943 5993 enum bfa_fcs_vport_event event); 5944 5994 static void bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport, ··· 5945 6037 static void bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s *vport, 5946 6038 enum bfa_fcs_vport_event event); 5947 6039 5948 - static struct bfa_sm_table_s vport_sm_table[] = { 6040 + struct bfa_fcs_vport_sm_table_s { 6041 + bfa_fcs_vport_sm_t sm; /* state machine function */ 6042 + enum bfa_vport_state state; /* state machine encoding */ 6043 + char *name; /* state name for display */ 6044 + }; 6045 + 6046 + static inline enum bfa_vport_state 6047 + bfa_vport_sm_to_state(struct bfa_fcs_vport_sm_table_s *smt, bfa_fcs_vport_sm_t sm) 6048 + { 6049 + int i = 0; 6050 + 6051 + while (smt[i].sm && smt[i].sm != sm) 6052 + i++; 6053 + return smt[i].state; 6054 + } 6055 + 6056 + static struct bfa_fcs_vport_sm_table_s vport_sm_table[] = { 5949 6057 {BFA_SM(bfa_fcs_vport_sm_uninit), BFA_FCS_VPORT_UNINIT}, 5950 6058 {BFA_SM(bfa_fcs_vport_sm_created), BFA_FCS_VPORT_CREATED}, 5951 6059 {BFA_SM(bfa_fcs_vport_sm_offline), BFA_FCS_VPORT_OFFLINE}, ··· 6788 6864 memset(attr, 0, sizeof(struct bfa_vport_attr_s)); 6789 6865 6790 6866 bfa_fcs_lport_get_attr(&vport->lport, &attr->port_attr); 6791 - attr->vport_state = bfa_sm_to_state(vport_sm_table, vport->sm); 6867 + attr->vport_state = bfa_vport_sm_to_state(vport_sm_table, vport->sm); 6792 6868 } 6793 6869 6794 6870
+18 -16
drivers/scsi/bfa/bfa_fcs_rport.c
··· 136 136 static void bfa_fcs_rport_sm_delete_pending(struct bfa_fcs_rport_s *rport, 137 137 enum rport_event event); 138 138 139 - static struct bfa_sm_table_s rport_sm_table[] = { 139 + struct bfa_fcs_rport_sm_table_s { 140 + bfa_fcs_rport_sm_t sm; /* state machine function */ 141 + enum bfa_rport_state state; /* state machine encoding */ 142 + char *name; /* state name for display */ 143 + }; 144 + 145 + static inline enum bfa_rport_state 146 + bfa_rport_sm_to_state(struct bfa_fcs_rport_sm_table_s *smt, bfa_fcs_rport_sm_t sm) 147 + { 148 + int i = 0; 149 + 150 + while (smt[i].sm && smt[i].sm != sm) 151 + i++; 152 + return smt[i].state; 153 + } 154 + 155 + static struct bfa_fcs_rport_sm_table_s rport_sm_table[] = { 140 156 {BFA_SM(bfa_fcs_rport_sm_uninit), BFA_RPORT_UNINIT}, 141 157 {BFA_SM(bfa_fcs_rport_sm_plogi_sending), BFA_RPORT_PLOGI}, 142 158 {BFA_SM(bfa_fcs_rport_sm_plogiacc_sending), BFA_RPORT_ONLINE}, ··· 2980 2964 int 2981 2965 bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport) 2982 2966 { 2983 - return bfa_sm_to_state(rport_sm_table, rport->sm); 2967 + return bfa_rport_sm_to_state(rport_sm_table, rport->sm); 2984 2968 } 2985 2969 2986 2970 ··· 3122 3106 struct fchs_s *rsp_fchs); 3123 3107 3124 3108 static void bfa_fcs_rpf_timeout(void *arg); 3125 - 3126 - /* 3127 - * fcs_rport_ftrs_sm FCS rport state machine events 3128 - */ 3129 - 3130 - enum rpf_event { 3131 - RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */ 3132 - RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */ 3133 - RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */ 3134 - RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */ 3135 - RPFSM_EVENT_RPSC_COMP = 5, 3136 - RPFSM_EVENT_RPSC_FAIL = 6, 3137 - RPFSM_EVENT_RPSC_ERROR = 7, 3138 - }; 3139 3109 3140 3110 static void bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf, 3141 3111 enum rpf_event event);
+36 -49
drivers/scsi/bfa/bfa_ioc.c
··· 114 114 /* 115 115 * IOC state machine definitions/declarations 116 116 */ 117 - enum ioc_event { 118 - IOC_E_RESET = 1, /* IOC reset request */ 119 - IOC_E_ENABLE = 2, /* IOC enable request */ 120 - IOC_E_DISABLE = 3, /* IOC disable request */ 121 - IOC_E_DETACH = 4, /* driver detach cleanup */ 122 - IOC_E_ENABLED = 5, /* f/w enabled */ 123 - IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */ 124 - IOC_E_DISABLED = 7, /* f/w disabled */ 125 - IOC_E_PFFAILED = 8, /* failure notice by iocpf sm */ 126 - IOC_E_HBFAIL = 9, /* heartbeat failure */ 127 - IOC_E_HWERROR = 10, /* hardware error interrupt */ 128 - IOC_E_TIMEOUT = 11, /* timeout */ 129 - IOC_E_HWFAILED = 12, /* PCI mapping failure notice */ 130 - }; 131 - 132 117 bfa_fsm_state_decl(bfa_ioc, uninit, struct bfa_ioc_s, enum ioc_event); 133 118 bfa_fsm_state_decl(bfa_ioc, reset, struct bfa_ioc_s, enum ioc_event); 134 119 bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event); ··· 125 140 bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event); 126 141 bfa_fsm_state_decl(bfa_ioc, hwfail, struct bfa_ioc_s, enum ioc_event); 127 142 128 - static struct bfa_sm_table_s ioc_sm_table[] = { 143 + struct bfa_ioc_sm_table { 144 + bfa_ioc_sm_t sm; /* state machine function */ 145 + enum bfa_ioc_state state; /* state machine encoding */ 146 + char *name; /* state name for display */ 147 + }; 148 + 149 + static struct bfa_ioc_sm_table ioc_sm_table[] = { 129 150 {BFA_SM(bfa_ioc_sm_uninit), BFA_IOC_UNINIT}, 130 151 {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET}, 131 152 {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING}, ··· 143 152 {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED}, 144 153 {BFA_SM(bfa_ioc_sm_hwfail), BFA_IOC_HWFAIL}, 145 154 }; 155 + 156 + static inline enum bfa_ioc_state 157 + bfa_ioc_sm_to_state(struct bfa_ioc_sm_table *smt, bfa_ioc_sm_t sm) 158 + { 159 + int i = 0; 160 + 161 + while (smt[i].sm && smt[i].sm != sm) 162 + i++; 163 + return smt[i].state; 164 + } 146 165 147 166 /* 148 167 * IOCPF state machine definitions/declarations ··· 178 177 static void bfa_iocpf_timeout(void *ioc_arg); 179 178 static void bfa_iocpf_sem_timeout(void *ioc_arg); 180 179 static void bfa_iocpf_poll_timeout(void *ioc_arg); 181 - 182 - /* 183 - * IOCPF state machine events 184 - */ 185 - enum iocpf_event { 186 - IOCPF_E_ENABLE = 1, /* IOCPF enable request */ 187 - IOCPF_E_DISABLE = 2, /* IOCPF disable request */ 188 - IOCPF_E_STOP = 3, /* stop on driver detach */ 189 - IOCPF_E_FWREADY = 4, /* f/w initialization done */ 190 - IOCPF_E_FWRSP_ENABLE = 5, /* enable f/w response */ 191 - IOCPF_E_FWRSP_DISABLE = 6, /* disable f/w response */ 192 - IOCPF_E_FAIL = 7, /* failure notice by ioc sm */ 193 - IOCPF_E_INITFAIL = 8, /* init fail notice by ioc sm */ 194 - IOCPF_E_GETATTRFAIL = 9, /* init fail notice by ioc sm */ 195 - IOCPF_E_SEMLOCKED = 10, /* h/w semaphore is locked */ 196 - IOCPF_E_TIMEOUT = 11, /* f/w response timeout */ 197 - IOCPF_E_SEM_ERROR = 12, /* h/w sem mapping error */ 198 - }; 199 180 200 181 /* 201 182 * IOCPF states ··· 211 228 enum iocpf_event); 212 229 bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event); 213 230 214 - static struct bfa_sm_table_s iocpf_sm_table[] = { 231 + struct bfa_iocpf_sm_table { 232 + bfa_iocpf_sm_t sm; /* state machine function */ 233 + enum bfa_iocpf_state state; /* state machine encoding */ 234 + char *name; /* state name for display */ 235 + }; 236 + 237 + static inline enum bfa_iocpf_state 238 + bfa_iocpf_sm_to_state(struct bfa_iocpf_sm_table *smt, bfa_iocpf_sm_t sm) 239 + { 240 + int i = 0; 241 + 242 + while (smt[i].sm && smt[i].sm != sm) 243 + i++; 244 + return smt[i].state; 245 + } 246 + 247 + static struct bfa_iocpf_sm_table iocpf_sm_table[] = { 215 248 {BFA_SM(bfa_iocpf_sm_reset), BFA_IOCPF_RESET}, 216 249 {BFA_SM(bfa_iocpf_sm_fwcheck), BFA_IOCPF_FWMISMATCH}, 217 250 {BFA_SM(bfa_iocpf_sm_mismatch), BFA_IOCPF_FWMISMATCH}, ··· 2814 2815 bfa_ioc_get_state(struct bfa_ioc_s *ioc) 2815 2816 { 2816 2817 enum bfa_iocpf_state iocpf_st; 2817 - enum bfa_ioc_state ioc_st = bfa_sm_to_state(ioc_sm_table, ioc->fsm); 2818 + enum bfa_ioc_state ioc_st = bfa_ioc_sm_to_state(ioc_sm_table, ioc->fsm); 2818 2819 2819 2820 if (ioc_st == BFA_IOC_ENABLING || 2820 2821 ioc_st == BFA_IOC_FAIL || ioc_st == BFA_IOC_INITFAIL) { 2821 2822 2822 - iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); 2823 + iocpf_st = bfa_iocpf_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm); 2823 2824 2824 2825 switch (iocpf_st) { 2825 2826 case BFA_IOCPF_SEMWAIT: ··· 5803 5804 WARN_ON(1); 5804 5805 } 5805 5806 } 5806 - 5807 - /* 5808 - * DCONF state machine events 5809 - */ 5810 - enum bfa_dconf_event { 5811 - BFA_DCONF_SM_INIT = 1, /* dconf Init */ 5812 - BFA_DCONF_SM_FLASH_COMP = 2, /* read/write to flash */ 5813 - BFA_DCONF_SM_WR = 3, /* binding change, map */ 5814 - BFA_DCONF_SM_TIMEOUT = 4, /* Start timer */ 5815 - BFA_DCONF_SM_EXIT = 5, /* exit dconf module */ 5816 - BFA_DCONF_SM_IOCDISABLE = 6, /* IOC disable event */ 5817 - }; 5818 5807 5819 5808 /* forward declaration of DCONF state machine */ 5820 5809 static void bfa_dconf_sm_uninit(struct bfa_dconf_mod_s *dconf,
+63 -21
drivers/scsi/bfa/bfa_ioc.h
··· 260 260 /* 261 261 * IOC event notification mechanism. 262 262 */ 263 + enum ioc_event { 264 + IOC_E_RESET = 1, /* IOC reset request */ 265 + IOC_E_ENABLE = 2, /* IOC enable request */ 266 + IOC_E_DISABLE = 3, /* IOC disable request */ 267 + IOC_E_DETACH = 4, /* driver detach cleanup */ 268 + IOC_E_ENABLED = 5, /* f/w enabled */ 269 + IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */ 270 + IOC_E_DISABLED = 7, /* f/w disabled */ 271 + IOC_E_PFFAILED = 8, /* failure notice by iocpf sm */ 272 + IOC_E_HBFAIL = 9, /* heartbeat failure */ 273 + IOC_E_HWERROR = 10, /* hardware error interrupt */ 274 + IOC_E_TIMEOUT = 11, /* timeout */ 275 + IOC_E_HWFAILED = 12, /* PCI mapping failure notice */ 276 + }; 277 + 278 + struct bfa_ioc_s; 279 + typedef void (*bfa_ioc_sm_t)(struct bfa_ioc_s *fsm, enum ioc_event); 280 + 263 281 enum bfa_ioc_event_e { 264 282 BFA_IOC_E_ENABLED = 1, 265 283 BFA_IOC_E_DISABLED = 2, ··· 300 282 (__notify)->cbarg = (__cbarg); \ 301 283 } while (0) 302 284 285 + /* 286 + * IOCPF state machine events 287 + */ 288 + enum iocpf_event { 289 + IOCPF_E_ENABLE = 1, /* IOCPF enable request */ 290 + IOCPF_E_DISABLE = 2, /* IOCPF disable request */ 291 + IOCPF_E_STOP = 3, /* stop on driver detach */ 292 + IOCPF_E_FWREADY = 4, /* f/w initialization done */ 293 + IOCPF_E_FWRSP_ENABLE = 5, /* enable f/w response */ 294 + IOCPF_E_FWRSP_DISABLE = 6, /* disable f/w response */ 295 + IOCPF_E_FAIL = 7, /* failure notice by ioc sm */ 296 + IOCPF_E_INITFAIL = 8, /* init fail notice by ioc sm */ 297 + IOCPF_E_GETATTRFAIL = 9, /* init fail notice by ioc sm */ 298 + IOCPF_E_SEMLOCKED = 10, /* h/w semaphore is locked */ 299 + IOCPF_E_TIMEOUT = 11, /* f/w response timeout */ 300 + IOCPF_E_SEM_ERROR = 12, /* h/w sem mapping error */ 301 + }; 302 + 303 + struct bfa_iocpf_s; 304 + typedef void (*bfa_iocpf_sm_t)(struct bfa_iocpf_s *fsm, enum iocpf_event); 305 + 303 306 struct bfa_iocpf_s { 304 - bfa_fsm_t fsm; 307 + bfa_iocpf_sm_t fsm; 305 308 struct bfa_ioc_s *ioc; 306 309 bfa_boolean_t fw_mismatch_notified; 307 310 bfa_boolean_t auto_recover; ··· 330 291 }; 331 292 332 293 struct bfa_ioc_s { 333 - bfa_fsm_t fsm; 294 + bfa_ioc_sm_t fsm; 334 295 struct bfa_s *bfa; 335 296 struct bfa_pcidev_s pcidev; 336 297 struct bfa_timer_mod_s *timer_mod; ··· 400 361 void *cbarg; 401 362 }; 402 363 403 - typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete); 364 + typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete); 365 + typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status); 404 366 405 367 /* 406 368 * Generic BFA callback element. 407 369 */ 408 370 struct bfa_cb_qe_s { 409 371 struct list_head qe; 410 - bfa_cb_cbfn_t cbfn; 372 + union { 373 + bfa_cb_cbfn_status_t cbfn_status; 374 + bfa_cb_cbfn_t cbfn; 375 + }; 411 376 bfa_boolean_t once; 412 377 bfa_boolean_t pre_rmv; /* set for stack based qe(s) */ 413 378 bfa_status_t fw_status; /* to access fw status in comp proc */ 414 379 void *cbarg; 415 - }; 416 - 417 - /* 418 - * IOCFC state machine definitions/declarations 419 - */ 420 - enum iocfc_event { 421 - IOCFC_E_INIT = 1, /* IOCFC init request */ 422 - IOCFC_E_START = 2, /* IOCFC mod start request */ 423 - IOCFC_E_STOP = 3, /* IOCFC stop request */ 424 - IOCFC_E_ENABLE = 4, /* IOCFC enable request */ 425 - IOCFC_E_DISABLE = 5, /* IOCFC disable request */ 426 - IOCFC_E_IOC_ENABLED = 6, /* IOC enabled message */ 427 - IOCFC_E_IOC_DISABLED = 7, /* IOC disabled message */ 428 - IOCFC_E_IOC_FAILED = 8, /* failure notice by IOC sm */ 429 - IOCFC_E_DCONF_DONE = 9, /* dconf read/write done */ 430 - IOCFC_E_CFG_DONE = 10, /* IOCFC config complete */ 431 380 }; 432 381 433 382 /* ··· 802 775 }; 803 776 #pragma pack() 804 777 778 + /* 779 + * DCONF state machine events 780 + */ 781 + enum bfa_dconf_event { 782 + BFA_DCONF_SM_INIT = 1, /* dconf Init */ 783 + BFA_DCONF_SM_FLASH_COMP = 2, /* read/write to flash */ 784 + BFA_DCONF_SM_WR = 3, /* binding change, map */ 785 + BFA_DCONF_SM_TIMEOUT = 4, /* Start timer */ 786 + BFA_DCONF_SM_EXIT = 5, /* exit dconf module */ 787 + BFA_DCONF_SM_IOCDISABLE = 6, /* IOC disable event */ 788 + }; 789 + 790 + struct bfa_dconf_mod_s; 791 + typedef void (*bfa_dconf_sm_t)(struct bfa_dconf_mod_s *fsm, enum bfa_dconf_event); 792 + 805 793 struct bfa_dconf_mod_s { 806 - bfa_sm_t sm; 794 + bfa_dconf_sm_t sm; 807 795 u8 instance; 808 796 bfa_boolean_t read_data_valid; 809 797 bfa_boolean_t min_cfg;
+22 -50
drivers/scsi/bfa/bfa_svc.c
··· 41 41 (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE)) 42 42 43 43 /* 44 - * BFA port state machine events 45 - */ 46 - enum bfa_fcport_sm_event { 47 - BFA_FCPORT_SM_START = 1, /* start port state machine */ 48 - BFA_FCPORT_SM_STOP = 2, /* stop port state machine */ 49 - BFA_FCPORT_SM_ENABLE = 3, /* enable port */ 50 - BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */ 51 - BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */ 52 - BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */ 53 - BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */ 54 - BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */ 55 - BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */ 56 - BFA_FCPORT_SM_DPORTENABLE = 10, /* enable dport */ 57 - BFA_FCPORT_SM_DPORTDISABLE = 11,/* disable dport */ 58 - BFA_FCPORT_SM_FAA_MISCONFIG = 12, /* FAA misconfiguratin */ 59 - BFA_FCPORT_SM_DDPORTENABLE = 13, /* enable ddport */ 60 - BFA_FCPORT_SM_DDPORTDISABLE = 14, /* disable ddport */ 61 - }; 62 - 63 - /* 64 - * BFA port link notification state machine events 65 - */ 66 - 67 - enum bfa_fcport_ln_sm_event { 68 - BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */ 69 - BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */ 70 - BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */ 71 - }; 72 - 73 - /* 74 44 * RPORT related definitions 75 45 */ 76 46 #define bfa_rport_offline_cb(__rp) do { \ ··· 171 201 static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln, 172 202 enum bfa_fcport_ln_sm_event event); 173 203 174 - static struct bfa_sm_table_s hal_port_sm_table[] = { 204 + struct bfa_fcport_sm_table_s { 205 + bfa_fcport_sm_t sm; /* state machine function */ 206 + enum bfa_port_states state; /* state machine encoding */ 207 + char *name; /* state name for display */ 208 + }; 209 + 210 + static inline enum bfa_port_states 211 + bfa_fcport_sm_to_state(struct bfa_fcport_sm_table_s *smt, bfa_fcport_sm_t sm) 212 + { 213 + int i = 0; 214 + 215 + while (smt[i].sm && smt[i].sm != sm) 216 + i++; 217 + return smt[i].state; 218 + } 219 + 220 + static struct bfa_fcport_sm_table_s hal_port_sm_table[] = { 175 221 {BFA_SM(bfa_fcport_sm_uninit), BFA_PORT_ST_UNINIT}, 176 222 {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PORT_ST_ENABLING_QWAIT}, 177 223 {BFA_SM(bfa_fcport_sm_enabling), BFA_PORT_ST_ENABLING}, ··· 3531 3545 fcport->event_arg.i2hmsg = i2hmsg; 3532 3546 3533 3547 bfa_trc(bfa, msg->mhdr.msg_id); 3534 - bfa_trc(bfa, bfa_sm_to_state(hal_port_sm_table, fcport->sm)); 3548 + bfa_trc(bfa, bfa_fcport_sm_to_state(hal_port_sm_table, fcport->sm)); 3535 3549 3536 3550 switch (msg->mhdr.msg_id) { 3537 3551 case BFI_FCPORT_I2H_ENABLE_RSP: ··· 3966 3980 3967 3981 attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa); 3968 3982 attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa); 3969 - attr->port_state = bfa_sm_to_state(hal_port_sm_table, fcport->sm); 3983 + attr->port_state = bfa_fcport_sm_to_state(hal_port_sm_table, fcport->sm); 3970 3984 3971 3985 attr->fec_state = fcport->fec_state; 3972 3986 ··· 4048 4062 { 4049 4063 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); 4050 4064 4051 - return bfa_sm_to_state(hal_port_sm_table, fcport->sm) == 4065 + return bfa_fcport_sm_to_state(hal_port_sm_table, fcport->sm) == 4052 4066 BFA_PORT_ST_DISABLED; 4053 4067 4054 4068 } ··· 4058 4072 { 4059 4073 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); 4060 4074 4061 - return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) == 4075 + return (bfa_fcport_sm_to_state(hal_port_sm_table, fcport->sm) == 4062 4076 BFA_PORT_ST_DPORT); 4063 4077 } 4064 4078 ··· 4067 4081 { 4068 4082 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); 4069 4083 4070 - return (bfa_sm_to_state(hal_port_sm_table, fcport->sm) == 4084 + return (bfa_fcport_sm_to_state(hal_port_sm_table, fcport->sm) == 4071 4085 BFA_PORT_ST_DDPORT); 4072 4086 } 4073 4087 ··· 5625 5639 BFA_DPORT_ST_COMP = 2, /*!< test complete successfully */ 5626 5640 BFA_DPORT_ST_NO_SFP = 3, /*!< sfp is not present */ 5627 5641 BFA_DPORT_ST_NOTSTART = 4, /*!< test not start dport is enabled */ 5628 - }; 5629 - 5630 - /* 5631 - * BFA DPORT state machine events 5632 - */ 5633 - enum bfa_dport_sm_event { 5634 - BFA_DPORT_SM_ENABLE = 1, /* dport enable event */ 5635 - BFA_DPORT_SM_DISABLE = 2, /* dport disable event */ 5636 - BFA_DPORT_SM_FWRSP = 3, /* fw enable/disable rsp */ 5637 - BFA_DPORT_SM_QRESUME = 4, /* CQ space available */ 5638 - BFA_DPORT_SM_HWFAIL = 5, /* IOC h/w failure */ 5639 - BFA_DPORT_SM_START = 6, /* re-start dport test */ 5640 - BFA_DPORT_SM_REQFAIL = 7, /* request failure */ 5641 - BFA_DPORT_SM_SCN = 8, /* state change notify frm fw */ 5642 5642 }; 5643 5643 5644 5644 static void bfa_dport_sm_disabled(struct bfa_dport_s *dport,
+94 -21
drivers/scsi/bfa/bfa_svc.h
··· 226 226 227 227 void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 228 228 229 - 230 - /* 231 - * RPORT related defines 232 - */ 233 - enum bfa_rport_event { 234 - BFA_RPORT_SM_CREATE = 1, /* rport create event */ 235 - BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */ 236 - BFA_RPORT_SM_ONLINE = 3, /* rport is online */ 237 - BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */ 238 - BFA_RPORT_SM_FWRSP = 5, /* firmware response */ 239 - BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */ 240 - BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */ 241 - BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */ 242 - BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */ 243 - }; 244 - 245 229 #define BFA_RPORT_MIN 4 246 230 247 231 struct bfa_rport_mod_s { ··· 269 285 }; 270 286 271 287 /* 288 + * RPORT related defines 289 + */ 290 + enum bfa_rport_event { 291 + BFA_RPORT_SM_CREATE = 1, /* rport create event */ 292 + BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */ 293 + BFA_RPORT_SM_ONLINE = 3, /* rport is online */ 294 + BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */ 295 + BFA_RPORT_SM_FWRSP = 5, /* firmware response */ 296 + BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */ 297 + BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */ 298 + BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */ 299 + BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */ 300 + }; 301 + 302 + struct bfa_rport_s; 303 + typedef void (*bfa_rport_sm_t)(struct bfa_rport_s *, enum bfa_rport_event); 304 + 305 + /* 272 306 * BFA rport data structure 273 307 */ 274 308 struct bfa_rport_s { 275 309 struct list_head qe; /* queue element */ 276 - bfa_sm_t sm; /* state machine */ 310 + bfa_rport_sm_t sm; /* state machine */ 277 311 struct bfa_s *bfa; /* backpointer to BFA */ 278 312 void *rport_drv; /* fcs/driver rport object */ 279 313 u16 fw_handle; /* firmware rport handle */ ··· 380 378 void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw); 381 379 382 380 /* 381 + * lps_pvt BFA LPS private functions 382 + */ 383 + 384 + enum bfa_lps_event { 385 + BFA_LPS_SM_LOGIN = 1, /* login request from user */ 386 + BFA_LPS_SM_LOGOUT = 2, /* logout request from user */ 387 + BFA_LPS_SM_FWRSP = 3, /* f/w response to login/logout */ 388 + BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */ 389 + BFA_LPS_SM_DELETE = 5, /* lps delete from user */ 390 + BFA_LPS_SM_OFFLINE = 6, /* Link is offline */ 391 + BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */ 392 + BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */ 393 + }; 394 + 395 + struct bfa_lps_s; 396 + typedef void (*bfa_lps_sm_t)(struct bfa_lps_s *, enum bfa_lps_event); 397 + 398 + /* 383 399 * LPS - bfa lport login/logout service interface 384 400 */ 385 401 struct bfa_lps_s { 386 402 struct list_head qe; /* queue element */ 387 403 struct bfa_s *bfa; /* parent bfa instance */ 388 - bfa_sm_t sm; /* finite state machine */ 404 + bfa_lps_sm_t sm; /* finite state machine */ 389 405 u8 bfa_tag; /* lport tag */ 390 406 u8 fw_tag; /* lport fw tag */ 391 407 u8 reqq; /* lport request queue */ ··· 460 440 #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port)) 461 441 462 442 /* 443 + * BFA port link notification state machine events 444 + */ 445 + 446 + enum bfa_fcport_ln_sm_event { 447 + BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */ 448 + BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */ 449 + BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */ 450 + }; 451 + 452 + struct bfa_fcport_ln_s; 453 + typedef void (*bfa_fcport_ln_sm_t)(struct bfa_fcport_ln_s *, enum bfa_fcport_ln_sm_event); 454 + 455 + /* 463 456 * Link notification data structure 464 457 */ 465 458 struct bfa_fcport_ln_s { 466 459 struct bfa_fcport_s *fcport; 467 - bfa_sm_t sm; 460 + bfa_fcport_ln_sm_t sm; 468 461 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */ 469 462 enum bfa_port_linkstate ln_event; /* ln event for callback */ 470 463 }; ··· 487 454 }; 488 455 489 456 /* 457 + * BFA port state machine events 458 + */ 459 + enum bfa_fcport_sm_event { 460 + BFA_FCPORT_SM_START = 1, /* start port state machine */ 461 + BFA_FCPORT_SM_STOP = 2, /* stop port state machine */ 462 + BFA_FCPORT_SM_ENABLE = 3, /* enable port */ 463 + BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */ 464 + BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */ 465 + BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */ 466 + BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */ 467 + BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */ 468 + BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */ 469 + BFA_FCPORT_SM_DPORTENABLE = 10, /* enable dport */ 470 + BFA_FCPORT_SM_DPORTDISABLE = 11,/* disable dport */ 471 + BFA_FCPORT_SM_FAA_MISCONFIG = 12, /* FAA misconfiguratin */ 472 + BFA_FCPORT_SM_DDPORTENABLE = 13, /* enable ddport */ 473 + BFA_FCPORT_SM_DDPORTDISABLE = 14, /* disable ddport */ 474 + }; 475 + 476 + struct bfa_fcport_s; 477 + typedef void (*bfa_fcport_sm_t)(struct bfa_fcport_s *, enum bfa_fcport_sm_event); 478 + 479 + /* 490 480 * BFA FC port data structure 491 481 */ 492 482 struct bfa_fcport_s { 493 483 struct bfa_s *bfa; /* parent BFA instance */ 494 - bfa_sm_t sm; /* port state machine */ 484 + bfa_fcport_sm_t sm; /* port state machine */ 495 485 wwn_t nwwn; /* node wwn of physical port */ 496 486 wwn_t pwwn; /* port wwn of physical oprt */ 497 487 enum bfa_port_speed speed_sup; ··· 762 706 u32 status; 763 707 }; 764 708 709 + /* 710 + * BFA DPORT state machine events 711 + */ 712 + enum bfa_dport_sm_event { 713 + BFA_DPORT_SM_ENABLE = 1, /* dport enable event */ 714 + BFA_DPORT_SM_DISABLE = 2, /* dport disable event */ 715 + BFA_DPORT_SM_FWRSP = 3, /* fw enable/disable rsp */ 716 + BFA_DPORT_SM_QRESUME = 4, /* CQ space available */ 717 + BFA_DPORT_SM_HWFAIL = 5, /* IOC h/w failure */ 718 + BFA_DPORT_SM_START = 6, /* re-start dport test */ 719 + BFA_DPORT_SM_REQFAIL = 7, /* request failure */ 720 + BFA_DPORT_SM_SCN = 8, /* state change notify frm fw */ 721 + }; 722 + 723 + struct bfa_dport_s; 724 + typedef void (*bfa_dport_sm_t)(struct bfa_dport_s *, enum bfa_dport_sm_event); 725 + 765 726 struct bfa_dport_s { 766 727 struct bfa_s *bfa; /* Back pointer to BFA */ 767 - bfa_sm_t sm; /* finite state machine */ 728 + bfa_dport_sm_t sm; /* finite state machine */ 768 729 struct bfa_reqq_wait_s reqq_wait; 769 730 bfa_cb_diag_t cbfn; 770 731 void *cbarg;
+4 -7
drivers/scsi/bfa/bfad_bsg.c
··· 2135 2135 struct bfa_cb_pending_q_s cb_qe; 2136 2136 2137 2137 init_completion(&fcomp.comp); 2138 - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, 2139 - &fcomp, &iocmd->stats); 2138 + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats); 2140 2139 spin_lock_irqsave(&bfad->bfad_lock, flags); 2141 2140 iocmd->status = bfa_fcport_get_stats(&bfad->bfa, &cb_qe); 2142 2141 spin_unlock_irqrestore(&bfad->bfad_lock, flags); ··· 2158 2159 struct bfa_cb_pending_q_s cb_qe; 2159 2160 2160 2161 init_completion(&fcomp.comp); 2161 - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, &fcomp, NULL); 2162 + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, NULL); 2162 2163 2163 2164 spin_lock_irqsave(&bfad->bfad_lock, flags); 2164 2165 iocmd->status = bfa_fcport_clear_stats(&bfad->bfa, &cb_qe); ··· 2442 2443 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); 2443 2444 2444 2445 init_completion(&fcomp.comp); 2445 - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, 2446 - &fcomp, &iocmd->stats); 2446 + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, &iocmd->stats); 2447 2447 2448 2448 spin_lock_irqsave(&bfad->bfad_lock, flags); 2449 2449 WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc)); ··· 2472 2474 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa); 2473 2475 2474 2476 init_completion(&fcomp.comp); 2475 - bfa_pending_q_init(&cb_qe, (bfa_cb_cbfn_t)bfad_hcb_comp, 2476 - &fcomp, NULL); 2477 + bfa_pending_q_init_status(&cb_qe, bfad_hcb_comp, &fcomp, NULL); 2477 2478 2478 2479 spin_lock_irqsave(&bfad->bfad_lock, flags); 2479 2480 WARN_ON(!bfa_ioc_get_fcmode(&bfad->bfa.ioc));
+17 -14
drivers/scsi/bfa/bfad_drv.h
··· 175 175 wwn_t wwn[BFA_FCS_MAX_LPORTS]; 176 176 }; 177 177 178 + /* BFAD state machine events */ 179 + enum bfad_sm_event { 180 + BFAD_E_CREATE = 1, 181 + BFAD_E_KTHREAD_CREATE_FAILED = 2, 182 + BFAD_E_INIT = 3, 183 + BFAD_E_INIT_SUCCESS = 4, 184 + BFAD_E_HAL_INIT_FAILED = 5, 185 + BFAD_E_INIT_FAILED = 6, 186 + BFAD_E_FCS_EXIT_COMP = 7, 187 + BFAD_E_EXIT_COMP = 8, 188 + BFAD_E_STOP = 9 189 + }; 190 + 191 + struct bfad_s; 192 + typedef void (*bfad_sm_t)(struct bfad_s *, enum bfad_sm_event); 193 + 178 194 /* 179 195 * BFAD (PCI function) data structure 180 196 */ 181 197 struct bfad_s { 182 - bfa_sm_t sm; /* state machine */ 198 + bfad_sm_t sm; /* state machine */ 183 199 struct list_head list_entry; 184 200 struct bfa_s bfa; 185 201 struct bfa_fcs_s bfa_fcs; ··· 240 224 struct bfa_aen_entry_s aen_list[BFA_AEN_MAX_ENTRY]; 241 225 spinlock_t bfad_aen_spinlock; 242 226 struct list_head vport_list; 243 - }; 244 - 245 - /* BFAD state machine events */ 246 - enum bfad_sm_event { 247 - BFAD_E_CREATE = 1, 248 - BFAD_E_KTHREAD_CREATE_FAILED = 2, 249 - BFAD_E_INIT = 3, 250 - BFAD_E_INIT_SUCCESS = 4, 251 - BFAD_E_HAL_INIT_FAILED = 5, 252 - BFAD_E_INIT_FAILED = 6, 253 - BFAD_E_FCS_EXIT_COMP = 7, 254 - BFAD_E_EXIT_COMP = 8, 255 - BFAD_E_STOP = 9 256 227 }; 257 228 258 229 /*
+15 -12
drivers/scsi/ch.c
··· 113 113 struct scsi_device **dt; /* ptrs to data transfer elements */ 114 114 u_int firsts[CH_TYPES]; 115 115 u_int counts[CH_TYPES]; 116 - u_int unit_attention; 117 116 u_int voltags; 118 117 struct mutex lock; 119 118 } scsi_changer; ··· 185 186 ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, 186 187 void *buffer, unsigned int buflength, enum req_op op) 187 188 { 188 - int errno, retries = 0, timeout, result; 189 + int errno = 0, timeout, result; 189 190 struct scsi_sense_hdr sshdr; 191 + struct scsi_failure failure_defs[] = { 192 + { 193 + .sense = UNIT_ATTENTION, 194 + .asc = SCMD_FAILURE_ASC_ANY, 195 + .ascq = SCMD_FAILURE_ASCQ_ANY, 196 + .allowed = 3, 197 + .result = SAM_STAT_CHECK_CONDITION, 198 + }, 199 + {} 200 + }; 201 + struct scsi_failures failures = { 202 + .failure_definitions = failure_defs, 203 + }; 190 204 const struct scsi_exec_args exec_args = { 191 205 .sshdr = &sshdr, 206 + .failures = &failures, 192 207 }; 193 208 194 209 timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS) 195 210 ? timeout_init : timeout_move; 196 211 197 - retry: 198 - errno = 0; 199 212 result = scsi_execute_cmd(ch->device, cmd, op, buffer, buflength, 200 213 timeout * HZ, MAX_RETRIES, &exec_args); 201 214 if (result < 0) ··· 216 205 if (debug) 217 206 scsi_print_sense_hdr(ch->device, ch->name, &sshdr); 218 207 errno = ch_find_errno(&sshdr); 219 - 220 - switch(sshdr.sense_key) { 221 - case UNIT_ATTENTION: 222 - ch->unit_attention = 1; 223 - if (retries++ < 3) 224 - goto retry; 225 - break; 226 - } 227 208 } 228 209 return errno; 229 210 }
+16 -2
drivers/scsi/csiostor/csio_defs.h
··· 73 73 #define csio_list_prev(elem) (((struct list_head *)(elem))->prev) 74 74 75 75 /* State machine */ 76 - typedef void (*csio_sm_state_t)(void *, uint32_t); 76 + struct csio_lnode; 77 + 78 + /* State machine evets */ 79 + enum csio_ln_ev { 80 + CSIO_LNE_NONE = (uint32_t)0, 81 + CSIO_LNE_LINKUP, 82 + CSIO_LNE_FAB_INIT_DONE, 83 + CSIO_LNE_LINK_DOWN, 84 + CSIO_LNE_DOWN_LINK, 85 + CSIO_LNE_LOGO, 86 + CSIO_LNE_CLOSE, 87 + CSIO_LNE_MAX_EVENT, 88 + }; 89 + 90 + typedef void (*csio_sm_state_t)(struct csio_lnode *ln, enum csio_ln_ev evt); 77 91 78 92 struct csio_sm { 79 93 struct list_head sm_list; ··· 97 83 static inline void 98 84 csio_set_state(void *smp, void *state) 99 85 { 100 - ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t)state; 86 + ((struct csio_sm *)smp)->sm_state = state; 101 87 } 102 88 103 89 static inline void
+4 -4
drivers/scsi/csiostor/csio_lnode.c
··· 1095 1095 int 1096 1096 csio_is_lnode_ready(struct csio_lnode *ln) 1097 1097 { 1098 - return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)); 1098 + return (csio_get_state(ln) == csio_lns_ready); 1099 1099 } 1100 1100 1101 1101 /*****************************************************************************/ ··· 1366 1366 void 1367 1367 csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str) 1368 1368 { 1369 - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) { 1369 + if (csio_get_state(ln) == csio_lns_uninit) { 1370 1370 strcpy(str, "UNINIT"); 1371 1371 return; 1372 1372 } 1373 - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) { 1373 + if (csio_get_state(ln) == csio_lns_ready) { 1374 1374 strcpy(str, "READY"); 1375 1375 return; 1376 1376 } 1377 - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) { 1377 + if (csio_get_state(ln) == csio_lns_offline) { 1378 1378 strcpy(str, "OFFLINE"); 1379 1379 return; 1380 1380 }
-13
drivers/scsi/csiostor/csio_lnode.h
··· 53 53 extern int csio_fcoe_rnodes; 54 54 extern int csio_fdmi_enable; 55 55 56 - /* State machine evets */ 57 - enum csio_ln_ev { 58 - CSIO_LNE_NONE = (uint32_t)0, 59 - CSIO_LNE_LINKUP, 60 - CSIO_LNE_FAB_INIT_DONE, 61 - CSIO_LNE_LINK_DOWN, 62 - CSIO_LNE_DOWN_LINK, 63 - CSIO_LNE_LOGO, 64 - CSIO_LNE_CLOSE, 65 - CSIO_LNE_MAX_EVENT, 66 - }; 67 - 68 - 69 56 struct csio_fcf_info { 70 57 struct list_head list; 71 58 uint8_t priority;
+33 -16
drivers/scsi/device_handler/scsi_dh_hp_sw.c
··· 46 46 int ret = SCSI_DH_IO; 47 47 48 48 switch (sshdr->sense_key) { 49 - case UNIT_ATTENTION: 50 - ret = SCSI_DH_IMM_RETRY; 51 - break; 52 49 case NOT_READY: 53 50 if (sshdr->asc == 0x04 && sshdr->ascq == 2) { 54 51 /* ··· 82 85 int ret, res; 83 86 blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | 84 87 REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; 88 + struct scsi_failure failure_defs[] = { 89 + { 90 + .sense = UNIT_ATTENTION, 91 + .asc = SCMD_FAILURE_ASC_ANY, 92 + .ascq = SCMD_FAILURE_ASCQ_ANY, 93 + .allowed = SCMD_FAILURE_NO_LIMIT, 94 + .result = SAM_STAT_CHECK_CONDITION, 95 + }, 96 + {} 97 + }; 98 + struct scsi_failures failures = { 99 + .failure_definitions = failure_defs, 100 + }; 85 101 const struct scsi_exec_args exec_args = { 86 102 .sshdr = &sshdr, 103 + .failures = &failures, 87 104 }; 88 105 89 - retry: 90 106 res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, 91 107 HP_SW_RETRIES, &exec_args); 92 108 if (res > 0 && scsi_sense_valid(&sshdr)) { ··· 113 103 HP_SW_NAME, res); 114 104 ret = SCSI_DH_IO; 115 105 } 116 - 117 - if (ret == SCSI_DH_IMM_RETRY) 118 - goto retry; 119 106 120 107 return ret; 121 108 } ··· 129 122 struct scsi_sense_hdr sshdr; 130 123 struct scsi_device *sdev = h->sdev; 131 124 int res, rc; 132 - int retry_cnt = HP_SW_RETRIES; 133 125 blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | 134 126 REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; 127 + struct scsi_failure failure_defs[] = { 128 + { 129 + /* 130 + * LUN not ready - manual intervention required 131 + * 132 + * Switch-over in progress, retry. 133 + */ 134 + .sense = NOT_READY, 135 + .asc = 0x04, 136 + .ascq = 0x03, 137 + .allowed = HP_SW_RETRIES, 138 + .result = SAM_STAT_CHECK_CONDITION, 139 + }, 140 + {} 141 + }; 142 + struct scsi_failures failures = { 143 + .failure_definitions = failure_defs, 144 + }; 135 145 const struct scsi_exec_args exec_args = { 136 146 .sshdr = &sshdr, 147 + .failures = &failures, 137 148 }; 138 149 139 - retry: 140 150 res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, 141 151 HP_SW_RETRIES, &exec_args); 142 152 if (!res) { ··· 168 144 switch (sshdr.sense_key) { 169 145 case NOT_READY: 170 146 if (sshdr.asc == 0x04 && sshdr.ascq == 3) { 171 - /* 172 - * LUN not ready - manual intervention required 173 - * 174 - * Switch-over in progress, retry. 175 - */ 176 - if (--retry_cnt) 177 - goto retry; 178 147 rc = SCSI_DH_RETRY; 179 148 break; 180 149 }
+46 -38
drivers/scsi/device_handler/scsi_dh_rdac.c
··· 485 485 static int mode_select_handle_sense(struct scsi_device *sdev, 486 486 struct scsi_sense_hdr *sense_hdr) 487 487 { 488 - int err = SCSI_DH_IO; 489 488 struct rdac_dh_data *h = sdev->handler_data; 490 489 491 490 if (!scsi_sense_valid(sense_hdr)) 492 - goto done; 493 - 494 - switch (sense_hdr->sense_key) { 495 - case NO_SENSE: 496 - case ABORTED_COMMAND: 497 - case UNIT_ATTENTION: 498 - err = SCSI_DH_RETRY; 499 - break; 500 - case NOT_READY: 501 - if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x01) 502 - /* LUN Not Ready and is in the Process of Becoming 503 - * Ready 504 - */ 505 - err = SCSI_DH_RETRY; 506 - break; 507 - case ILLEGAL_REQUEST: 508 - if (sense_hdr->asc == 0x91 && sense_hdr->ascq == 0x36) 509 - /* 510 - * Command Lock contention 511 - */ 512 - err = SCSI_DH_IMM_RETRY; 513 - break; 514 - default: 515 - break; 516 - } 491 + return SCSI_DH_IO; 517 492 518 493 RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " 519 494 "MODE_SELECT returned with sense %02x/%02x/%02x", 520 495 (char *) h->ctlr->array_name, h->ctlr->index, 521 496 sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); 522 497 523 - done: 524 - return err; 498 + return SCSI_DH_IO; 525 499 } 526 500 527 501 static void send_mode_select(struct work_struct *work) ··· 504 530 container_of(work, struct rdac_controller, ms_work); 505 531 struct scsi_device *sdev = ctlr->ms_sdev; 506 532 struct rdac_dh_data *h = sdev->handler_data; 507 - int rc, err, retry_cnt = RDAC_RETRY_COUNT; 533 + int rc, err; 508 534 struct rdac_queue_data *tmp, *qdata; 509 535 LIST_HEAD(list); 510 536 unsigned char cdb[MAX_COMMAND_SIZE]; ··· 512 538 unsigned int data_size; 513 539 blk_opf_t opf = REQ_OP_DRV_OUT | REQ_FAILFAST_DEV | 514 540 REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; 541 + struct scsi_failure failure_defs[] = { 542 + { 543 + .sense = NO_SENSE, 544 + .asc = SCMD_FAILURE_ASC_ANY, 545 + .ascq = SCMD_FAILURE_ASCQ_ANY, 546 + .result = SAM_STAT_CHECK_CONDITION, 547 + }, 548 + { 549 + .sense = ABORTED_COMMAND, 550 + .asc = SCMD_FAILURE_ASC_ANY, 551 + .ascq = SCMD_FAILURE_ASCQ_ANY, 552 + .result = SAM_STAT_CHECK_CONDITION, 553 + }, 554 + { 555 + .sense = UNIT_ATTENTION, 556 + .asc = SCMD_FAILURE_ASC_ANY, 557 + .ascq = SCMD_FAILURE_ASCQ_ANY, 558 + .result = SAM_STAT_CHECK_CONDITION, 559 + }, 560 + /* LUN Not Ready and is in the Process of Becoming Ready */ 561 + { 562 + .sense = NOT_READY, 563 + .asc = 0x04, 564 + .ascq = 0x01, 565 + .result = SAM_STAT_CHECK_CONDITION, 566 + }, 567 + /* Command Lock contention */ 568 + { 569 + .sense = ILLEGAL_REQUEST, 570 + .asc = 0x91, 571 + .ascq = 0x36, 572 + .allowed = SCMD_FAILURE_NO_LIMIT, 573 + .result = SAM_STAT_CHECK_CONDITION, 574 + }, 575 + {} 576 + }; 577 + struct scsi_failures failures = { 578 + .total_allowed = RDAC_RETRY_COUNT, 579 + .failure_definitions = failure_defs, 580 + }; 515 581 const struct scsi_exec_args exec_args = { 516 582 .sshdr = &sshdr, 583 + .failures = &failures, 517 584 }; 518 585 519 586 spin_lock(&ctlr->ms_lock); ··· 563 548 ctlr->ms_sdev = NULL; 564 549 spin_unlock(&ctlr->ms_lock); 565 550 566 - retry: 567 551 memset(cdb, 0, sizeof(cdb)); 568 552 569 553 data_size = rdac_failover_get(ctlr, &list, cdb); 570 554 571 - RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " 572 - "%s MODE_SELECT command", 573 - (char *) h->ctlr->array_name, h->ctlr->index, 574 - (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); 555 + RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, queueing MODE_SELECT command", 556 + (char *)h->ctlr->array_name, h->ctlr->index); 575 557 576 558 rc = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, 577 559 RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args); ··· 582 570 err = SCSI_DH_IO; 583 571 } else { 584 572 err = mode_select_handle_sense(sdev, &sshdr); 585 - if (err == SCSI_DH_RETRY && retry_cnt--) 586 - goto retry; 587 - if (err == SCSI_DH_IMM_RETRY) 588 - goto retry; 589 573 } 590 574 591 575 list_for_each_entry_safe(qdata, tmp, &list, entry) {
+2 -2
drivers/scsi/fcoe/fcoe_sysfs.c
··· 597 597 NULL, 598 598 }; 599 599 600 - static struct bus_type fcoe_bus_type; 600 + static const struct bus_type fcoe_bus_type; 601 601 602 602 static int fcoe_bus_match(struct device *dev, 603 603 struct device_driver *drv) ··· 664 664 }; 665 665 ATTRIBUTE_GROUPS(fcoe_bus); 666 666 667 - static struct bus_type fcoe_bus_type = { 667 + static const struct bus_type fcoe_bus_type = { 668 668 .name = "fcoe", 669 669 .match = &fcoe_bus_match, 670 670 .bus_groups = fcoe_bus_groups,
+3 -4
drivers/scsi/fnic/fnic_attrs.c
··· 14 14 struct fc_lport *lp = shost_priv(class_to_shost(dev)); 15 15 struct fnic *fnic = lport_priv(lp); 16 16 17 - return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]); 17 + return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]); 18 18 } 19 19 20 20 static ssize_t fnic_show_drv_version(struct device *dev, 21 21 struct device_attribute *attr, char *buf) 22 22 { 23 - return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); 23 + return sysfs_emit(buf, "%s\n", DRV_VERSION); 24 24 } 25 25 26 26 static ssize_t fnic_show_link_state(struct device *dev, ··· 28 28 { 29 29 struct fc_lport *lp = shost_priv(class_to_shost(dev)); 30 30 31 - return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up) 32 - ? "Link Up" : "Link Down"); 31 + return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down"); 33 32 } 34 33 35 34 static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
+2 -2
drivers/scsi/fnic/fnic_scsi.c
··· 1961 1961 1962 1962 if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { 1963 1963 spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1964 - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1965 - "Issuing host reset due to out of order IO\n"); 1964 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1965 + "Issuing host reset due to out of order IO\n"); 1966 1966 1967 1967 ret = FAILED; 1968 1968 goto fnic_abort_cmd_end;
+20 -6
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 1507 1507 scsi_block_requests(shost); 1508 1508 hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 100, 5000); 1509 1509 1510 - del_timer_sync(&hisi_hba->timer); 1510 + /* 1511 + * hisi_hba->timer is only used for v1/v2 hw, and check hw->sht 1512 + * which is also only used for v1/v2 hw to skip it for v3 hw 1513 + */ 1514 + if (hisi_hba->hw->sht) 1515 + del_timer_sync(&hisi_hba->timer); 1511 1516 1512 1517 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); 1513 1518 } ··· 1578 1573 return -EPERM; 1579 1574 } 1580 1575 1581 - if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct) 1576 + if (hisi_sas_debugfs_enable) 1582 1577 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba); 1583 1578 1584 1579 return 0; ··· 1966 1961 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); 1967 1962 struct hisi_sas_internal_abort_data *timeout = data; 1968 1963 1969 - if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct) { 1970 - down(&hisi_hba->sem); 1964 + if (hisi_sas_debugfs_enable) { 1965 + /* 1966 + * If timeout occurs in device gone scenario, to avoid 1967 + * circular dependency like: 1968 + * hisi_sas_dev_gone() -> down() -> ... -> 1969 + * hisi_sas_internal_abort_timeout() -> down(). 1970 + */ 1971 + if (!timeout->rst_ha_timeout) 1972 + down(&hisi_hba->sem); 1971 1973 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba); 1972 - up(&hisi_hba->sem); 1974 + if (!timeout->rst_ha_timeout) 1975 + up(&hisi_hba->sem); 1973 1976 } 1974 1977 1975 1978 if (task->task_state_flags & SAS_TASK_STATE_DONE) { ··· 2630 2617 { 2631 2618 sas_release_transport(hisi_sas_stt); 2632 2619 2633 - debugfs_remove(hisi_sas_debugfs_dir); 2620 + if (hisi_sas_debugfs_enable) 2621 + debugfs_remove(hisi_sas_debugfs_dir); 2634 2622 } 2635 2623 2636 2624 module_init(hisi_sas_init);
+5 -3
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 4902 4902 err_out_remove_host: 4903 4903 scsi_remove_host(shost); 4904 4904 err_out_undo_debugfs: 4905 - debugfs_exit_v3_hw(hisi_hba); 4905 + if (hisi_sas_debugfs_enable) 4906 + debugfs_exit_v3_hw(hisi_hba); 4906 4907 err_out_free_host: 4907 4908 hisi_sas_free(hisi_hba); 4908 4909 scsi_host_put(shost); ··· 4935 4934 struct Scsi_Host *shost = sha->shost; 4936 4935 4937 4936 pm_runtime_get_noresume(dev); 4938 - del_timer_sync(&hisi_hba->timer); 4939 4937 4940 4938 sas_unregister_ha(sha); 4941 4939 flush_workqueue(hisi_hba->wq); ··· 4942 4942 4943 4943 hisi_sas_v3_destroy_irqs(pdev, hisi_hba); 4944 4944 hisi_sas_free(hisi_hba); 4945 - debugfs_exit_v3_hw(hisi_hba); 4945 + if (hisi_sas_debugfs_enable) 4946 + debugfs_exit_v3_hw(hisi_hba); 4947 + 4946 4948 scsi_host_put(shost); 4947 4949 } 4948 4950
+1 -1
drivers/scsi/hosts.c
··· 371 371 kfree(shost); 372 372 } 373 373 374 - static struct device_type scsi_host_type = { 374 + static const struct device_type scsi_host_type = { 375 375 .name = "scsi_host", 376 376 .release = scsi_host_dev_release, 377 377 };
+10 -12
drivers/scsi/ibmvscsi/ibmvfc.c
··· 3482 3482 struct Scsi_Host *shost = class_to_shost(dev); 3483 3483 struct ibmvfc_host *vhost = shost_priv(shost); 3484 3484 3485 - return snprintf(buf, PAGE_SIZE, "%s\n", 3486 - vhost->login_buf->resp.partition_name); 3485 + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.partition_name); 3487 3486 } 3488 3487 3489 3488 static ssize_t ibmvfc_show_host_device_name(struct device *dev, ··· 3491 3492 struct Scsi_Host *shost = class_to_shost(dev); 3492 3493 struct ibmvfc_host *vhost = shost_priv(shost); 3493 3494 3494 - return snprintf(buf, PAGE_SIZE, "%s\n", 3495 - vhost->login_buf->resp.device_name); 3495 + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.device_name); 3496 3496 } 3497 3497 3498 3498 static ssize_t ibmvfc_show_host_loc_code(struct device *dev, ··· 3500 3502 struct Scsi_Host *shost = class_to_shost(dev); 3501 3503 struct ibmvfc_host *vhost = shost_priv(shost); 3502 3504 3503 - return snprintf(buf, PAGE_SIZE, "%s\n", 3504 - vhost->login_buf->resp.port_loc_code); 3505 + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.port_loc_code); 3505 3506 } 3506 3507 3507 3508 static ssize_t ibmvfc_show_host_drc_name(struct device *dev, ··· 3509 3512 struct Scsi_Host *shost = class_to_shost(dev); 3510 3513 struct ibmvfc_host *vhost = shost_priv(shost); 3511 3514 3512 - return snprintf(buf, PAGE_SIZE, "%s\n", 3513 - vhost->login_buf->resp.drc_name); 3515 + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.drc_name); 3514 3516 } 3515 3517 3516 3518 static ssize_t ibmvfc_show_host_npiv_version(struct device *dev, ··· 3517 3521 { 3518 3522 struct Scsi_Host *shost = class_to_shost(dev); 3519 3523 struct ibmvfc_host *vhost = shost_priv(shost); 3520 - return snprintf(buf, PAGE_SIZE, "%d\n", be32_to_cpu(vhost->login_buf->resp.version)); 3524 + return sysfs_emit(buf, "%d\n", 3525 + be32_to_cpu(vhost->login_buf->resp.version)); 3521 3526 } 3522 3527 3523 3528 static ssize_t ibmvfc_show_host_capabilities(struct device *dev, ··· 3526 3529 { 3527 3530 struct Scsi_Host *shost = class_to_shost(dev); 3528 3531 struct ibmvfc_host *vhost = shost_priv(shost); 3529 - return snprintf(buf, PAGE_SIZE, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities)); 3532 + return sysfs_emit(buf, "%llx\n", 3533 + be64_to_cpu(vhost->login_buf->resp.capabilities)); 3530 3534 } 3531 3535 3532 3536 /** ··· 3548 3550 int len; 3549 3551 3550 3552 spin_lock_irqsave(shost->host_lock, flags); 3551 - len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->log_level); 3553 + len = sysfs_emit(buf, "%d\n", vhost->log_level); 3552 3554 spin_unlock_irqrestore(shost->host_lock, flags); 3553 3555 return len; 3554 3556 } ··· 3587 3589 int len; 3588 3590 3589 3591 spin_lock_irqsave(shost->host_lock, flags); 3590 - len = snprintf(buf, PAGE_SIZE, "%d\n", scsi->desired_queues); 3592 + len = sysfs_emit(buf, "%d\n", scsi->desired_queues); 3591 3593 spin_unlock_irqrestore(shost->host_lock, flags); 3592 3594 return len; 3593 3595 }
+12 -12
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
··· 1551 1551 if (vscsi->client_data.partition_number == 0) 1552 1552 vscsi->client_data.partition_number = 1553 1553 be32_to_cpu(info->partition_number); 1554 - strncpy(vscsi->client_data.srp_version, info->srp_version, 1554 + strscpy(vscsi->client_data.srp_version, info->srp_version, 1555 1555 sizeof(vscsi->client_data.srp_version)); 1556 - strncpy(vscsi->client_data.partition_name, info->partition_name, 1556 + strscpy(vscsi->client_data.partition_name, info->partition_name, 1557 1557 sizeof(vscsi->client_data.partition_name)); 1558 1558 vscsi->client_data.mad_version = be32_to_cpu(info->mad_version); 1559 1559 vscsi->client_data.os_type = be32_to_cpu(info->os_type); 1560 1560 1561 1561 /* Copy our info */ 1562 - strncpy(info->srp_version, SRP_VERSION, 1563 - sizeof(info->srp_version)); 1564 - strncpy(info->partition_name, vscsi->dds.partition_name, 1565 - sizeof(info->partition_name)); 1562 + strscpy_pad(info->srp_version, SRP_VERSION, 1563 + sizeof(info->srp_version)); 1564 + strscpy_pad(info->partition_name, vscsi->dds.partition_name, 1565 + sizeof(info->partition_name)); 1566 1566 info->partition_number = cpu_to_be32(vscsi->dds.partition_num); 1567 1567 info->mad_version = cpu_to_be32(MAD_VERSION_1); 1568 1568 info->os_type = cpu_to_be32(LINUX); ··· 1645 1645 be64_to_cpu(mad->buffer), 1646 1646 vscsi->dds.window[LOCAL].liobn, token); 1647 1647 if (rc == H_SUCCESS) { 1648 - strncpy(cap->name, dev_name(&vscsi->dma_dev->dev), 1649 - SRP_MAX_LOC_LEN); 1648 + strscpy_pad(cap->name, dev_name(&vscsi->dma_dev->dev), 1649 + sizeof(cap->name)); 1650 1650 1651 1651 len = olen - min_len; 1652 1652 status = VIOSRP_MAD_SUCCESS; ··· 3616 3616 static ssize_t system_id_show(struct device *dev, 3617 3617 struct device_attribute *attr, char *buf) 3618 3618 { 3619 - return snprintf(buf, PAGE_SIZE, "%s\n", system_id); 3619 + return sysfs_emit(buf, "%s\n", system_id); 3620 3620 } 3621 3621 3622 3622 static ssize_t partition_number_show(struct device *dev, 3623 3623 struct device_attribute *attr, char *buf) 3624 3624 { 3625 - return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); 3625 + return sysfs_emit(buf, "%x\n", partition_number); 3626 3626 } 3627 3627 3628 3628 static ssize_t unit_address_show(struct device *dev, ··· 3630 3630 { 3631 3631 struct scsi_info *vscsi = container_of(dev, struct scsi_info, dev); 3632 3632 3633 - return snprintf(buf, PAGE_SIZE, "%x\n", vscsi->dma_dev->unit_address); 3633 + return sysfs_emit(buf, "%x\n", vscsi->dma_dev->unit_address); 3634 3634 } 3635 3635 3636 3636 static int ibmvscsis_get_system_info(void) ··· 3650 3650 3651 3651 name = of_get_property(rootdn, "ibm,partition-name", NULL); 3652 3652 if (name) 3653 - strncpy(partition_name, name, sizeof(partition_name)); 3653 + strscpy(partition_name, name, sizeof(partition_name)); 3654 3654 3655 3655 num = of_get_property(rootdn, "ibm,partition-no", NULL); 3656 3656 if (num)
+1 -1
drivers/scsi/isci/init.c
··· 137 137 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); 138 138 struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha); 139 139 140 - return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id); 140 + return sysfs_emit(buf, "%d\n", ihost->id); 141 141 } 142 142 143 143 static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
+8 -6
drivers/scsi/libfc/fc_encode.h
··· 136 136 break; 137 137 138 138 case FC_NS_RSPN_ID: 139 - len = strnlen(fc_host_symbolic_name(lport->host), 255); 139 + len = strnlen(fc_host_symbolic_name(lport->host), 140 + FC_SYMBOLIC_NAME_SIZE); 140 141 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rspn) + len, 141 142 FC_FST_DIR, FC_NS_SUBTYPE); 142 143 hton24(ct->payload.spn.fr_fid.fp_fid, lport->port_id); 143 - strncpy(ct->payload.spn.fr_name, 144 - fc_host_symbolic_name(lport->host), len); 144 + memcpy(ct->payload.spn.fr_name, 145 + fc_host_symbolic_name(lport->host), len); 145 146 ct->payload.spn.fr_name_len = len; 146 147 break; 147 148 148 149 case FC_NS_RSNN_NN: 149 - len = strnlen(fc_host_symbolic_name(lport->host), 255); 150 + len = strnlen(fc_host_symbolic_name(lport->host), 151 + FC_SYMBOLIC_NAME_SIZE); 150 152 ct = fc_ct_hdr_fill(fp, op, sizeof(struct fc_ns_rsnn) + len, 151 153 FC_FST_DIR, FC_NS_SUBTYPE); 152 154 put_unaligned_be64(lport->wwnn, &ct->payload.snn.fr_wwn); 153 - strncpy(ct->payload.snn.fr_name, 154 - fc_host_symbolic_name(lport->host), len); 155 + memcpy(ct->payload.snn.fr_name, 156 + fc_host_symbolic_name(lport->host), len); 155 157 ct->payload.snn.fr_name_len = len; 156 158 break; 157 159
+51 -43
drivers/scsi/lpfc/lpfc.h
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 535 535 atomic64_t warn; 536 536 }; 537 537 538 + enum lpfc_fc_flag { 539 + /* Several of these flags are HBA centric and should be moved to 540 + * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP) 541 + */ 542 + FC_PT2PT, /* pt2pt with no fabric */ 543 + FC_PT2PT_PLOGI, /* pt2pt initiate PLOGI */ 544 + FC_DISC_TMO, /* Discovery timer running */ 545 + FC_PUBLIC_LOOP, /* Public loop */ 546 + FC_LBIT, /* LOGIN bit in loopinit set */ 547 + FC_RSCN_MODE, /* RSCN cmd rcv'ed */ 548 + FC_NLP_MORE, /* More node to process in node tbl */ 549 + FC_OFFLINE_MODE, /* Interface is offline for diag */ 550 + FC_FABRIC, /* We are fabric attached */ 551 + FC_VPORT_LOGO_RCVD, /* LOGO received on vport */ 552 + FC_RSCN_DISCOVERY, /* Auth all devices after RSCN */ 553 + FC_LOGO_RCVD_DID_CHNG, /* FDISC on phys port detect DID chng */ 554 + FC_PT2PT_NO_NVME, /* Don't send NVME PRLI */ 555 + FC_SCSI_SCAN_TMO, /* scsi scan timer running */ 556 + FC_ABORT_DISCOVERY, /* we want to abort discovery */ 557 + FC_NDISC_ACTIVE, /* NPort discovery active */ 558 + FC_BYPASSED_MODE, /* NPort is in bypassed mode */ 559 + FC_VPORT_NEEDS_REG_VPI, /* Needs to have its vpi registered */ 560 + FC_RSCN_DEFERRED, /* A deferred RSCN being processed */ 561 + FC_VPORT_NEEDS_INIT_VPI, /* Need to INIT_VPI before FDISC */ 562 + FC_VPORT_CVL_RCVD, /* VLink failed due to CVL */ 563 + FC_VFI_REGISTERED, /* VFI is registered */ 564 + FC_FDISC_COMPLETED, /* FDISC completed */ 565 + FC_DISC_DELAYED, /* Delay NPort discovery */ 566 + }; 567 + 568 + enum lpfc_load_flag { 569 + FC_LOADING, /* HBA in process of loading drvr */ 570 + FC_UNLOADING, /* HBA in process of unloading drvr */ 571 + FC_ALLOW_FDMI, /* port is ready for FDMI requests */ 572 + FC_ALLOW_VMID, /* Allow VMID I/Os */ 573 + FC_DEREGISTER_ALL_APP_ID /* Deregister all VMIDs */ 574 + }; 575 + 538 576 struct lpfc_vport { 539 577 struct lpfc_hba *phba; 540 578 struct list_head listentry; ··· 587 549 uint8_t vpi_state; 588 550 #define LPFC_VPI_REGISTERED 0x1 589 551 590 - uint32_t fc_flag; /* FC flags */ 591 - /* Several of these flags are HBA centric and should be moved to 592 - * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP) 593 - */ 594 - #define FC_PT2PT 0x1 /* pt2pt with no fabric */ 595 - #define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */ 596 - #define FC_DISC_TMO 0x4 /* Discovery timer running */ 597 - #define FC_PUBLIC_LOOP 0x8 /* Public loop */ 598 - #define FC_LBIT 0x10 /* LOGIN bit in loopinit set */ 599 - #define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */ 600 - #define FC_NLP_MORE 0x40 /* More node to process in node tbl */ 601 - #define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */ 602 - #define FC_FABRIC 0x100 /* We are fabric attached */ 603 - #define FC_VPORT_LOGO_RCVD 0x200 /* LOGO received on vport */ 604 - #define FC_RSCN_DISCOVERY 0x400 /* Auth all devices after RSCN */ 605 - #define FC_LOGO_RCVD_DID_CHNG 0x800 /* FDISC on phys port detect DID chng*/ 606 - #define FC_PT2PT_NO_NVME 0x1000 /* Don't send NVME PRLI */ 607 - #define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */ 608 - #define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */ 609 - #define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */ 610 - #define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */ 611 - #define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */ 612 - #define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */ 613 - #define FC_VPORT_NEEDS_INIT_VPI 0x200000 /* Need to INIT_VPI before FDISC */ 614 - #define FC_VPORT_CVL_RCVD 0x400000 /* VLink failed due to CVL */ 615 - #define FC_VFI_REGISTERED 0x800000 /* VFI is registered */ 616 - #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */ 617 - #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */ 552 + unsigned long fc_flag; /* FC flags */ 618 553 619 554 uint32_t ct_flags; 620 555 #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */ ··· 598 587 #define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */ 599 588 600 589 struct list_head fc_nodes; 590 + spinlock_t fc_nodes_list_lock; /* spinlock for fc_nodes list */ 601 591 602 592 /* Keep counters for the number of entries in each list. */ 603 - uint16_t fc_plogi_cnt; 604 - uint16_t fc_adisc_cnt; 605 - uint16_t fc_reglogin_cnt; 606 - uint16_t fc_prli_cnt; 607 - uint16_t fc_unmap_cnt; 608 - uint16_t fc_map_cnt; 609 - uint16_t fc_npr_cnt; 610 - uint16_t fc_unused_cnt; 593 + atomic_t fc_plogi_cnt; 594 + atomic_t fc_adisc_cnt; 595 + atomic_t fc_reglogin_cnt; 596 + atomic_t fc_prli_cnt; 597 + atomic_t fc_unmap_cnt; 598 + atomic_t fc_map_cnt; 599 + atomic_t fc_npr_cnt; 600 + atomic_t fc_unused_cnt; 601 + 611 602 struct serv_parm fc_sparam; /* buffer for our service parameters */ 612 603 613 604 uint32_t fc_myDID; /* fibre channel S_ID */ ··· 655 642 struct timer_list els_tmofunc; 656 643 struct timer_list delayed_disc_tmo; 657 644 658 - uint8_t load_flag; 659 - #define FC_LOADING 0x1 /* HBA in process of loading drvr */ 660 - #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */ 661 - #define FC_ALLOW_FDMI 0x4 /* port is ready for FDMI requests */ 662 - #define FC_ALLOW_VMID 0x8 /* Allow VMID I/Os */ 663 - #define FC_DEREGISTER_ALL_APP_ID 0x10 /* Deregister all VMIDs */ 645 + unsigned long load_flag; 664 646 /* Vport Config Parameters */ 665 647 uint32_t cfg_scan_down; 666 648 uint32_t cfg_lun_queue_depth;
+47 -60
drivers/scsi/lpfc/lpfc_attr.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 344 344 struct lpfc_fc4_ctrl_stat *cstat; 345 345 uint64_t data1, data2, data3; 346 346 uint64_t totin, totout, tot; 347 + unsigned long iflags; 347 348 char *statep; 348 349 int i; 349 350 int len = 0; ··· 544 543 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) 545 544 goto buffer_done; 546 545 547 - spin_lock_irq(shost->host_lock); 546 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 548 547 549 548 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 550 549 nrport = NULL; ··· 618 617 if (strlcat(buf, tmp, PAGE_SIZE) >= PAGE_SIZE) 619 618 goto unlock_buf_done; 620 619 } 621 - spin_unlock_irq(shost->host_lock); 620 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 622 621 623 622 if (!lport) 624 623 goto buffer_done; ··· 682 681 goto buffer_done; 683 682 684 683 unlock_buf_done: 685 - spin_unlock_irq(shost->host_lock); 684 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 686 685 687 686 buffer_done: 688 687 len = strnlen(buf, PAGE_SIZE); ··· 1092 1091 break; 1093 1092 } 1094 1093 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { 1095 - if (vport->fc_flag & FC_PUBLIC_LOOP) 1094 + if (test_bit(FC_PUBLIC_LOOP, &vport->fc_flag)) 1096 1095 len += scnprintf(buf + len, PAGE_SIZE-len, 1097 1096 " Public Loop\n"); 1098 1097 else 1099 1098 len += scnprintf(buf + len, PAGE_SIZE-len, 1100 1099 " Private Loop\n"); 1101 1100 } else { 1102 - if (vport->fc_flag & FC_FABRIC) { 1101 + if (test_bit(FC_FABRIC, &vport->fc_flag)) { 1103 1102 if (phba->sli_rev == LPFC_SLI_REV4 && 1104 1103 vport->port_type == LPFC_PHYSICAL_PORT && 1105 1104 phba->sli4_hba.fawwpn_flag & ··· 1261 1260 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1262 1261 1263 1262 return scnprintf(buf, PAGE_SIZE, "%d\n", 1264 - vport->fc_map_cnt + vport->fc_unmap_cnt); 1263 + atomic_read(&vport->fc_map_cnt) + 1264 + atomic_read(&vport->fc_unmap_cnt)); 1265 1265 } 1266 1266 1267 1267 /** ··· 1291 1289 * If the link is offline, disabled or BLOCK_MGMT_IO 1292 1290 * it doesn't make any sense to allow issue_lip 1293 1291 */ 1294 - if ((vport->fc_flag & FC_OFFLINE_MODE) || 1292 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) || 1295 1293 (phba->hba_flag & LINK_DISABLED) || 1296 1294 (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO)) 1297 1295 return -EPERM; ··· 1305 1303 pmboxq->u.mb.mbxCommand = MBX_DOWN_LINK; 1306 1304 pmboxq->u.mb.mbxOwner = OWN_HOST; 1307 1305 1308 - if ((vport->fc_flag & FC_PT2PT) && (vport->fc_flag & FC_PT2PT_NO_NVME)) 1309 - vport->fc_flag &= ~FC_PT2PT_NO_NVME; 1306 + if (test_bit(FC_PT2PT, &vport->fc_flag)) 1307 + clear_bit(FC_PT2PT_NO_NVME, &vport->fc_flag); 1310 1308 1311 1309 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); 1312 1310 ··· 1496 1494 if (shost) { 1497 1495 phba_other = 1498 1496 ((struct lpfc_vport *)shost->hostdata)->phba; 1499 - if (!(phba_other->pport->fc_flag & FC_OFFLINE_MODE)) { 1497 + if (!test_bit(FC_OFFLINE_MODE, 1498 + &phba_other->pport->fc_flag)) { 1500 1499 lpfc_printf_log(phba_other, KERN_INFO, LOG_INIT, 1501 1500 "8349 WWPN = 0x%02x%02x%02x%02x" 1502 1501 "%02x%02x%02x%02x is not " ··· 1552 1549 if (!phba->cfg_enable_hba_reset) 1553 1550 return -EACCES; 1554 1551 1555 - if (!(phba->pport->fc_flag & FC_OFFLINE_MODE)) { 1552 + if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) { 1556 1553 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 1557 1554 1558 1555 if (status != 0) ··· 1691 1688 { 1692 1689 struct completion online_compl; 1693 1690 struct pci_dev *pdev = phba->pcidev; 1694 - uint32_t before_fc_flag; 1691 + unsigned long before_fc_flag; 1695 1692 uint32_t sriov_nr_virtfn; 1696 1693 uint32_t reg_val; 1697 1694 int status = 0, rc = 0; ··· 1762 1759 } 1763 1760 1764 1761 /* keep the original port state */ 1765 - if (before_fc_flag & FC_OFFLINE_MODE) { 1762 + if (test_bit(FC_OFFLINE_MODE, &before_fc_flag)) { 1766 1763 if (phba->fw_dump_cmpl) 1767 1764 phba->fw_dump_cmpl = NULL; 1768 1765 goto out; ··· 2100 2097 *board_mode_str = '\0'; 2101 2098 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, 2102 2099 "3097 Failed \"%s\", status(%d), " 2103 - "fc_flag(x%x)\n", 2100 + "fc_flag(x%lx)\n", 2104 2101 buf, status, phba->pport->fc_flag); 2105 2102 return status; 2106 2103 } ··· 2159 2156 pmb->mbxOwner = OWN_HOST; 2160 2157 pmboxq->ctx_buf = NULL; 2161 2158 2162 - if (phba->pport->fc_flag & FC_OFFLINE_MODE) 2159 + if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 2163 2160 rc = MBX_NOT_FINISHED; 2164 2161 else 2165 2162 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); ··· 3767 3764 static void 3768 3765 lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) 3769 3766 { 3770 - struct Scsi_Host *shost; 3771 3767 struct lpfc_nodelist *ndlp; 3768 + unsigned long iflags; 3772 3769 #if (IS_ENABLED(CONFIG_NVME_FC)) 3773 3770 struct lpfc_nvme_rport *rport; 3774 3771 struct nvme_fc_remote_port *remoteport = NULL; 3775 3772 #endif 3776 3773 3777 - shost = lpfc_shost_from_vport(vport); 3778 - spin_lock_irq(shost->host_lock); 3774 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 3779 3775 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 3780 3776 if (ndlp->rport) 3781 3777 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo; ··· 3789 3787 vport->cfg_devloss_tmo); 3790 3788 #endif 3791 3789 } 3792 - spin_unlock_irq(shost->host_lock); 3790 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 3793 3791 } 3794 3792 3795 3793 /** ··· 3975 3973 static int 3976 3974 lpfc_tgt_queue_depth_set(struct lpfc_vport *vport, uint val) 3977 3975 { 3978 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 3979 3976 struct lpfc_nodelist *ndlp; 3977 + unsigned long iflags; 3980 3978 3981 3979 if (!lpfc_rangecheck(val, LPFC_MIN_TGT_QDEPTH, LPFC_MAX_TGT_QDEPTH)) 3982 3980 return -EINVAL; ··· 3984 3982 if (val == vport->cfg_tgt_queue_depth) 3985 3983 return 0; 3986 3984 3987 - spin_lock_irq(shost->host_lock); 3988 3985 vport->cfg_tgt_queue_depth = val; 3989 3986 3990 3987 /* Next loop thru nodelist and change cmd_qdepth */ 3988 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 3991 3989 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) 3992 3990 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; 3993 - 3994 - spin_unlock_irq(shost->host_lock); 3991 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 3995 3992 return 0; 3996 3993 } 3997 3994 ··· 5236 5235 static int 5237 5236 lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val) 5238 5237 { 5239 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 5240 5238 struct lpfc_nodelist *ndlp, *next_ndlp; 5239 + unsigned long iflags; 5241 5240 5242 5241 if (val == vport->cfg_max_scsicmpl_time) 5243 5242 return 0; ··· 5245 5244 return -EINVAL; 5246 5245 vport->cfg_max_scsicmpl_time = val; 5247 5246 5248 - spin_lock_irq(shost->host_lock); 5247 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 5249 5248 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { 5250 5249 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) 5251 5250 continue; 5252 5251 ndlp->cmd_qdepth = vport->cfg_tgt_queue_depth; 5253 5252 } 5254 - spin_unlock_irq(shost->host_lock); 5253 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 5255 5254 return 0; 5256 5255 } 5257 5256 lpfc_vport_param_store(max_scsicmpl_time); ··· 6201 6200 if (memcmp(buf, LPFC_REG_WRITE_KEY, LPFC_REG_WRITE_KEY_SIZE)) 6202 6201 return -EINVAL; 6203 6202 6204 - if (!(vport->fc_flag & FC_OFFLINE_MODE)) 6203 + if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) 6205 6204 return -EPERM; 6206 6205 6207 6206 spin_lock_irq(&phba->hbalock); ··· 6430 6429 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 6431 6430 struct lpfc_hba *phba = vport->phba; 6432 6431 6433 - spin_lock_irq(shost->host_lock); 6434 - 6435 6432 if (vport->port_type == LPFC_NPIV_PORT) { 6436 6433 fc_host_port_type(shost) = FC_PORTTYPE_NPIV; 6437 6434 } else if (lpfc_is_link_up(phba)) { 6438 6435 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { 6439 - if (vport->fc_flag & FC_PUBLIC_LOOP) 6436 + if (test_bit(FC_PUBLIC_LOOP, &vport->fc_flag)) 6440 6437 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; 6441 6438 else 6442 6439 fc_host_port_type(shost) = FC_PORTTYPE_LPORT; 6443 6440 } else { 6444 - if (vport->fc_flag & FC_FABRIC) 6441 + if (test_bit(FC_FABRIC, &vport->fc_flag)) 6445 6442 fc_host_port_type(shost) = FC_PORTTYPE_NPORT; 6446 6443 else 6447 6444 fc_host_port_type(shost) = FC_PORTTYPE_PTP; 6448 6445 } 6449 6446 } else 6450 6447 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; 6451 - 6452 - spin_unlock_irq(shost->host_lock); 6453 6448 } 6454 6449 6455 6450 /** ··· 6458 6461 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 6459 6462 struct lpfc_hba *phba = vport->phba; 6460 6463 6461 - spin_lock_irq(shost->host_lock); 6462 - 6463 - if (vport->fc_flag & FC_OFFLINE_MODE) 6464 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) 6464 6465 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; 6465 6466 else { 6466 6467 switch (phba->link_state) { ··· 6485 6490 break; 6486 6491 } 6487 6492 } 6488 - 6489 - spin_unlock_irq(shost->host_lock); 6490 6493 } 6491 6494 6492 6495 /** ··· 6496 6503 { 6497 6504 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 6498 6505 struct lpfc_hba *phba = vport->phba; 6499 - 6500 - spin_lock_irq(shost->host_lock); 6501 6506 6502 6507 if ((lpfc_is_link_up(phba)) && (!(phba->hba_flag & HBA_FCOE_MODE))) { 6503 6508 switch(phba->fc_linkspeed) { ··· 6559 6568 } 6560 6569 } else 6561 6570 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 6562 - 6563 - spin_unlock_irq(shost->host_lock); 6564 6571 } 6565 6572 6566 6573 /** ··· 6572 6583 struct lpfc_hba *phba = vport->phba; 6573 6584 u64 node_name; 6574 6585 6575 - spin_lock_irq(shost->host_lock); 6576 - 6577 - if ((vport->port_state > LPFC_FLOGI) && 6578 - ((vport->fc_flag & FC_FABRIC) || 6579 - ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && 6580 - (vport->fc_flag & FC_PUBLIC_LOOP)))) 6586 + if (vport->port_state > LPFC_FLOGI && 6587 + (test_bit(FC_FABRIC, &vport->fc_flag) || 6588 + (phba->fc_topology == LPFC_TOPOLOGY_LOOP && 6589 + test_bit(FC_PUBLIC_LOOP, &vport->fc_flag)))) 6581 6590 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn); 6582 6591 else 6583 6592 /* fabric is local port if there is no F/FL_Port */ 6584 6593 node_name = 0; 6585 - 6586 - spin_unlock_irq(shost->host_lock); 6587 6594 6588 6595 fc_host_fabric_name(shost) = node_name; 6589 6596 } ··· 6631 6646 pmboxq->ctx_buf = NULL; 6632 6647 pmboxq->vport = vport; 6633 6648 6634 - if (vport->fc_flag & FC_OFFLINE_MODE) { 6649 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) { 6635 6650 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); 6636 6651 if (rc != MBX_SUCCESS) { 6637 6652 mempool_free(pmboxq, phba->mbox_mem_pool); ··· 6684 6699 pmboxq->ctx_buf = NULL; 6685 6700 pmboxq->vport = vport; 6686 6701 6687 - if (vport->fc_flag & FC_OFFLINE_MODE) { 6702 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) { 6688 6703 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); 6689 6704 if (rc != MBX_SUCCESS) { 6690 6705 mempool_free(pmboxq, phba->mbox_mem_pool); ··· 6771 6786 pmboxq->ctx_buf = NULL; 6772 6787 pmboxq->vport = vport; 6773 6788 6774 - if ((vport->fc_flag & FC_OFFLINE_MODE) || 6775 - (!(psli->sli_flag & LPFC_SLI_ACTIVE))) { 6789 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) || 6790 + !(psli->sli_flag & LPFC_SLI_ACTIVE)) { 6776 6791 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); 6777 6792 if (rc != MBX_SUCCESS) { 6778 6793 mempool_free(pmboxq, phba->mbox_mem_pool); ··· 6793 6808 pmboxq->ctx_buf = NULL; 6794 6809 pmboxq->vport = vport; 6795 6810 6796 - if ((vport->fc_flag & FC_OFFLINE_MODE) || 6797 - (!(psli->sli_flag & LPFC_SLI_ACTIVE))) { 6811 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) || 6812 + !(psli->sli_flag & LPFC_SLI_ACTIVE)) { 6798 6813 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); 6799 6814 if (rc != MBX_SUCCESS) { 6800 6815 mempool_free(pmboxq, phba->mbox_mem_pool); ··· 6853 6868 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 6854 6869 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 6855 6870 struct lpfc_nodelist *ndlp; 6871 + unsigned long iflags; 6856 6872 6857 - spin_lock_irq(shost->host_lock); 6873 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 6858 6874 /* Search for this, mapped, target ID */ 6859 6875 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 6860 6876 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE && 6861 6877 starget->id == ndlp->nlp_sid) { 6862 - spin_unlock_irq(shost->host_lock); 6878 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, 6879 + iflags); 6863 6880 return ndlp; 6864 6881 } 6865 6882 } 6866 - spin_unlock_irq(shost->host_lock); 6883 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 6867 6884 return NULL; 6868 6885 } 6869 6886
+4 -4
drivers/scsi/lpfc/lpfc_bsg.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2009-2015 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 1977 1977 static int 1978 1978 lpfc_sli4_diag_fcport_reg_setup(struct lpfc_hba *phba) 1979 1979 { 1980 - if (phba->pport->fc_flag & FC_VFI_REGISTERED) { 1980 + if (test_bit(FC_VFI_REGISTERED, &phba->pport->fc_flag)) { 1981 1981 lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, 1982 1982 "3136 Port still had vfi registered: " 1983 1983 "mydid:x%x, fcfi:%d, vfi:%d, vpi:%d\n", ··· 3448 3448 case MBX_RUN_DIAGS: 3449 3449 case MBX_RESTART: 3450 3450 case MBX_SET_MASK: 3451 - if (!(vport->fc_flag & FC_OFFLINE_MODE)) { 3451 + if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) { 3452 3452 lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, 3453 3453 "2743 Command 0x%x is illegal in on-line " 3454 3454 "state\n", ··· 4886 4886 dd_data->context_un.mbox.outExtWLen = mbox_req->outExtWLen; 4887 4887 job->dd_data = dd_data; 4888 4888 4889 - if ((vport->fc_flag & FC_OFFLINE_MODE) || 4889 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag) || 4890 4890 (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE))) { 4891 4891 rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); 4892 4892 if (rc != MBX_SUCCESS) {
+68 -90
drivers/scsi/lpfc/lpfc_ct.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 265 265 kfree(mp); 266 266 ct_exit: 267 267 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS, 268 - "6440 Unsol CT: Rsp err %d Data: x%x\n", 268 + "6440 Unsol CT: Rsp err %d Data: x%lx\n", 269 269 rc, vport->fc_flag); 270 270 } 271 271 ··· 298 298 } 299 299 300 300 /* Ignore traffic received during vport shutdown */ 301 - if (vport->fc_flag & FC_UNLOADING) 301 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 302 302 return; 303 303 304 304 ndlp = lpfc_findnode_did(vport, did); ··· 723 723 724 724 if (ndlp) { 725 725 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 726 - "Parse GID_FTrsp: did:x%x flg:x%x x%x", 726 + "Parse GID_FTrsp: did:x%x flg:x%lx x%x", 727 727 Did, ndlp->nlp_flag, vport->fc_flag); 728 728 729 729 /* By default, the driver expects to support FCP FC4 */ ··· 735 735 736 736 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 737 737 "0238 Process x%06x NameServer Rsp " 738 - "Data: x%x x%x x%x x%x x%x\n", Did, 738 + "Data: x%x x%x x%x x%lx x%x\n", Did, 739 739 ndlp->nlp_flag, ndlp->nlp_fc4_type, 740 740 ndlp->nlp_state, vport->fc_flag, 741 741 vport->fc_rscn_id_cnt); ··· 751 751 } 752 752 } else { 753 753 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 754 - "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d", 754 + "Skip1 GID_FTrsp: did:x%x flg:x%lx cnt:%d", 755 755 Did, vport->fc_flag, vport->fc_rscn_id_cnt); 756 756 757 757 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 758 758 "0239 Skip x%06x NameServer Rsp " 759 - "Data: x%x x%x x%px\n", 759 + "Data: x%lx x%x x%px\n", 760 760 Did, vport->fc_flag, 761 761 vport->fc_rscn_id_cnt, ndlp); 762 762 } 763 763 } else { 764 - if (!(vport->fc_flag & FC_RSCN_MODE) || 764 + if (!test_bit(FC_RSCN_MODE, &vport->fc_flag) || 765 765 lpfc_rscn_payload_check(vport, Did)) { 766 766 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 767 - "Query GID_FTrsp: did:x%x flg:x%x cnt:%d", 767 + "Query GID_FTrsp: did:x%x flg:x%lx cnt:%d", 768 768 Did, vport->fc_flag, vport->fc_rscn_id_cnt); 769 769 770 770 /* ··· 787 787 lpfc_setup_disc_node(vport, Did); 788 788 } else { 789 789 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 790 - "Skip2 GID_FTrsp: did:x%x flg:x%x cnt:%d", 790 + "Skip2 GID_FTrsp: did:x%x flg:x%lx cnt:%d", 791 791 Did, vport->fc_flag, vport->fc_rscn_id_cnt); 792 792 793 793 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 794 794 "0245 Skip x%06x NameServer Rsp " 795 - "Data: x%x x%x\n", Did, 795 + "Data: x%lx x%x\n", Did, 796 796 vport->fc_flag, 797 797 vport->fc_rscn_id_cnt); 798 798 } ··· 914 914 struct lpfc_iocbq *rspiocb) 915 915 { 916 916 struct lpfc_vport *vport = cmdiocb->vport; 917 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 918 917 struct lpfc_dmabuf *outp; 919 918 struct lpfc_dmabuf *inp; 920 919 struct lpfc_sli_ct_request *CTrsp; ··· 942 943 goto out; 943 944 } 944 945 945 - /* Don't bother processing response if vport is being torn down. */ 946 - if (vport->load_flag & FC_UNLOADING) { 947 - if (vport->fc_flag & FC_RSCN_MODE) 946 + /* Skip processing response on pport if unloading */ 947 + if (vport == phba->pport && test_bit(FC_UNLOADING, &vport->load_flag)) { 948 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 948 949 lpfc_els_flush_rscn(vport); 949 950 goto out; 950 951 } ··· 952 953 if (lpfc_els_chk_latt(vport)) { 953 954 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 954 955 "0216 Link event during NS query\n"); 955 - if (vport->fc_flag & FC_RSCN_MODE) 956 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 956 957 lpfc_els_flush_rscn(vport); 957 958 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 958 959 goto out; ··· 960 961 if (lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { 961 962 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 962 963 "0226 NS query failed due to link event: " 963 - "ulp_status x%x ulp_word4 x%x fc_flag x%x " 964 + "ulp_status x%x ulp_word4 x%x fc_flag x%lx " 964 965 "port_state x%x gidft_inp x%x\n", 965 966 ulp_status, ulp_word4, vport->fc_flag, 966 967 vport->port_state, vport->gidft_inp); 967 - if (vport->fc_flag & FC_RSCN_MODE) 968 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 968 969 lpfc_els_flush_rscn(vport); 969 970 if (vport->gidft_inp) 970 971 vport->gidft_inp--; 971 972 goto out; 972 973 } 973 974 974 - spin_lock_irq(shost->host_lock); 975 - if (vport->fc_flag & FC_RSCN_DEFERRED) { 976 - vport->fc_flag &= ~FC_RSCN_DEFERRED; 977 - spin_unlock_irq(shost->host_lock); 978 - 975 + if (test_and_clear_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) { 979 976 /* This is a GID_FT completing so the gidft_inp counter was 980 977 * incremented before the GID_FT was issued to the wire. 981 978 */ ··· 983 988 * Re-issue the NS cmd 984 989 */ 985 990 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 986 - "0151 Process Deferred RSCN Data: x%x x%x\n", 991 + "0151 Process Deferred RSCN Data: x%lx x%x\n", 987 992 vport->fc_flag, vport->fc_rscn_id_cnt); 988 993 lpfc_els_handle_rscn(vport); 989 994 990 995 goto out; 991 996 } 992 - spin_unlock_irq(shost->host_lock); 993 997 994 998 if (ulp_status) { 995 999 /* Check for retry */ ··· 1012 1018 vport->gidft_inp--; 1013 1019 } 1014 1020 } 1015 - if (vport->fc_flag & FC_RSCN_MODE) 1021 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 1016 1022 lpfc_els_flush_rscn(vport); 1017 1023 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1018 1024 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 1025 1031 if (CTrsp->CommandResponse.bits.CmdRsp == 1026 1032 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) { 1027 1033 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1028 - "0208 NameServer Rsp Data: x%x x%x " 1034 + "0208 NameServer Rsp Data: x%lx x%x " 1029 1035 "x%x x%x sz x%x\n", 1030 1036 vport->fc_flag, 1031 1037 CTreq->un.gid.Fc4Type, ··· 1045 1051 lpfc_printf_vlog(vport, KERN_INFO, 1046 1052 LOG_DISCOVERY, 1047 1053 "0269 No NameServer Entries " 1048 - "Data: x%x x%x x%x x%x\n", 1054 + "Data: x%x x%x x%x x%lx\n", 1049 1055 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1050 1056 (uint32_t) CTrsp->ReasonCode, 1051 1057 (uint32_t) CTrsp->Explanation, ··· 1060 1066 lpfc_printf_vlog(vport, KERN_INFO, 1061 1067 LOG_DISCOVERY, 1062 1068 "0240 NameServer Rsp Error " 1063 - "Data: x%x x%x x%x x%x\n", 1069 + "Data: x%x x%x x%x x%lx\n", 1064 1070 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1065 1071 (uint32_t) CTrsp->ReasonCode, 1066 1072 (uint32_t) CTrsp->Explanation, ··· 1078 1084 /* NameServer Rsp Error */ 1079 1085 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1080 1086 "0241 NameServer Rsp Error " 1081 - "Data: x%x x%x x%x x%x\n", 1087 + "Data: x%x x%x x%x x%lx\n", 1082 1088 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1083 1089 (uint32_t) CTrsp->ReasonCode, 1084 1090 (uint32_t) CTrsp->Explanation, ··· 1107 1113 * current driver state. 1108 1114 */ 1109 1115 if (vport->port_state >= LPFC_DISC_AUTH) { 1110 - if (vport->fc_flag & FC_RSCN_MODE) { 1116 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 1111 1117 lpfc_els_flush_rscn(vport); 1112 - spin_lock_irq(shost->host_lock); 1113 - vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ 1114 - spin_unlock_irq(shost->host_lock); 1118 + /* RSCN still */ 1119 + set_bit(FC_RSCN_MODE, &vport->fc_flag); 1120 + } else { 1121 + lpfc_els_flush_rscn(vport); 1115 1122 } 1116 - else 1117 - lpfc_els_flush_rscn(vport); 1118 1123 } 1119 1124 1120 1125 lpfc_disc_start(vport); ··· 1129 1136 struct lpfc_iocbq *rspiocb) 1130 1137 { 1131 1138 struct lpfc_vport *vport = cmdiocb->vport; 1132 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1133 1139 struct lpfc_dmabuf *outp; 1134 1140 struct lpfc_dmabuf *inp; 1135 1141 struct lpfc_sli_ct_request *CTrsp; ··· 1158 1166 goto out; 1159 1167 } 1160 1168 1161 - /* Don't bother processing response if vport is being torn down. */ 1162 - if (vport->load_flag & FC_UNLOADING) { 1163 - if (vport->fc_flag & FC_RSCN_MODE) 1169 + /* Skip processing response on pport if unloading */ 1170 + if (vport == phba->pport && test_bit(FC_UNLOADING, &vport->load_flag)) { 1171 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 1164 1172 lpfc_els_flush_rscn(vport); 1165 1173 goto out; 1166 1174 } ··· 1168 1176 if (lpfc_els_chk_latt(vport)) { 1169 1177 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1170 1178 "4108 Link event during NS query\n"); 1171 - if (vport->fc_flag & FC_RSCN_MODE) 1179 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 1172 1180 lpfc_els_flush_rscn(vport); 1173 1181 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1174 1182 goto out; ··· 1176 1184 if (lpfc_error_lost_link(vport, ulp_status, ulp_word4)) { 1177 1185 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1178 1186 "4166 NS query failed due to link event: " 1179 - "ulp_status x%x ulp_word4 x%x fc_flag x%x " 1187 + "ulp_status x%x ulp_word4 x%x fc_flag x%lx " 1180 1188 "port_state x%x gidft_inp x%x\n", 1181 1189 ulp_status, ulp_word4, vport->fc_flag, 1182 1190 vport->port_state, vport->gidft_inp); 1183 - if (vport->fc_flag & FC_RSCN_MODE) 1191 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 1184 1192 lpfc_els_flush_rscn(vport); 1185 1193 if (vport->gidft_inp) 1186 1194 vport->gidft_inp--; 1187 1195 goto out; 1188 1196 } 1189 1197 1190 - spin_lock_irq(shost->host_lock); 1191 - if (vport->fc_flag & FC_RSCN_DEFERRED) { 1192 - vport->fc_flag &= ~FC_RSCN_DEFERRED; 1193 - spin_unlock_irq(shost->host_lock); 1194 - 1198 + if (test_and_clear_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) { 1195 1199 /* This is a GID_PT completing so the gidft_inp counter was 1196 1200 * incremented before the GID_PT was issued to the wire. 1197 1201 */ ··· 1199 1211 * Re-issue the NS cmd 1200 1212 */ 1201 1213 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 1202 - "4167 Process Deferred RSCN Data: x%x x%x\n", 1214 + "4167 Process Deferred RSCN Data: x%lx x%x\n", 1203 1215 vport->fc_flag, vport->fc_rscn_id_cnt); 1204 1216 lpfc_els_handle_rscn(vport); 1205 1217 1206 1218 goto out; 1207 1219 } 1208 - spin_unlock_irq(shost->host_lock); 1209 1220 1210 1221 if (ulp_status) { 1211 1222 /* Check for retry */ ··· 1224 1237 vport->gidft_inp--; 1225 1238 } 1226 1239 } 1227 - if (vport->fc_flag & FC_RSCN_MODE) 1240 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) 1228 1241 lpfc_els_flush_rscn(vport); 1229 1242 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1230 1243 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 1237 1250 if (be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp) == 1238 1251 SLI_CT_RESPONSE_FS_ACC) { 1239 1252 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1240 - "4105 NameServer Rsp Data: x%x x%x " 1253 + "4105 NameServer Rsp Data: x%lx x%x " 1241 1254 "x%x x%x sz x%x\n", 1242 1255 vport->fc_flag, 1243 1256 CTreq->un.gid.Fc4Type, ··· 1257 1270 lpfc_printf_vlog( 1258 1271 vport, KERN_INFO, LOG_DISCOVERY, 1259 1272 "4106 No NameServer Entries " 1260 - "Data: x%x x%x x%x x%x\n", 1273 + "Data: x%x x%x x%x x%lx\n", 1261 1274 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1262 1275 (uint32_t)CTrsp->ReasonCode, 1263 1276 (uint32_t)CTrsp->Explanation, ··· 1273 1286 lpfc_printf_vlog( 1274 1287 vport, KERN_INFO, LOG_DISCOVERY, 1275 1288 "4107 NameServer Rsp Error " 1276 - "Data: x%x x%x x%x x%x\n", 1289 + "Data: x%x x%x x%x x%lx\n", 1277 1290 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1278 1291 (uint32_t)CTrsp->ReasonCode, 1279 1292 (uint32_t)CTrsp->Explanation, ··· 1290 1303 /* NameServer Rsp Error */ 1291 1304 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1292 1305 "4109 NameServer Rsp Error " 1293 - "Data: x%x x%x x%x x%x\n", 1306 + "Data: x%x x%x x%x x%lx\n", 1294 1307 be16_to_cpu(CTrsp->CommandResponse.bits.CmdRsp), 1295 1308 (uint32_t)CTrsp->ReasonCode, 1296 1309 (uint32_t)CTrsp->Explanation, ··· 1320 1333 * current driver state. 1321 1334 */ 1322 1335 if (vport->port_state >= LPFC_DISC_AUTH) { 1323 - if (vport->fc_flag & FC_RSCN_MODE) { 1336 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 1324 1337 lpfc_els_flush_rscn(vport); 1325 - spin_lock_irq(shost->host_lock); 1326 - vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ 1327 - spin_unlock_irq(shost->host_lock); 1338 + /* RSCN still */ 1339 + set_bit(FC_RSCN_MODE, &vport->fc_flag); 1328 1340 } else { 1329 1341 lpfc_els_flush_rscn(vport); 1330 1342 } ··· 1341 1355 struct lpfc_iocbq *rspiocb) 1342 1356 { 1343 1357 struct lpfc_vport *vport = cmdiocb->vport; 1344 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1345 1358 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf; 1346 1359 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf; 1347 1360 struct lpfc_sli_ct_request *CTrsp; ··· 1430 1445 } 1431 1446 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1432 1447 "0267 NameServer GFF Rsp " 1433 - "x%x Error (%d %d) Data: x%x x%x\n", 1448 + "x%x Error (%d %d) Data: x%lx x%x\n", 1434 1449 did, ulp_status, ulp_word4, 1435 1450 vport->fc_flag, vport->fc_rscn_id_cnt); 1436 1451 } ··· 1440 1455 if (ndlp) { 1441 1456 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1442 1457 "0242 Process x%x GFF " 1443 - "NameServer Rsp Data: x%x x%x x%x\n", 1458 + "NameServer Rsp Data: x%x x%lx x%x\n", 1444 1459 did, ndlp->nlp_flag, vport->fc_flag, 1445 1460 vport->fc_rscn_id_cnt); 1446 1461 } else { 1447 1462 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1448 1463 "0243 Skip x%x GFF " 1449 - "NameServer Rsp Data: x%x x%x\n", did, 1464 + "NameServer Rsp Data: x%lx x%x\n", did, 1450 1465 vport->fc_flag, vport->fc_rscn_id_cnt); 1451 1466 } 1452 1467 out: ··· 1465 1480 * current driver state. 1466 1481 */ 1467 1482 if (vport->port_state >= LPFC_DISC_AUTH) { 1468 - if (vport->fc_flag & FC_RSCN_MODE) { 1483 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 1469 1484 lpfc_els_flush_rscn(vport); 1470 - spin_lock_irq(shost->host_lock); 1471 - vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */ 1472 - spin_unlock_irq(shost->host_lock); 1485 + /* RSCN still */ 1486 + set_bit(FC_RSCN_MODE, &vport->fc_flag); 1487 + } else { 1488 + lpfc_els_flush_rscn(vport); 1473 1489 } 1474 - else 1475 - lpfc_els_flush_rscn(vport); 1476 1490 } 1477 1491 lpfc_disc_start(vport); 1478 1492 } ··· 1837 1853 lpfc_find_map_node(struct lpfc_vport *vport) 1838 1854 { 1839 1855 struct lpfc_nodelist *ndlp, *next_ndlp; 1840 - struct Scsi_Host *shost; 1856 + unsigned long iflags; 1841 1857 uint32_t cnt = 0; 1842 1858 1843 - shost = lpfc_shost_from_vport(vport); 1844 - spin_lock_irq(shost->host_lock); 1859 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 1845 1860 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { 1846 1861 if (ndlp->nlp_type & NLP_FABRIC) 1847 1862 continue; ··· 1848 1865 (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE)) 1849 1866 cnt++; 1850 1867 } 1851 - spin_unlock_irq(shost->host_lock); 1868 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 1852 1869 return cnt; 1853 1870 } 1854 1871 ··· 1933 1950 1934 1951 /* NameServer Req */ 1935 1952 lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY, 1936 - "0236 NameServer Req Data: x%x x%x x%x x%x\n", 1953 + "0236 NameServer Req Data: x%x x%lx x%x x%x\n", 1937 1954 cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt, 1938 1955 context); 1939 1956 ··· 2150 2167 kfree(mp); 2151 2168 ns_cmd_exit: 2152 2169 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 2153 - "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", 2170 + "0266 Issue NameServer Req x%x err %d Data: x%lx " 2171 + "x%x\n", 2154 2172 cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt); 2155 2173 return 1; 2156 2174 } ··· 2437 2453 return; 2438 2454 2439 2455 /* Must be connected to a Fabric */ 2440 - if (!(vport->fc_flag & FC_FABRIC)) 2456 + if (!test_bit(FC_FABRIC, &vport->fc_flag)) 2441 2457 return; 2442 2458 2443 2459 ndlp = lpfc_findnode_did(vport, FDMI_DID); ··· 2553 2569 * 64 bytes or less. 2554 2570 */ 2555 2571 2556 - strncpy(ae->value_string, attrstring, sizeof(ae->value_string)); 2572 + strscpy(ae->value_string, attrstring, sizeof(ae->value_string)); 2557 2573 len = strnlen(ae->value_string, sizeof(ae->value_string)); 2558 - /* round string length to a 32bit boundary. Ensure there's a NULL */ 2574 + /* round string length to a 32bit boundary */ 2559 2575 len += (len & 3) ? (4 - (len & 3)) : 4; 2560 2576 /* size is Type/Len (4 bytes) plus string length */ 2561 2577 size = FOURBYTES + len; ··· 3217 3233 3218 3234 /* FDMI request */ 3219 3235 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 3220 - "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n", 3236 + "0218 FDMI Request x%x mask x%x Data: x%x x%lx x%x\n", 3221 3237 cmdcode, new_mask, vport->fdmi_port_mask, 3222 3238 vport->fc_flag, vport->port_state); 3223 3239 ··· 3454 3470 void 3455 3471 lpfc_delayed_disc_timeout_handler(struct lpfc_vport *vport) 3456 3472 { 3457 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 3458 - 3459 - spin_lock_irq(shost->host_lock); 3460 - if (!(vport->fc_flag & FC_DISC_DELAYED)) { 3461 - spin_unlock_irq(shost->host_lock); 3473 + if (!test_and_clear_bit(FC_DISC_DELAYED, &vport->fc_flag)) 3462 3474 return; 3463 - } 3464 - vport->fc_flag &= ~FC_DISC_DELAYED; 3465 - spin_unlock_irq(shost->host_lock); 3466 3475 3467 3476 lpfc_do_scr_ns_plogi(vport->phba, vport); 3468 3477 } ··· 3583 3606 (ctrsp->Explanation != SLI_CT_APP_ID_NOT_AVAILABLE)) { 3584 3607 /* If DALLAPP_ID failed retry later */ 3585 3608 if (cmd == SLI_CTAS_DALLAPP_ID) 3586 - vport->load_flag |= FC_DEREGISTER_ALL_APP_ID; 3609 + set_bit(FC_DEREGISTER_ALL_APP_ID, 3610 + &vport->load_flag); 3587 3611 goto free_res; 3588 3612 } 3589 3613 } ··· 3640 3662 if (!hash_empty(vport->hash_table)) 3641 3663 hash_for_each(vport->hash_table, bucket, cur, hnode) 3642 3664 hash_del(&cur->hnode); 3643 - vport->load_flag |= FC_ALLOW_VMID; 3665 + set_bit(FC_ALLOW_VMID, &vport->load_flag); 3644 3666 break; 3645 3667 default: 3646 3668 lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY, ··· 3707 3729 INIT_LIST_HEAD(&bmp->list); 3708 3730 3709 3731 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 3710 - "3275 VMID Request Data: x%x x%x x%x\n", 3732 + "3275 VMID Request Data: x%lx x%x x%x\n", 3711 3733 vport->fc_flag, vport->port_state, cmdcode); 3712 3734 ctreq = (struct lpfc_sli_ct_request *)mp->virt; 3713 3735 data = mp->virt;
+6 -8
drivers/scsi/lpfc/lpfc_debugfs.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2007-2015 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 806 806 { 807 807 int len = 0; 808 808 int i, iocnt, outio, cnt; 809 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 810 809 struct lpfc_hba *phba = vport->phba; 811 810 struct lpfc_nodelist *ndlp; 812 811 unsigned char *statep; 812 + unsigned long iflags; 813 813 struct nvme_fc_local_port *localport; 814 814 struct nvme_fc_remote_port *nrport = NULL; 815 815 struct lpfc_nvme_rport *rport; ··· 818 818 outio = 0; 819 819 820 820 len += scnprintf(buf+len, size-len, "\nFCP Nodelist Entries ...\n"); 821 - spin_lock_irq(shost->host_lock); 821 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 822 822 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 823 823 iocnt = 0; 824 824 if (!cnt) { ··· 908 908 ndlp->nlp_defer_did); 909 909 len += scnprintf(buf+len, size-len, "\n"); 910 910 } 911 - spin_unlock_irq(shost->host_lock); 911 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 912 912 913 913 len += scnprintf(buf + len, size - len, 914 914 "\nOutstanding IO x%x\n", outio); ··· 940 940 if (!localport) 941 941 goto out_exit; 942 942 943 - spin_lock_irq(shost->host_lock); 944 - 945 943 /* Port state is only one of two values for now. */ 946 944 if (localport->port_id) 947 945 statep = "ONLINE"; ··· 951 953 localport->port_id, statep); 952 954 953 955 len += scnprintf(buf + len, size - len, "\tRport List:\n"); 956 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 954 957 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 955 958 /* local short-hand pointer. */ 956 959 spin_lock(&ndlp->lock); ··· 1005 1006 /* Terminate the string. */ 1006 1007 len += scnprintf(buf + len, size - len, "\n"); 1007 1008 } 1008 - 1009 - spin_unlock_irq(shost->host_lock); 1009 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 1010 1010 out_exit: 1011 1011 return len; 1012 1012 }
+192 -254
drivers/scsi/lpfc/lpfc_els.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 93 93 int 94 94 lpfc_els_chk_latt(struct lpfc_vport *vport) 95 95 { 96 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 97 96 struct lpfc_hba *phba = vport->phba; 98 97 uint32_t ha_copy; 99 98 ··· 120 121 * will cleanup any left over in-progress discovery 121 122 * events. 122 123 */ 123 - spin_lock_irq(shost->host_lock); 124 - vport->fc_flag |= FC_ABORT_DISCOVERY; 125 - spin_unlock_irq(shost->host_lock); 124 + set_bit(FC_ABORT_DISCOVERY, &vport->fc_flag); 126 125 127 126 if (phba->link_state != LPFC_CLEAR_LA) 128 127 lpfc_issue_clear_la(phba, vport); ··· 298 301 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 299 302 "0116 Xmit ELS command x%x to remote " 300 303 "NPORT x%x I/O tag: x%x, port state:x%x " 301 - "rpi x%x fc_flag:x%x\n", 304 + "rpi x%x fc_flag:x%lx\n", 302 305 elscmd, did, elsiocb->iotag, 303 306 vport->port_state, ndlp->nlp_rpi, 304 307 vport->fc_flag); ··· 307 310 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 308 311 "0117 Xmit ELS response x%x to remote " 309 312 "NPORT x%x I/O tag: x%x, size: x%x " 310 - "port_state x%x rpi x%x fc_flag x%x\n", 313 + "port_state x%x rpi x%x fc_flag x%lx\n", 311 314 elscmd, ndlp->nlp_DID, elsiocb->iotag, 312 315 cmd_size, vport->port_state, 313 316 ndlp->nlp_rpi, vport->fc_flag); ··· 449 452 /* move forward in case of SLI4 FC port loopback test and pt2pt mode */ 450 453 if ((phba->sli_rev == LPFC_SLI_REV4) && 451 454 !(phba->link_flag & LS_LOOPBACK_MODE) && 452 - !(vport->fc_flag & FC_PT2PT)) { 455 + !test_bit(FC_PT2PT, &vport->fc_flag)) { 453 456 ndlp = lpfc_findnode_did(vport, Fabric_DID); 454 457 if (!ndlp) { 455 458 rc = -ENODEV; ··· 464 467 } 465 468 466 469 /* Supply CSP's only if we are fabric connect or pt-to-pt connect */ 467 - if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) { 470 + if (test_bit(FC_FABRIC, &vport->fc_flag) || 471 + test_bit(FC_PT2PT, &vport->fc_flag)) { 468 472 rc = lpfc_mbox_rsrc_prep(phba, mboxq); 469 473 if (rc) { 470 474 rc = -ENOMEM; ··· 518 520 lpfc_issue_unreg_vfi(struct lpfc_vport *vport) 519 521 { 520 522 struct lpfc_hba *phba = vport->phba; 521 - struct Scsi_Host *shost; 522 523 LPFC_MBOXQ_t *mboxq; 523 524 int rc; 524 525 ··· 543 546 return -EIO; 544 547 } 545 548 546 - shost = lpfc_shost_from_vport(vport); 547 - spin_lock_irq(shost->host_lock); 548 - vport->fc_flag &= ~FC_VFI_REGISTERED; 549 - spin_unlock_irq(shost->host_lock); 549 + clear_bit(FC_VFI_REGISTERED, &vport->fc_flag); 550 550 return 0; 551 551 } 552 552 ··· 571 577 { 572 578 struct lpfc_hba *phba = vport->phba; 573 579 uint8_t fabric_param_changed = 0; 574 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 575 580 576 581 if ((vport->fc_prevDID != vport->fc_myDID) || 577 582 memcmp(&vport->fabric_portname, &sp->portName, ··· 592 599 * - lpfc_delay_discovery module parameter is set. 593 600 */ 594 601 if (fabric_param_changed && !sp->cmn.clean_address_bit && 595 - (vport->fc_prevDID || phba->cfg_delay_discovery)) { 596 - spin_lock_irq(shost->host_lock); 597 - vport->fc_flag |= FC_DISC_DELAYED; 598 - spin_unlock_irq(shost->host_lock); 599 - } 602 + (vport->fc_prevDID || phba->cfg_delay_discovery)) 603 + set_bit(FC_DISC_DELAYED, &vport->fc_flag); 600 604 601 605 return fabric_param_changed; 602 606 } ··· 623 633 lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 624 634 struct serv_parm *sp, uint32_t ulp_word4) 625 635 { 626 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 627 636 struct lpfc_hba *phba = vport->phba; 628 637 struct lpfc_nodelist *np; 629 638 struct lpfc_nodelist *next_np; 630 639 uint8_t fabric_param_changed; 631 640 632 - spin_lock_irq(shost->host_lock); 633 - vport->fc_flag |= FC_FABRIC; 634 - spin_unlock_irq(shost->host_lock); 641 + set_bit(FC_FABRIC, &vport->fc_flag); 635 642 636 643 phba->fc_edtov = be32_to_cpu(sp->cmn.e_d_tov); 637 644 if (sp->cmn.edtovResolution) /* E_D_TOV ticks are in nanoseconds */ ··· 637 650 phba->fc_edtovResol = sp->cmn.edtovResolution; 638 651 phba->fc_ratov = (be32_to_cpu(sp->cmn.w2.r_a_tov) + 999) / 1000; 639 652 640 - if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { 641 - spin_lock_irq(shost->host_lock); 642 - vport->fc_flag |= FC_PUBLIC_LOOP; 643 - spin_unlock_irq(shost->host_lock); 644 - } 653 + if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) 654 + set_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 645 655 646 656 vport->fc_myDID = ulp_word4 & Mask_DID; 647 657 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof(struct lpfc_name)); ··· 712 728 lpfc_unregister_fcf_prep(phba); 713 729 714 730 /* This should just update the VFI CSPs*/ 715 - if (vport->fc_flag & FC_VFI_REGISTERED) 731 + if (test_bit(FC_VFI_REGISTERED, &vport->fc_flag)) 716 732 lpfc_issue_reg_vfi(vport); 717 733 } 718 734 719 735 if (fabric_param_changed && 720 - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { 736 + !test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) { 721 737 722 738 /* If our NportID changed, we need to ensure all 723 739 * remaining NPORTs get unreg_login'ed. ··· 737 753 if (phba->sli_rev == LPFC_SLI_REV4) { 738 754 lpfc_sli4_unreg_all_rpis(vport); 739 755 lpfc_mbx_unreg_vpi(vport); 740 - spin_lock_irq(shost->host_lock); 741 - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 742 - spin_unlock_irq(shost->host_lock); 756 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 743 757 } 744 758 745 759 /* 746 760 * For SLI3 and SLI4, the VPI needs to be reregistered in 747 761 * response to this fabric parameter change event. 748 762 */ 749 - spin_lock_irq(shost->host_lock); 750 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 751 - spin_unlock_irq(shost->host_lock); 763 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 752 764 } else if ((phba->sli_rev == LPFC_SLI_REV4) && 753 - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { 765 + !test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) { 754 766 /* 755 767 * Driver needs to re-reg VPI in order for f/w 756 768 * to update the MAC address. ··· 759 779 if (phba->sli_rev < LPFC_SLI_REV4) { 760 780 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); 761 781 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED && 762 - vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) 782 + test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) 763 783 lpfc_register_new_vport(phba, vport, ndlp); 764 784 else 765 785 lpfc_issue_fabric_reglogin(vport); 766 786 } else { 767 787 ndlp->nlp_type |= NLP_FABRIC; 768 788 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); 769 - if ((!(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) && 770 - (vport->vpi_state & LPFC_VPI_REGISTERED)) { 789 + if ((!test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) && 790 + (vport->vpi_state & LPFC_VPI_REGISTERED)) { 771 791 lpfc_start_fdiscs(phba); 772 792 lpfc_do_scr_ns_plogi(phba, vport); 773 - } else if (vport->fc_flag & FC_VFI_REGISTERED) 793 + } else if (test_bit(FC_VFI_REGISTERED, &vport->fc_flag)) 774 794 lpfc_issue_init_vpi(vport); 775 795 else { 776 796 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, ··· 806 826 lpfc_cmpl_els_flogi_nport(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 807 827 struct serv_parm *sp) 808 828 { 809 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 810 829 struct lpfc_hba *phba = vport->phba; 811 830 LPFC_MBOXQ_t *mbox; 812 831 int rc; 813 832 814 - spin_lock_irq(shost->host_lock); 815 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 816 - vport->fc_flag |= FC_PT2PT; 817 - spin_unlock_irq(shost->host_lock); 833 + clear_bit(FC_FABRIC, &vport->fc_flag); 834 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 835 + set_bit(FC_PT2PT, &vport->fc_flag); 818 836 819 837 /* If we are pt2pt with another NPort, force NPIV off! */ 820 838 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; ··· 820 842 /* If physical FC port changed, unreg VFI and ALL VPIs / RPIs */ 821 843 if ((phba->sli_rev == LPFC_SLI_REV4) && phba->fc_topology_changed) { 822 844 lpfc_unregister_fcf_prep(phba); 823 - 824 - spin_lock_irq(shost->host_lock); 825 - vport->fc_flag &= ~FC_VFI_REGISTERED; 826 - spin_unlock_irq(shost->host_lock); 845 + clear_bit(FC_VFI_REGISTERED, &vport->fc_flag); 827 846 phba->fc_topology_changed = 0; 828 847 } 829 848 ··· 829 854 830 855 if (rc >= 0) { 831 856 /* This side will initiate the PLOGI */ 832 - spin_lock_irq(shost->host_lock); 833 - vport->fc_flag |= FC_PT2PT_PLOGI; 834 - spin_unlock_irq(shost->host_lock); 857 + set_bit(FC_PT2PT_PLOGI, &vport->fc_flag); 835 858 836 859 /* 837 860 * N_Port ID cannot be 0, set our Id to LocalID ··· 926 953 struct lpfc_iocbq *rspiocb) 927 954 { 928 955 struct lpfc_vport *vport = cmdiocb->vport; 929 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 930 956 struct lpfc_nodelist *ndlp = cmdiocb->ndlp; 931 957 IOCB_t *irsp; 932 958 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp; ··· 1041 1069 } 1042 1070 1043 1071 /* FLOGI failed, so there is no fabric */ 1044 - spin_lock_irq(shost->host_lock); 1045 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP | 1046 - FC_PT2PT_NO_NVME); 1047 - spin_unlock_irq(shost->host_lock); 1072 + clear_bit(FC_FABRIC, &vport->fc_flag); 1073 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 1074 + clear_bit(FC_PT2PT_NO_NVME, &vport->fc_flag); 1048 1075 1049 1076 /* If private loop, then allow max outstanding els to be 1050 1077 * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no ··· 1052 1081 if (phba->alpa_map[0] == 0) 1053 1082 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; 1054 1083 if ((phba->sli_rev == LPFC_SLI_REV4) && 1055 - (!(vport->fc_flag & FC_VFI_REGISTERED) || 1084 + (!test_bit(FC_VFI_REGISTERED, &vport->fc_flag) || 1056 1085 (vport->fc_prevDID != vport->fc_myDID) || 1057 1086 phba->fc_topology_changed)) { 1058 - if (vport->fc_flag & FC_VFI_REGISTERED) { 1087 + if (test_bit(FC_VFI_REGISTERED, &vport->fc_flag)) { 1059 1088 if (phba->fc_topology_changed) { 1060 1089 lpfc_unregister_fcf_prep(phba); 1061 - spin_lock_irq(shost->host_lock); 1062 - vport->fc_flag &= ~FC_VFI_REGISTERED; 1063 - spin_unlock_irq(shost->host_lock); 1090 + clear_bit(FC_VFI_REGISTERED, 1091 + &vport->fc_flag); 1064 1092 phba->fc_topology_changed = 0; 1065 1093 } else { 1066 1094 lpfc_sli4_unreg_all_rpis(vport); ··· 1074 1104 } 1075 1105 goto flogifail; 1076 1106 } 1077 - spin_lock_irq(shost->host_lock); 1078 - vport->fc_flag &= ~FC_VPORT_CVL_RCVD; 1079 - vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; 1080 - spin_unlock_irq(shost->host_lock); 1107 + clear_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); 1108 + clear_bit(FC_VPORT_LOGO_RCVD, &vport->fc_flag); 1081 1109 1082 1110 /* 1083 1111 * The FLOGI succeeded. Sync the data for the CPU before ··· 1091 1123 /* FLOGI completes successfully */ 1092 1124 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 1093 1125 "0101 FLOGI completes successfully, I/O tag:x%x " 1094 - "xri x%x Data: x%x x%x x%x x%x x%x x%x x%x %d\n", 1126 + "xri x%x Data: x%x x%x x%x x%x x%x x%lx x%x %d\n", 1095 1127 cmdiocb->iotag, cmdiocb->sli4_xritag, 1096 1128 ulp_word4, sp->cmn.e_d_tov, 1097 1129 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution, ··· 1170 1202 goto out; 1171 1203 } 1172 1204 } else if (vport->port_state > LPFC_FLOGI && 1173 - vport->fc_flag & FC_PT2PT) { 1205 + test_bit(FC_PT2PT, &vport->fc_flag)) { 1174 1206 /* 1175 1207 * In a p2p topology, it is possible that discovery has 1176 1208 * already progressed, and this completion can be ignored. ··· 1474 1506 if (ulp_command == CMD_ELS_REQUEST64_CR) { 1475 1507 ndlp = iocb->ndlp; 1476 1508 if (ndlp && ndlp->nlp_DID == Fabric_DID) { 1477 - if ((phba->pport->fc_flag & FC_PT2PT) && 1478 - !(phba->pport->fc_flag & FC_PT2PT_PLOGI)) 1509 + if (test_bit(FC_PT2PT, &phba->pport->fc_flag) && 1510 + !test_bit(FC_PT2PT_PLOGI, 1511 + &phba->pport->fc_flag)) 1479 1512 iocb->fabric_cmd_cmpl = 1480 1513 lpfc_ignore_els_cmpl; 1481 1514 lpfc_sli_issue_abort_iotag(phba, pring, iocb, ··· 1531 1562 } 1532 1563 1533 1564 /* Reset the Fabric flag, topology change may have happened */ 1534 - vport->fc_flag &= ~FC_FABRIC; 1565 + clear_bit(FC_FABRIC, &vport->fc_flag); 1535 1566 if (lpfc_issue_els_flogi(vport, ndlp, 0)) { 1536 1567 /* A node reference should be retained while registered with a 1537 1568 * transport or dev-loss-evt work is pending. ··· 1614 1645 /* Continue discovery with <num_disc_nodes> PLOGIs to go */ 1615 1646 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 1616 1647 "0232 Continue discovery with %d PLOGIs to go " 1617 - "Data: x%x x%x x%x\n", 1618 - vport->num_disc_nodes, vport->fc_plogi_cnt, 1648 + "Data: x%x x%lx x%x\n", 1649 + vport->num_disc_nodes, 1650 + atomic_read(&vport->fc_plogi_cnt), 1619 1651 vport->fc_flag, vport->port_state); 1620 1652 /* Check to see if there are more PLOGIs to be sent */ 1621 - if (vport->fc_flag & FC_NLP_MORE) 1653 + if (test_bit(FC_NLP_MORE, &vport->fc_flag)) 1622 1654 /* go thru NPR nodes and issue any remaining ELS PLOGIs */ 1623 1655 lpfc_els_disc_plogi(vport); 1624 1656 ··· 1666 1696 struct serv_parm *sp; 1667 1697 uint8_t name[sizeof(struct lpfc_name)]; 1668 1698 uint32_t keepDID = 0, keep_nlp_flag = 0; 1699 + int rc; 1669 1700 uint32_t keep_new_nlp_flag = 0; 1670 1701 uint16_t keep_nlp_state; 1671 1702 u32 keep_nlp_fc4_type = 0; 1672 1703 struct lpfc_nvme_rport *keep_nrport = NULL; 1673 1704 unsigned long *active_rrqs_xri_bitmap = NULL; 1674 - 1675 - /* Fabric nodes can have the same WWPN so we don't bother searching 1676 - * by WWPN. Just return the ndlp that was given to us. 1677 - */ 1678 - if (ndlp->nlp_type & NLP_FABRIC) 1679 - return ndlp; 1680 1705 1681 1706 sp = (struct serv_parm *) ((uint8_t *) prsp + sizeof(uint32_t)); 1682 1707 memset(name, 0, sizeof(struct lpfc_name)); ··· 1682 1717 new_ndlp = lpfc_findnode_wwpn(vport, &sp->portName); 1683 1718 1684 1719 /* return immediately if the WWPN matches ndlp */ 1685 - if (!new_ndlp || (new_ndlp == ndlp)) 1720 + if (new_ndlp == ndlp) 1686 1721 return ndlp; 1687 - 1688 - /* 1689 - * Unregister from backend if not done yet. Could have been skipped 1690 - * due to ADISC 1691 - */ 1692 - lpfc_nlp_unreg_node(vport, new_ndlp); 1693 1722 1694 1723 if (phba->sli_rev == LPFC_SLI_REV4) { 1695 1724 active_rrqs_xri_bitmap = mempool_alloc(phba->active_rrq_pool, ··· 1701 1742 (new_ndlp ? new_ndlp->nlp_flag : 0), 1702 1743 (new_ndlp ? new_ndlp->nlp_fc4_type : 0)); 1703 1744 1704 - keepDID = new_ndlp->nlp_DID; 1745 + if (!new_ndlp) { 1746 + rc = memcmp(&ndlp->nlp_portname, name, 1747 + sizeof(struct lpfc_name)); 1748 + if (!rc) { 1749 + if (active_rrqs_xri_bitmap) 1750 + mempool_free(active_rrqs_xri_bitmap, 1751 + phba->active_rrq_pool); 1752 + return ndlp; 1753 + } 1754 + new_ndlp = lpfc_nlp_init(vport, ndlp->nlp_DID); 1755 + if (!new_ndlp) { 1756 + if (active_rrqs_xri_bitmap) 1757 + mempool_free(active_rrqs_xri_bitmap, 1758 + phba->active_rrq_pool); 1759 + return ndlp; 1760 + } 1761 + } else { 1762 + if (phba->sli_rev == LPFC_SLI_REV4 && 1763 + active_rrqs_xri_bitmap) 1764 + memcpy(active_rrqs_xri_bitmap, 1765 + new_ndlp->active_rrqs_xri_bitmap, 1766 + phba->cfg_rrq_xri_bitmap_sz); 1705 1767 1706 - if (phba->sli_rev == LPFC_SLI_REV4 && active_rrqs_xri_bitmap) 1707 - memcpy(active_rrqs_xri_bitmap, new_ndlp->active_rrqs_xri_bitmap, 1708 - phba->cfg_rrq_xri_bitmap_sz); 1768 + /* 1769 + * Unregister from backend if not done yet. Could have been 1770 + * skipped due to ADISC 1771 + */ 1772 + lpfc_nlp_unreg_node(vport, new_ndlp); 1773 + } 1774 + 1775 + keepDID = new_ndlp->nlp_DID; 1709 1776 1710 1777 /* At this point in this routine, we know new_ndlp will be 1711 1778 * returned. however, any previous GID_FTs that were done 1712 1779 * would have updated nlp_fc4_type in ndlp, so we must ensure 1713 1780 * new_ndlp has the right value. 1714 1781 */ 1715 - if (vport->fc_flag & FC_FABRIC) { 1782 + if (test_bit(FC_FABRIC, &vport->fc_flag)) { 1716 1783 keep_nlp_fc4_type = new_ndlp->nlp_fc4_type; 1717 1784 new_ndlp->nlp_fc4_type = ndlp->nlp_fc4_type; 1718 1785 } ··· 1899 1914 void 1900 1915 lpfc_end_rscn(struct lpfc_vport *vport) 1901 1916 { 1902 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1903 1917 1904 - if (vport->fc_flag & FC_RSCN_MODE) { 1918 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 1905 1919 /* 1906 1920 * Check to see if more RSCNs came in while we were 1907 1921 * processing this one. 1908 1922 */ 1909 1923 if (vport->fc_rscn_id_cnt || 1910 - (vport->fc_flag & FC_RSCN_DISCOVERY) != 0) 1924 + test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag)) 1911 1925 lpfc_els_handle_rscn(vport); 1912 - else { 1913 - spin_lock_irq(shost->host_lock); 1914 - vport->fc_flag &= ~FC_RSCN_MODE; 1915 - spin_unlock_irq(shost->host_lock); 1916 - } 1926 + else 1927 + clear_bit(FC_RSCN_MODE, &vport->fc_flag); 1917 1928 } 1918 1929 } 1919 1930 ··· 1996 2015 struct lpfc_iocbq *rspiocb) 1997 2016 { 1998 2017 struct lpfc_vport *vport = cmdiocb->vport; 1999 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2000 2018 IOCB_t *irsp; 2001 2019 struct lpfc_nodelist *ndlp, *free_ndlp; 2002 2020 struct lpfc_dmabuf *prsp; ··· 2142 2162 lpfc_more_plogi(vport); 2143 2163 2144 2164 if (vport->num_disc_nodes == 0) { 2145 - spin_lock_irq(shost->host_lock); 2146 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 2147 - spin_unlock_irq(shost->host_lock); 2165 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 2148 2166 2149 2167 lpfc_can_disctmo(vport); 2150 2168 lpfc_end_rscn(vport); ··· 2204 2226 */ 2205 2227 if ((ndlp->nlp_flag & (NLP_IGNR_REG_CMPL | NLP_UNREG_INP)) && 2206 2228 ((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) && 2207 - !(vport->fc_flag & FC_OFFLINE_MODE)) { 2229 + !test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) { 2208 2230 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 2209 2231 "4110 Issue PLOGI x%x deferred " 2210 2232 "on NPort x%x rpi x%x flg x%x Data:" ··· 2236 2258 * If we are a N-port connected to a Fabric, fix-up paramm's so logins 2237 2259 * to device on remote loops work. 2238 2260 */ 2239 - if ((vport->fc_flag & FC_FABRIC) && !(vport->fc_flag & FC_PUBLIC_LOOP)) 2261 + if (test_bit(FC_FABRIC, &vport->fc_flag) && 2262 + !test_bit(FC_PUBLIC_LOOP, &vport->fc_flag)) 2240 2263 sp->cmn.altBbCredit = 1; 2241 2264 2242 2265 if (sp->cmn.fcphLow < FC_PH_4_3) ··· 2361 2382 /* If we don't send GFT_ID to Fabric, a PRLI error 2362 2383 * could be expected. 2363 2384 */ 2364 - if ((vport->fc_flag & FC_FABRIC) || 2365 - (vport->cfg_enable_fc4_type != LPFC_ENABLE_BOTH)) { 2385 + if (test_bit(FC_FABRIC, &vport->fc_flag) || 2386 + vport->cfg_enable_fc4_type != LPFC_ENABLE_BOTH) { 2366 2387 mode = KERN_ERR; 2367 2388 loglevel = LOG_TRACE_EVENT; 2368 2389 } else { ··· 2403 2424 * For P2P topology, retain the node so that PLOGI can be 2404 2425 * attempted on it again. 2405 2426 */ 2406 - if (vport->fc_flag & FC_PT2PT) 2427 + if (test_bit(FC_PT2PT, &vport->fc_flag)) 2407 2428 goto out; 2408 2429 2409 2430 /* As long as this node is not registered with the SCSI ··· 2479 2500 * the remote NPort beng a NVME Target. 2480 2501 */ 2481 2502 if (phba->sli_rev == LPFC_SLI_REV4 && 2482 - vport->fc_flag & FC_RSCN_MODE && 2503 + test_bit(FC_RSCN_MODE, &vport->fc_flag) && 2483 2504 vport->nvmei_support) 2484 2505 ndlp->nlp_fc4_type |= NLP_FC4_NVME; 2485 2506 local_nlp_type = ndlp->nlp_fc4_type; ··· 2656 2677 2657 2678 /* RSCN discovery */ 2658 2679 /* go thru NPR nodes and issue ELS PLOGIs */ 2659 - if (vport->fc_npr_cnt) 2680 + if (atomic_read(&vport->fc_npr_cnt)) 2660 2681 if (lpfc_els_disc_plogi(vport)) 2661 2682 return; 2662 2683 ··· 2676 2697 static void 2677 2698 lpfc_adisc_done(struct lpfc_vport *vport) 2678 2699 { 2679 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2680 2700 struct lpfc_hba *phba = vport->phba; 2681 2701 2682 2702 /* ··· 2683 2705 * and continue discovery. 2684 2706 */ 2685 2707 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 2686 - !(vport->fc_flag & FC_RSCN_MODE) && 2708 + !test_bit(FC_RSCN_MODE, &vport->fc_flag) && 2687 2709 (phba->sli_rev < LPFC_SLI_REV4)) { 2688 2710 2689 2711 /* ··· 2712 2734 if (vport->port_state < LPFC_VPORT_READY) { 2713 2735 /* If we get here, there is nothing to ADISC */ 2714 2736 lpfc_issue_clear_la(phba, vport); 2715 - if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { 2737 + if (!test_bit(FC_ABORT_DISCOVERY, &vport->fc_flag)) { 2716 2738 vport->num_disc_nodes = 0; 2717 2739 /* go thru NPR list, issue ELS PLOGIs */ 2718 - if (vport->fc_npr_cnt) 2740 + if (atomic_read(&vport->fc_npr_cnt)) 2719 2741 lpfc_els_disc_plogi(vport); 2720 2742 if (!vport->num_disc_nodes) { 2721 - spin_lock_irq(shost->host_lock); 2722 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 2723 - spin_unlock_irq(shost->host_lock); 2743 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 2724 2744 lpfc_can_disctmo(vport); 2725 2745 lpfc_end_rscn(vport); 2726 2746 } ··· 2745 2769 /* Continue discovery with <num_disc_nodes> ADISCs to go */ 2746 2770 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 2747 2771 "0210 Continue discovery with %d ADISCs to go " 2748 - "Data: x%x x%x x%x\n", 2749 - vport->num_disc_nodes, vport->fc_adisc_cnt, 2772 + "Data: x%x x%lx x%x\n", 2773 + vport->num_disc_nodes, 2774 + atomic_read(&vport->fc_adisc_cnt), 2750 2775 vport->fc_flag, vport->port_state); 2751 2776 /* Check to see if there are more ADISCs to be sent */ 2752 - if (vport->fc_flag & FC_NLP_MORE) { 2777 + if (test_bit(FC_NLP_MORE, &vport->fc_flag)) { 2753 2778 lpfc_set_disctmo(vport); 2754 2779 /* go thru NPR nodes and issue any remaining ELS ADISCs */ 2755 2780 lpfc_els_disc_adisc(vport); ··· 3595 3618 3596 3619 /* Not supported for private loop */ 3597 3620 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP && 3598 - !(vport->fc_flag & FC_PUBLIC_LOOP)) 3621 + !test_bit(FC_PUBLIC_LOOP, &vport->fc_flag)) 3599 3622 return 1; 3600 3623 3601 - if (vport->fc_flag & FC_PT2PT) { 3624 + if (test_bit(FC_PT2PT, &vport->fc_flag)) { 3602 3625 /* find any mapped nport - that would be the other nport */ 3603 3626 ndlp = lpfc_findnode_mapped(vport); 3604 3627 if (!ndlp) ··· 4376 4399 void 4377 4400 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) 4378 4401 { 4379 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4380 4402 struct lpfc_work_evt *evtp; 4381 4403 4382 4404 if (!(nlp->nlp_flag & NLP_DELAY_TMO)) ··· 4403 4427 /* Check if there are more PLOGIs to be sent */ 4404 4428 lpfc_more_plogi(vport); 4405 4429 if (vport->num_disc_nodes == 0) { 4406 - spin_lock_irq(shost->host_lock); 4407 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 4408 - spin_unlock_irq(shost->host_lock); 4430 + clear_bit(FC_NDISC_ACTIVE, 4431 + &vport->fc_flag); 4409 4432 lpfc_can_disctmo(vport); 4410 4433 lpfc_end_rscn(vport); 4411 4434 } ··· 4521 4546 } 4522 4547 break; 4523 4548 case ELS_CMD_FDISC: 4524 - if (!(vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)) 4549 + if (!test_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag)) 4525 4550 lpfc_issue_els_fdisc(vport, ndlp, retry); 4526 4551 break; 4527 4552 } ··· 4759 4784 /* Added for Vendor specifc support 4760 4785 * Just keep retrying for these Rsn / Exp codes 4761 4786 */ 4762 - if ((vport->fc_flag & FC_PT2PT) && 4787 + if (test_bit(FC_PT2PT, &vport->fc_flag) && 4763 4788 cmd == ELS_CMD_NVMEPRLI) { 4764 4789 switch (stat.un.b.lsRjtRsnCode) { 4765 4790 case LSRJT_UNABLE_TPC: ··· 4772 4797 "support NVME, disabling NVME\n", 4773 4798 stat.un.b.lsRjtRsnCode); 4774 4799 retry = 0; 4775 - vport->fc_flag |= FC_PT2PT_NO_NVME; 4800 + set_bit(FC_PT2PT_NO_NVME, &vport->fc_flag); 4776 4801 goto out_retry; 4777 4802 } 4778 4803 } ··· 4964 4989 retry = 0; 4965 4990 } 4966 4991 4967 - if ((vport->load_flag & FC_UNLOADING) != 0) 4992 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 4968 4993 retry = 0; 4969 4994 4970 4995 out_retry: ··· 4995 5020 4996 5021 /* If discovery / RSCN timer is running, reset it */ 4997 5022 if (timer_pending(&vport->fc_disctmo) || 4998 - (vport->fc_flag & FC_RSCN_MODE)) 5023 + test_bit(FC_RSCN_MODE, &vport->fc_flag)) 4999 5024 lpfc_set_disctmo(vport); 5000 5025 } 5001 5026 ··· 5381 5406 if (ulp_status == 0 5382 5407 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { 5383 5408 if (!lpfc_unreg_rpi(vport, ndlp) && 5384 - (!(vport->fc_flag & FC_PT2PT))) { 5409 + !test_bit(FC_PT2PT, &vport->fc_flag)) { 5385 5410 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE || 5386 5411 ndlp->nlp_state == 5387 5412 NLP_STE_REG_LOGIN_ISSUE) { ··· 5753 5778 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 5754 5779 "0128 Xmit ELS ACC response Status: x%x, IoTag: x%x, " 5755 5780 "XRI: x%x, DID: x%x, nlp_flag: x%x nlp_state: x%x " 5756 - "RPI: x%x, fc_flag x%x refcnt %d\n", 5781 + "RPI: x%x, fc_flag x%lx refcnt %d\n", 5757 5782 rc, elsiocb->iotag, elsiocb->sli4_xritag, 5758 5783 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, 5759 5784 ndlp->nlp_rpi, vport->fc_flag, kref_read(&ndlp->kref)); ··· 5959 5984 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 5960 5985 "0152 Xmit EDC ACC response Status: x%x, IoTag: x%x, " 5961 5986 "XRI: x%x, DID: x%x, nlp_flag: x%x nlp_state: x%x " 5962 - "RPI: x%x, fc_flag x%x\n", 5987 + "RPI: x%x, fc_flag x%lx\n", 5963 5988 rc, elsiocb->iotag, elsiocb->sli4_xritag, 5964 5989 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, 5965 5990 ndlp->nlp_rpi, vport->fc_flag); ··· 6526 6551 int 6527 6552 lpfc_els_disc_adisc(struct lpfc_vport *vport) 6528 6553 { 6529 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 6530 6554 struct lpfc_nodelist *ndlp, *next_ndlp; 6531 6555 int sentadisc = 0; 6532 6556 ··· 6560 6586 vport->num_disc_nodes++; 6561 6587 if (vport->num_disc_nodes >= 6562 6588 vport->cfg_discovery_threads) { 6563 - spin_lock_irq(shost->host_lock); 6564 - vport->fc_flag |= FC_NLP_MORE; 6565 - spin_unlock_irq(shost->host_lock); 6589 + set_bit(FC_NLP_MORE, &vport->fc_flag); 6566 6590 break; 6567 6591 } 6568 6592 6569 6593 } 6570 - if (sentadisc == 0) { 6571 - spin_lock_irq(shost->host_lock); 6572 - vport->fc_flag &= ~FC_NLP_MORE; 6573 - spin_unlock_irq(shost->host_lock); 6574 - } 6594 + if (sentadisc == 0) 6595 + clear_bit(FC_NLP_MORE, &vport->fc_flag); 6575 6596 return sentadisc; 6576 6597 } 6577 6598 ··· 6592 6623 int 6593 6624 lpfc_els_disc_plogi(struct lpfc_vport *vport) 6594 6625 { 6595 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 6596 6626 struct lpfc_nodelist *ndlp, *next_ndlp; 6597 6627 int sentplogi = 0; 6598 6628 ··· 6608 6640 vport->num_disc_nodes++; 6609 6641 if (vport->num_disc_nodes >= 6610 6642 vport->cfg_discovery_threads) { 6611 - spin_lock_irq(shost->host_lock); 6612 - vport->fc_flag |= FC_NLP_MORE; 6613 - spin_unlock_irq(shost->host_lock); 6643 + set_bit(FC_NLP_MORE, &vport->fc_flag); 6614 6644 break; 6615 6645 } 6616 6646 } 6617 6647 } 6618 6648 6619 6649 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 6620 - "6452 Discover PLOGI %d flag x%x\n", 6650 + "6452 Discover PLOGI %d flag x%lx\n", 6621 6651 sentplogi, vport->fc_flag); 6622 6652 6623 - if (sentplogi) { 6653 + if (sentplogi) 6624 6654 lpfc_set_disctmo(vport); 6625 - } 6626 - else { 6627 - spin_lock_irq(shost->host_lock); 6628 - vport->fc_flag &= ~FC_NLP_MORE; 6629 - spin_unlock_irq(shost->host_lock); 6630 - } 6655 + else 6656 + clear_bit(FC_NLP_MORE, &vport->fc_flag); 6631 6657 return sentplogi; 6632 6658 } 6633 6659 ··· 7032 7070 { 7033 7071 7034 7072 desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG); 7035 - if (vport->fc_flag & FC_FABRIC) { 7073 + if (test_bit(FC_FABRIC, &vport->fc_flag)) { 7036 7074 memcpy(desc->port_names.wwnn, &vport->fabric_nodename, 7037 7075 sizeof(desc->port_names.wwnn)); 7038 7076 ··· 7816 7854 lpfc_in_buf_free(phba, vport->fc_rscn_id_list[i]); 7817 7855 vport->fc_rscn_id_list[i] = NULL; 7818 7856 } 7857 + clear_bit(FC_RSCN_MODE, &vport->fc_flag); 7858 + clear_bit(FC_RSCN_DISCOVERY, &vport->fc_flag); 7819 7859 spin_lock_irq(shost->host_lock); 7820 7860 vport->fc_rscn_id_cnt = 0; 7821 - vport->fc_flag &= ~(FC_RSCN_MODE | FC_RSCN_DISCOVERY); 7822 7861 spin_unlock_irq(shost->host_lock); 7823 7862 lpfc_can_disctmo(vport); 7824 7863 /* Indicate we are done walking this fc_rscn_id_list */ ··· 7854 7891 return 0; 7855 7892 7856 7893 /* If we are doing a FULL RSCN rediscovery, match everything */ 7857 - if (vport->fc_flag & FC_RSCN_DISCOVERY) 7894 + if (test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag)) 7858 7895 return did; 7859 7896 7860 7897 spin_lock_irq(shost->host_lock); ··· 8033 8070 payload_len -= sizeof(uint32_t); /* take off word 0 */ 8034 8071 /* RSCN received */ 8035 8072 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 8036 - "0214 RSCN received Data: x%x x%x x%x x%x\n", 8073 + "0214 RSCN received Data: x%lx x%x x%x x%x\n", 8037 8074 vport->fc_flag, payload_len, *lp, 8038 8075 vport->fc_rscn_id_cnt); 8039 8076 ··· 8045 8082 FCH_EVT_RSCN, lp[i]); 8046 8083 8047 8084 /* Check if RSCN is coming from a direct-connected remote NPort */ 8048 - if (vport->fc_flag & FC_PT2PT) { 8085 + if (test_bit(FC_PT2PT, &vport->fc_flag)) { 8049 8086 /* If so, just ACC it, no other action needed for now */ 8050 8087 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 8051 - "2024 pt2pt RSCN %08x Data: x%x x%x\n", 8088 + "2024 pt2pt RSCN %08x Data: x%lx x%x\n", 8052 8089 *lp, vport->fc_flag, payload_len); 8053 8090 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); 8054 8091 ··· 8092 8129 /* ALL NPortIDs in RSCN are on HBA */ 8093 8130 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 8094 8131 "0219 Ignore RSCN " 8095 - "Data: x%x x%x x%x x%x\n", 8132 + "Data: x%lx x%x x%x x%x\n", 8096 8133 vport->fc_flag, payload_len, 8097 8134 *lp, vport->fc_rscn_id_cnt); 8098 8135 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, ··· 8103 8140 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, 8104 8141 ndlp, NULL); 8105 8142 /* Restart disctmo if its already running */ 8106 - if (vport->fc_flag & FC_DISC_TMO) { 8143 + if (test_bit(FC_DISC_TMO, &vport->fc_flag)) { 8107 8144 tmo = ((phba->fc_ratov * 3) + 3); 8108 8145 mod_timer(&vport->fc_disctmo, 8109 8146 jiffies + ··· 8116 8153 spin_lock_irq(shost->host_lock); 8117 8154 if (vport->fc_rscn_flush) { 8118 8155 /* Another thread is walking fc_rscn_id_list on this vport */ 8119 - vport->fc_flag |= FC_RSCN_DISCOVERY; 8120 8156 spin_unlock_irq(shost->host_lock); 8157 + set_bit(FC_RSCN_DISCOVERY, &vport->fc_flag); 8121 8158 /* Send back ACC */ 8122 8159 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); 8123 8160 return 0; ··· 8130 8167 /* If we are already processing an RSCN, save the received 8131 8168 * RSCN payload buffer, cmdiocb->cmd_dmabuf to process later. 8132 8169 */ 8133 - if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { 8170 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag) || 8171 + test_bit(FC_NDISC_ACTIVE, &vport->fc_flag)) { 8134 8172 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 8135 8173 "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", 8136 8174 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 8137 8175 8138 - spin_lock_irq(shost->host_lock); 8139 - vport->fc_flag |= FC_RSCN_DEFERRED; 8176 + set_bit(FC_RSCN_DEFERRED, &vport->fc_flag); 8140 8177 8141 8178 /* Restart disctmo if its already running */ 8142 - if (vport->fc_flag & FC_DISC_TMO) { 8179 + if (test_bit(FC_DISC_TMO, &vport->fc_flag)) { 8143 8180 tmo = ((phba->fc_ratov * 3) + 3); 8144 8181 mod_timer(&vport->fc_disctmo, 8145 8182 jiffies + msecs_to_jiffies(1000 * tmo)); 8146 8183 } 8147 8184 if ((rscn_cnt < FC_MAX_HOLD_RSCN) && 8148 - !(vport->fc_flag & FC_RSCN_DISCOVERY)) { 8149 - vport->fc_flag |= FC_RSCN_MODE; 8150 - spin_unlock_irq(shost->host_lock); 8185 + !test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag)) { 8186 + set_bit(FC_RSCN_MODE, &vport->fc_flag); 8151 8187 if (rscn_cnt) { 8152 8188 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; 8153 8189 length = be32_to_cpu(*cmd & ~ELS_CMD_MASK); ··· 8168 8206 /* Deferred RSCN */ 8169 8207 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 8170 8208 "0235 Deferred RSCN " 8171 - "Data: x%x x%x x%x\n", 8209 + "Data: x%x x%lx x%x\n", 8172 8210 vport->fc_rscn_id_cnt, vport->fc_flag, 8173 8211 vport->port_state); 8174 8212 } else { 8175 - vport->fc_flag |= FC_RSCN_DISCOVERY; 8176 - spin_unlock_irq(shost->host_lock); 8213 + set_bit(FC_RSCN_DISCOVERY, &vport->fc_flag); 8177 8214 /* ReDiscovery RSCN */ 8178 8215 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 8179 8216 "0234 ReDiscovery RSCN " 8180 - "Data: x%x x%x x%x\n", 8217 + "Data: x%x x%lx x%x\n", 8181 8218 vport->fc_rscn_id_cnt, vport->fc_flag, 8182 8219 vport->port_state); 8183 8220 } ··· 8192 8231 "RCV RSCN: did:x%x/ste:x%x flg:x%x", 8193 8232 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 8194 8233 8195 - spin_lock_irq(shost->host_lock); 8196 - vport->fc_flag |= FC_RSCN_MODE; 8197 - spin_unlock_irq(shost->host_lock); 8234 + set_bit(FC_RSCN_MODE, &vport->fc_flag); 8198 8235 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; 8199 8236 /* Indicate we are done walking fc_rscn_id_list on this vport */ 8200 8237 vport->fc_rscn_flush = 0; ··· 8232 8273 struct lpfc_hba *phba = vport->phba; 8233 8274 8234 8275 /* Ignore RSCN if the port is being torn down. */ 8235 - if (vport->load_flag & FC_UNLOADING) { 8276 + if (test_bit(FC_UNLOADING, &vport->load_flag)) { 8236 8277 lpfc_els_flush_rscn(vport); 8237 8278 return 0; 8238 8279 } ··· 8242 8283 8243 8284 /* RSCN processed */ 8244 8285 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 8245 - "0215 RSCN processed Data: x%x x%x x%x x%x x%x x%x\n", 8286 + "0215 RSCN processed Data: x%lx x%x x%x x%x x%x x%x\n", 8246 8287 vport->fc_flag, 0, vport->fc_rscn_id_cnt, 8247 8288 vport->port_state, vport->num_disc_nodes, 8248 8289 vport->gidft_inp); ··· 8331 8372 LPFC_MBOXQ_t *mbox; 8332 8373 uint32_t cmd, did; 8333 8374 int rc; 8334 - uint32_t fc_flag = 0; 8375 + unsigned long fc_flag = 0; 8335 8376 uint32_t port_state = 0; 8336 8377 8337 8378 /* Clear external loopback plug detected flag */ ··· 8401 8442 return 0; 8402 8443 8403 8444 } else if (rc > 0) { /* greater than */ 8404 - spin_lock_irq(shost->host_lock); 8405 - vport->fc_flag |= FC_PT2PT_PLOGI; 8406 - spin_unlock_irq(shost->host_lock); 8445 + set_bit(FC_PT2PT_PLOGI, &vport->fc_flag); 8407 8446 8408 8447 /* If we have the high WWPN we can assign our own 8409 8448 * myDID; otherwise, we have to WAIT for a PLOGI ··· 8420 8463 spin_lock_irq(shost->host_lock); 8421 8464 fc_flag = vport->fc_flag; 8422 8465 port_state = vport->port_state; 8423 - vport->fc_flag |= FC_PT2PT; 8424 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 8425 - 8426 8466 /* Acking an unsol FLOGI. Count 1 for link bounce 8427 8467 * work-around. 8428 8468 */ 8429 8469 vport->rcv_flogi_cnt++; 8430 8470 spin_unlock_irq(shost->host_lock); 8471 + set_bit(FC_PT2PT, &vport->fc_flag); 8472 + clear_bit(FC_FABRIC, &vport->fc_flag); 8473 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 8431 8474 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 8432 8475 "3311 Rcv Flogi PS x%x new PS x%x " 8433 - "fc_flag x%x new fc_flag x%x\n", 8476 + "fc_flag x%lx new fc_flag x%lx\n", 8434 8477 port_state, vport->port_state, 8435 8478 fc_flag, vport->fc_flag); 8436 8479 ··· 9449 9492 9450 9493 spin_lock_irqsave(&vport->work_port_lock, iflag); 9451 9494 tmo_posted = vport->work_port_events & WORKER_ELS_TMO; 9452 - if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) 9495 + if (!tmo_posted && !test_bit(FC_UNLOADING, &vport->load_flag)) 9453 9496 vport->work_port_events |= WORKER_ELS_TMO; 9454 9497 spin_unlock_irqrestore(&vport->work_port_lock, iflag); 9455 9498 9456 - if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING))) 9499 + if (!tmo_posted && !test_bit(FC_UNLOADING, &vport->load_flag)) 9457 9500 lpfc_worker_wake_up(phba); 9458 9501 return; 9459 9502 } ··· 9489 9532 if (unlikely(!pring)) 9490 9533 return; 9491 9534 9492 - if (phba->pport->load_flag & FC_UNLOADING) 9535 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 9493 9536 return; 9494 9537 9495 9538 spin_lock_irq(&phba->hbalock); ··· 9565 9608 lpfc_issue_hb_tmo(phba); 9566 9609 9567 9610 if (!list_empty(&pring->txcmplq)) 9568 - if (!(phba->pport->load_flag & FC_UNLOADING)) 9611 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 9569 9612 mod_timer(&vport->els_tmofunc, 9570 9613 jiffies + msecs_to_jiffies(1000 * timeout)); 9571 9614 } ··· 10073 10116 pc_evt_str = lpfc_get_fpin_congn_event_nm(pc_evt); 10074 10117 cnt = be32_to_cpu(pc->pname_count); 10075 10118 10119 + /* Capture FPIN frequency */ 10120 + phba->cgn_fpin_frequency = be32_to_cpu(pc->event_period); 10121 + 10076 10122 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT | LOG_ELS, 10077 10123 "4684 FPIN Peer Congestion %s (x%x) " 10078 10124 "Duration %d mSecs " ··· 10364 10404 goto dropit; 10365 10405 10366 10406 /* Ignore traffic received during vport shutdown. */ 10367 - if (vport->load_flag & FC_UNLOADING) 10407 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 10368 10408 goto dropit; 10369 10409 10370 10410 /* If NPort discovery is delayed drop incoming ELS */ 10371 - if ((vport->fc_flag & FC_DISC_DELAYED) && 10372 - (cmd != ELS_CMD_PLOGI)) 10411 + if (test_bit(FC_DISC_DELAYED, &vport->fc_flag) && 10412 + cmd != ELS_CMD_PLOGI) 10373 10413 goto dropit; 10374 10414 10375 10415 ndlp = lpfc_findnode_did(vport, did); ··· 10413 10453 /* ELS command <elsCmd> received from NPORT <did> */ 10414 10454 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 10415 10455 "0112 ELS command x%x received from NPORT x%x " 10416 - "refcnt %d Data: x%x x%x x%x x%x\n", 10456 + "refcnt %d Data: x%x x%lx x%x x%x\n", 10417 10457 cmd, did, kref_read(&ndlp->kref), vport->port_state, 10418 10458 vport->fc_flag, vport->fc_myDID, vport->fc_prevDID); 10419 10459 10420 10460 /* reject till our FLOGI completes or PLOGI assigned DID via PT2PT */ 10421 10461 if ((vport->port_state < LPFC_FABRIC_CFG_LINK) && 10422 10462 (cmd != ELS_CMD_FLOGI) && 10423 - !((cmd == ELS_CMD_PLOGI) && (vport->fc_flag & FC_PT2PT))) { 10463 + !((cmd == ELS_CMD_PLOGI) && test_bit(FC_PT2PT, &vport->fc_flag))) { 10424 10464 rjt_err = LSRJT_LOGICAL_BSY; 10425 10465 rjt_exp = LSEXP_NOTHING_MORE; 10426 10466 goto lsrjt; ··· 10435 10475 phba->fc_stat.elsRcvPLOGI++; 10436 10476 ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); 10437 10477 if (phba->sli_rev == LPFC_SLI_REV4 && 10438 - (phba->pport->fc_flag & FC_PT2PT)) { 10478 + test_bit(FC_PT2PT, &phba->pport->fc_flag)) { 10439 10479 vport->fc_prevDID = vport->fc_myDID; 10440 10480 /* Our DID needs to be updated before registering 10441 10481 * the vfi. This is done in lpfc_rcv_plogi but ··· 10453 10493 lpfc_send_els_event(vport, ndlp, payload); 10454 10494 10455 10495 /* If Nport discovery is delayed, reject PLOGIs */ 10456 - if (vport->fc_flag & FC_DISC_DELAYED) { 10496 + if (test_bit(FC_DISC_DELAYED, &vport->fc_flag)) { 10457 10497 rjt_err = LSRJT_UNABLE_TPC; 10458 10498 rjt_exp = LSEXP_NOTHING_MORE; 10459 10499 break; 10460 10500 } 10461 10501 10462 10502 if (vport->port_state < LPFC_DISC_AUTH) { 10463 - if (!(phba->pport->fc_flag & FC_PT2PT) || 10464 - (phba->pport->fc_flag & FC_PT2PT_PLOGI)) { 10503 + if (!test_bit(FC_PT2PT, &phba->pport->fc_flag) || 10504 + test_bit(FC_PT2PT_PLOGI, &phba->pport->fc_flag)) { 10465 10505 rjt_err = LSRJT_UNABLE_TPC; 10466 10506 rjt_exp = LSEXP_NOTHING_MORE; 10467 10507 break; ··· 10487 10527 * bounce the link. There is some descrepancy. 10488 10528 */ 10489 10529 if (vport->port_state >= LPFC_LOCAL_CFG_LINK && 10490 - vport->fc_flag & FC_PT2PT && 10530 + test_bit(FC_PT2PT, &vport->fc_flag) && 10491 10531 vport->rcv_flogi_cnt >= 1) { 10492 10532 rjt_err = LSRJT_LOGICAL_BSY; 10493 10533 rjt_exp = LSEXP_NOTHING_MORE; ··· 10610 10650 10611 10651 phba->fc_stat.elsRcvPRLI++; 10612 10652 if ((vport->port_state < LPFC_DISC_AUTH) && 10613 - (vport->fc_flag & FC_FABRIC)) { 10653 + test_bit(FC_FABRIC, &vport->fc_flag)) { 10614 10654 rjt_err = LSRJT_UNABLE_TPC; 10615 10655 rjt_exp = LSEXP_NOTHING_MORE; 10616 10656 break; ··· 10785 10825 return; 10786 10826 10787 10827 dropit: 10788 - if (vport && !(vport->load_flag & FC_UNLOADING)) 10828 + if (vport && !test_bit(FC_UNLOADING, &vport->load_flag)) 10789 10829 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 10790 10830 "0111 Dropping received ELS cmd " 10791 10831 "Data: x%x x%x x%x x%x\n", ··· 10939 10979 lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) 10940 10980 { 10941 10981 struct lpfc_nodelist *ndlp; 10942 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 10943 10982 10944 10983 /* 10945 10984 * If lpfc_delay_discovery parameter is set and the clean address 10946 10985 * bit is cleared and fc fabric parameters chenged, delay FC NPort 10947 10986 * discovery. 10948 10987 */ 10949 - spin_lock_irq(shost->host_lock); 10950 - if (vport->fc_flag & FC_DISC_DELAYED) { 10951 - spin_unlock_irq(shost->host_lock); 10988 + if (test_bit(FC_DISC_DELAYED, &vport->fc_flag)) { 10952 10989 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 10953 10990 "3334 Delay fc port discovery for %d secs\n", 10954 10991 phba->fc_ratov); ··· 10953 10996 jiffies + msecs_to_jiffies(1000 * phba->fc_ratov)); 10954 10997 return; 10955 10998 } 10956 - spin_unlock_irq(shost->host_lock); 10957 10999 10958 11000 ndlp = lpfc_findnode_did(vport, NameServer_DID); 10959 11001 if (!ndlp) { ··· 10981 11025 } 10982 11026 10983 11027 if ((phba->cfg_enable_SmartSAN || 10984 - (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) && 10985 - (vport->load_flag & FC_ALLOW_FDMI)) 11028 + phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) && 11029 + test_bit(FC_ALLOW_FDMI, &vport->load_flag)) 10986 11030 lpfc_start_fdmi(vport); 10987 11031 } 10988 11032 ··· 11002 11046 lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 11003 11047 { 11004 11048 struct lpfc_vport *vport = pmb->vport; 11005 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 11049 + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 11006 11050 struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; 11007 11051 MAILBOX_t *mb = &pmb->u.mb; 11008 11052 int rc; 11009 11053 11010 - spin_lock_irq(shost->host_lock); 11011 - vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 11012 - spin_unlock_irq(shost->host_lock); 11054 + clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 11013 11055 11014 11056 if (mb->mbxStatus) { 11015 11057 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 11024 11070 case 0x9602: /* Link event since CLEAR_LA */ 11025 11071 /* giving up on vport registration */ 11026 11072 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 11027 - spin_lock_irq(shost->host_lock); 11028 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 11029 - spin_unlock_irq(shost->host_lock); 11073 + clear_bit(FC_FABRIC, &vport->fc_flag); 11074 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 11030 11075 lpfc_can_disctmo(vport); 11031 11076 break; 11032 11077 /* If reg_vpi fail with invalid VPI status, re-init VPI */ 11033 11078 case 0x20: 11034 - spin_lock_irq(shost->host_lock); 11035 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 11036 - spin_unlock_irq(shost->host_lock); 11079 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 11037 11080 lpfc_init_vpi(phba, pmb, vport->vpi); 11038 11081 pmb->vport = vport; 11039 11082 pmb->mbox_cmpl = lpfc_init_vpi_cmpl; ··· 11051 11100 if (phba->sli_rev == LPFC_SLI_REV4) 11052 11101 lpfc_sli4_unreg_all_rpis(vport); 11053 11102 lpfc_mbx_unreg_vpi(vport); 11054 - spin_lock_irq(shost->host_lock); 11055 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 11056 - spin_unlock_irq(shost->host_lock); 11103 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 11057 11104 if (mb->mbxStatus == MBX_NOT_FINISHED) 11058 11105 break; 11059 11106 if ((vport->port_type == LPFC_PHYSICAL_PORT) && 11060 - !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) { 11107 + !test_bit(FC_LOGO_RCVD_DID_CHNG, &vport->fc_flag)) { 11061 11108 if (phba->sli_rev == LPFC_SLI_REV4) 11062 11109 lpfc_issue_init_vfi(vport); 11063 11110 else ··· 11116 11167 lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport, 11117 11168 struct lpfc_nodelist *ndlp) 11118 11169 { 11119 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 11120 11170 LPFC_MBOXQ_t *mbox; 11121 11171 11122 11172 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); ··· 11150 11202 11151 11203 mbox_err_exit: 11152 11204 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 11153 - spin_lock_irq(shost->host_lock); 11154 - vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 11155 - spin_unlock_irq(shost->host_lock); 11205 + clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 11156 11206 return; 11157 11207 } 11158 11208 ··· 11265 11319 struct lpfc_iocbq *rspiocb) 11266 11320 { 11267 11321 struct lpfc_vport *vport = cmdiocb->vport; 11268 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 11269 11322 struct lpfc_nodelist *ndlp = cmdiocb->ndlp; 11270 11323 struct lpfc_nodelist *np; 11271 11324 struct lpfc_nodelist *next_np; ··· 11312 11367 11313 11368 lpfc_check_nlp_post_devloss(vport, ndlp); 11314 11369 11315 - spin_lock_irq(shost->host_lock); 11316 - vport->fc_flag &= ~FC_VPORT_CVL_RCVD; 11317 - vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; 11318 - vport->fc_flag |= FC_FABRIC; 11370 + clear_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); 11371 + clear_bit(FC_VPORT_LOGO_RCVD, &vport->fc_flag); 11372 + set_bit(FC_FABRIC, &vport->fc_flag); 11319 11373 if (vport->phba->fc_topology == LPFC_TOPOLOGY_LOOP) 11320 - vport->fc_flag |= FC_PUBLIC_LOOP; 11321 - spin_unlock_irq(shost->host_lock); 11374 + set_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 11322 11375 11323 11376 vport->fc_myDID = ulp_word4 & Mask_DID; 11324 11377 lpfc_vport_set_state(vport, FC_VPORT_ACTIVE); ··· 11333 11390 memcpy(&vport->fabric_nodename, &sp->nodeName, 11334 11391 sizeof(struct lpfc_name)); 11335 11392 if (fabric_param_changed && 11336 - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { 11393 + !test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) { 11337 11394 /* If our NportID changed, we need to ensure all 11338 11395 * remaining NPORTs get unreg_login'ed so we can 11339 11396 * issue unreg_vpi. ··· 11354 11411 lpfc_sli4_unreg_all_rpis(vport); 11355 11412 11356 11413 lpfc_mbx_unreg_vpi(vport); 11357 - spin_lock_irq(shost->host_lock); 11358 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 11414 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 11359 11415 if (phba->sli_rev == LPFC_SLI_REV4) 11360 - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 11416 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 11361 11417 else 11362 - vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG; 11363 - spin_unlock_irq(shost->host_lock); 11418 + set_bit(FC_LOGO_RCVD_DID_CHNG, &vport->fc_flag); 11364 11419 } else if ((phba->sli_rev == LPFC_SLI_REV4) && 11365 - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) { 11420 + !test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) { 11366 11421 /* 11367 11422 * Driver needs to re-reg VPI in order for f/w 11368 11423 * to update the MAC address. ··· 11370 11429 goto out; 11371 11430 } 11372 11431 11373 - if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) 11432 + if (test_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag)) 11374 11433 lpfc_issue_init_vpi(vport); 11375 - else if (vport->fc_flag & FC_VPORT_NEEDS_REG_VPI) 11434 + else if (test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) 11376 11435 lpfc_register_new_vport(phba, vport, ndlp); 11377 11436 else 11378 11437 lpfc_do_scr_ns_plogi(phba, vport); ··· 11525 11584 struct lpfc_vport *vport = cmdiocb->vport; 11526 11585 IOCB_t *irsp; 11527 11586 struct lpfc_nodelist *ndlp; 11528 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 11529 11587 u32 ulp_status, ulp_word4, did, tmo; 11530 11588 11531 11589 ndlp = cmdiocb->ndlp; ··· 11555 11615 ndlp->fc4_xpt_flags); 11556 11616 11557 11617 if (ulp_status == IOSTAT_SUCCESS) { 11558 - spin_lock_irq(shost->host_lock); 11559 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 11560 - vport->fc_flag &= ~FC_FABRIC; 11561 - spin_unlock_irq(shost->host_lock); 11618 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 11619 + clear_bit(FC_FABRIC, &vport->fc_flag); 11562 11620 lpfc_can_disctmo(vport); 11563 11621 } 11564 11622 ··· 12014 12076 * node and the vport is unloading, the xri aborted wcqe 12015 12077 * likely isn't coming back. Just release the sgl. 12016 12078 */ 12017 - if ((vport->load_flag & FC_UNLOADING) && 12079 + if (test_bit(FC_UNLOADING, &vport->load_flag) && 12018 12080 ndlp->nlp_DID == Fabric_DID) { 12019 12081 list_del(&sglq_entry->list); 12020 12082 sglq_entry->state = SGL_FREED;
+147 -203
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 169 169 170 170 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, 171 171 "3181 dev_loss_callbk x%06x, rport x%px flg x%x " 172 - "load_flag x%x refcnt %u state %d xpt x%x\n", 172 + "load_flag x%lx refcnt %u state %d xpt x%x\n", 173 173 ndlp->nlp_DID, ndlp->rport, ndlp->nlp_flag, 174 174 vport->load_flag, kref_read(&ndlp->kref), 175 175 ndlp->nlp_state, ndlp->fc4_xpt_flags); 176 176 177 177 /* Don't schedule a worker thread event if the vport is going down. */ 178 - if (vport->load_flag & FC_UNLOADING) { 178 + if (test_bit(FC_UNLOADING, &vport->load_flag)) { 179 179 spin_lock_irqsave(&ndlp->lock, iflags); 180 180 ndlp->rport = NULL; 181 181 ··· 263 263 } else { 264 264 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, 265 265 "3188 worker thread is stopped %s x%06x, " 266 - " rport x%px flg x%x load_flag x%x refcnt " 266 + " rport x%px flg x%x load_flag x%lx refcnt " 267 267 "%d\n", __func__, ndlp->nlp_DID, 268 268 ndlp->rport, ndlp->nlp_flag, 269 269 vport->load_flag, kref_read(&ndlp->kref)); ··· 911 911 free_evt = 0; 912 912 break; 913 913 case LPFC_EVT_RESET_HBA: 914 - if (!(phba->pport->load_flag & FC_UNLOADING)) 914 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 915 915 lpfc_reset_hba(phba); 916 916 break; 917 917 } ··· 1149 1149 void 1150 1150 lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove) 1151 1151 { 1152 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1153 1152 struct lpfc_hba *phba = vport->phba; 1154 1153 struct lpfc_nodelist *ndlp, *next_ndlp; 1155 1154 ··· 1179 1180 if (phba->sli_rev == LPFC_SLI_REV4) 1180 1181 lpfc_sli4_unreg_all_rpis(vport); 1181 1182 lpfc_mbx_unreg_vpi(vport); 1182 - spin_lock_irq(shost->host_lock); 1183 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 1184 - spin_unlock_irq(shost->host_lock); 1183 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 1185 1184 } 1186 1185 } 1187 1186 ··· 1207 1210 lpfc_linkdown_port(struct lpfc_vport *vport) 1208 1211 { 1209 1212 struct lpfc_hba *phba = vport->phba; 1210 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1213 + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1211 1214 1212 1215 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME) 1213 1216 fc_host_post_event(shost, fc_get_event_number(), ··· 1220 1223 lpfc_port_link_failure(vport); 1221 1224 1222 1225 /* Stop delayed Nport discovery */ 1223 - spin_lock_irq(shost->host_lock); 1224 - vport->fc_flag &= ~FC_DISC_DELAYED; 1225 - spin_unlock_irq(shost->host_lock); 1226 + clear_bit(FC_DISC_DELAYED, &vport->fc_flag); 1226 1227 del_timer_sync(&vport->delayed_disc_tmo); 1227 1228 1228 1229 if (phba->sli_rev == LPFC_SLI_REV4 && ··· 1235 1240 lpfc_linkdown(struct lpfc_hba *phba) 1236 1241 { 1237 1242 struct lpfc_vport *vport = phba->pport; 1238 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1243 + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1239 1244 struct lpfc_vport **vports; 1240 1245 LPFC_MBOXQ_t *mb; 1241 1246 int i; ··· 1268 1273 phba->sli4_hba.link_state.logical_speed = 1269 1274 LPFC_LINK_SPEED_UNKNOWN; 1270 1275 } 1271 - spin_lock_irq(shost->host_lock); 1272 - phba->pport->fc_flag &= ~FC_LBIT; 1273 - spin_unlock_irq(shost->host_lock); 1276 + clear_bit(FC_LBIT, &phba->pport->fc_flag); 1274 1277 } 1275 1278 vports = lpfc_create_vport_work_array(phba); 1276 1279 if (vports != NULL) { ··· 1306 1313 1307 1314 skip_unreg_did: 1308 1315 /* Setup myDID for link up if we are in pt2pt mode */ 1309 - if (phba->pport->fc_flag & FC_PT2PT) { 1316 + if (test_bit(FC_PT2PT, &phba->pport->fc_flag)) { 1310 1317 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1311 1318 if (mb) { 1312 1319 lpfc_config_link(phba, mb); ··· 1317 1324 mempool_free(mb, phba->mbox_mem_pool); 1318 1325 } 1319 1326 } 1327 + clear_bit(FC_PT2PT, &phba->pport->fc_flag); 1328 + clear_bit(FC_PT2PT_PLOGI, &phba->pport->fc_flag); 1320 1329 spin_lock_irq(shost->host_lock); 1321 - phba->pport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI); 1322 1330 phba->pport->rcv_flogi_cnt = 0; 1323 1331 spin_unlock_irq(shost->host_lock); 1324 1332 } ··· 1358 1364 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1359 1365 struct lpfc_hba *phba = vport->phba; 1360 1366 1361 - if ((vport->load_flag & FC_UNLOADING) != 0) 1367 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 1362 1368 return; 1363 1369 1364 1370 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, ··· 1370 1376 (vport != phba->pport)) 1371 1377 return; 1372 1378 1373 - if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME) 1374 - fc_host_post_event(shost, fc_get_event_number(), 1375 - FCH_EVT_LINKUP, 0); 1379 + if (phba->defer_flogi_acc_flag) { 1380 + clear_bit(FC_ABORT_DISCOVERY, &vport->fc_flag); 1381 + clear_bit(FC_RSCN_MODE, &vport->fc_flag); 1382 + clear_bit(FC_NLP_MORE, &vport->fc_flag); 1383 + clear_bit(FC_RSCN_DISCOVERY, &vport->fc_flag); 1384 + } else { 1385 + clear_bit(FC_PT2PT, &vport->fc_flag); 1386 + clear_bit(FC_PT2PT_PLOGI, &vport->fc_flag); 1387 + clear_bit(FC_ABORT_DISCOVERY, &vport->fc_flag); 1388 + clear_bit(FC_RSCN_MODE, &vport->fc_flag); 1389 + clear_bit(FC_NLP_MORE, &vport->fc_flag); 1390 + clear_bit(FC_RSCN_DISCOVERY, &vport->fc_flag); 1391 + } 1392 + set_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 1376 1393 1377 1394 spin_lock_irq(shost->host_lock); 1378 - if (phba->defer_flogi_acc_flag) 1379 - vport->fc_flag &= ~(FC_ABORT_DISCOVERY | FC_RSCN_MODE | 1380 - FC_NLP_MORE | FC_RSCN_DISCOVERY); 1381 - else 1382 - vport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | 1383 - FC_ABORT_DISCOVERY | FC_RSCN_MODE | 1384 - FC_NLP_MORE | FC_RSCN_DISCOVERY); 1385 - vport->fc_flag |= FC_NDISC_ACTIVE; 1386 1395 vport->fc_ns_retry = 0; 1387 1396 spin_unlock_irq(shost->host_lock); 1388 1397 lpfc_setup_fdmi_mask(vport); ··· 1436 1439 lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 1437 1440 { 1438 1441 struct lpfc_vport *vport = pmb->vport; 1439 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1440 1442 struct lpfc_sli *psli = &phba->sli; 1441 1443 MAILBOX_t *mb = &pmb->u.mb; 1442 1444 uint32_t control; ··· 1474 1478 "0225 Device Discovery completes\n"); 1475 1479 mempool_free(pmb, phba->mbox_mem_pool); 1476 1480 1477 - spin_lock_irq(shost->host_lock); 1478 - vport->fc_flag &= ~FC_ABORT_DISCOVERY; 1479 - spin_unlock_irq(shost->host_lock); 1481 + clear_bit(FC_ABORT_DISCOVERY, &vport->fc_flag); 1480 1482 1481 1483 lpfc_can_disctmo(vport); 1482 1484 ··· 1511 1517 return; 1512 1518 1513 1519 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP && 1514 - vport->fc_flag & FC_PUBLIC_LOOP && 1515 - !(vport->fc_flag & FC_LBIT)) { 1520 + test_bit(FC_PUBLIC_LOOP, &vport->fc_flag) && 1521 + !test_bit(FC_LBIT, &vport->fc_flag)) { 1516 1522 /* Need to wait for FAN - use discovery timer 1517 1523 * for timeout. port_state is identically 1518 1524 * LPFC_LOCAL_CFG_LINK while waiting for FAN ··· 1554 1560 lpfc_initial_flogi(vport); 1555 1561 } 1556 1562 } else { 1557 - if (vport->fc_flag & FC_PT2PT) 1563 + if (test_bit(FC_PT2PT, &vport->fc_flag)) 1558 1564 lpfc_disc_start(vport); 1559 1565 } 1560 1566 return; ··· 1878 1884 phba->fcf.fcf_flag |= (FCF_SCAN_DONE | FCF_IN_USE); 1879 1885 phba->hba_flag &= ~FCF_TS_INPROG; 1880 1886 if (phba->pport->port_state != LPFC_FLOGI && 1881 - phba->pport->fc_flag & FC_FABRIC) { 1887 + test_bit(FC_FABRIC, &phba->pport->fc_flag)) { 1882 1888 phba->hba_flag |= FCF_RR_INPROG; 1883 1889 spin_unlock_irq(&phba->hbalock); 1884 1890 lpfc_initial_flogi(phba->pport); ··· 2736 2742 lpfc_printf_log(phba, KERN_INFO, LOG_FIP, 2737 2743 "2836 New FCF matches in-use " 2738 2744 "FCF (x%x), port_state:x%x, " 2739 - "fc_flag:x%x\n", 2745 + "fc_flag:x%lx\n", 2740 2746 phba->fcf.current_rec.fcf_indx, 2741 2747 phba->pport->port_state, 2742 2748 phba->pport->fc_flag); ··· 3212 3218 { 3213 3219 struct lpfc_vport *vport = mboxq->vport; 3214 3220 struct lpfc_nodelist *ndlp; 3215 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 3216 3221 3217 3222 if (mboxq->u.mb.mbxStatus) { 3218 3223 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 3221 3228 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 3222 3229 return; 3223 3230 } 3224 - spin_lock_irq(shost->host_lock); 3225 - vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; 3226 - spin_unlock_irq(shost->host_lock); 3231 + clear_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 3227 3232 3228 3233 /* If this port is physical port or FDISC is done, do reg_vpi */ 3229 3234 if ((phba->pport == vport) || (vport->port_state == LPFC_FDISC)) { ··· 3319 3328 FC_VPORT_LINKDOWN); 3320 3329 continue; 3321 3330 } 3322 - if (vports[i]->fc_flag & FC_VPORT_NEEDS_INIT_VPI) { 3331 + if (test_bit(FC_VPORT_NEEDS_INIT_VPI, 3332 + &vports[i]->fc_flag)) { 3323 3333 lpfc_issue_init_vpi(vports[i]); 3324 3334 continue; 3325 3335 } ··· 3372 3380 * Unless this was a VFI update and we are in PT2PT mode, then 3373 3381 * we should drop through to set the port state to ready. 3374 3382 */ 3375 - if (vport->fc_flag & FC_VFI_REGISTERED) 3383 + if (test_bit(FC_VFI_REGISTERED, &vport->fc_flag)) 3376 3384 if (!(phba->sli_rev == LPFC_SLI_REV4 && 3377 - vport->fc_flag & FC_PT2PT)) 3385 + test_bit(FC_PT2PT, &vport->fc_flag))) 3378 3386 goto out_free_mem; 3379 3387 3380 3388 /* The VPI is implicitly registered when the VFI is registered */ 3389 + set_bit(FC_VFI_REGISTERED, &vport->fc_flag); 3390 + clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 3391 + clear_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 3381 3392 spin_lock_irq(shost->host_lock); 3382 3393 vport->vpi_state |= LPFC_VPI_REGISTERED; 3383 - vport->fc_flag |= FC_VFI_REGISTERED; 3384 - vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 3385 - vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; 3386 3394 spin_unlock_irq(shost->host_lock); 3387 3395 3388 3396 /* In case SLI4 FC loopback test, we are ready */ ··· 3393 3401 } 3394 3402 3395 3403 lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI, 3396 - "3313 cmpl reg vfi port_state:%x fc_flag:%x myDid:%x " 3397 - "alpacnt:%d LinkState:%x topology:%x\n", 3404 + "3313 cmpl reg vfi port_state:%x fc_flag:%lx " 3405 + "myDid:%x alpacnt:%d LinkState:%x topology:%x\n", 3398 3406 vport->port_state, vport->fc_flag, vport->fc_myDID, 3399 3407 vport->phba->alpa_map[0], 3400 3408 phba->link_state, phba->fc_topology); ··· 3404 3412 * For private loop or for NPort pt2pt, 3405 3413 * just start discovery and we are done. 3406 3414 */ 3407 - if ((vport->fc_flag & FC_PT2PT) || 3408 - ((phba->fc_topology == LPFC_TOPOLOGY_LOOP) && 3409 - !(vport->fc_flag & FC_PUBLIC_LOOP))) { 3415 + if (test_bit(FC_PT2PT, &vport->fc_flag) || 3416 + (phba->fc_topology == LPFC_TOPOLOGY_LOOP && 3417 + !test_bit(FC_PUBLIC_LOOP, &vport->fc_flag))) { 3410 3418 3411 3419 /* Use loop map to make discovery list */ 3412 3420 lpfc_disc_list_loopmap(vport); 3413 3421 /* Start discovery */ 3414 - if (vport->fc_flag & FC_PT2PT) 3422 + if (test_bit(FC_PT2PT, &vport->fc_flag)) 3415 3423 vport->port_state = LPFC_VPORT_READY; 3416 3424 else 3417 3425 lpfc_disc_start(vport); ··· 3488 3496 { 3489 3497 struct lpfc_vport *vport = phba->pport; 3490 3498 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL; 3491 - struct Scsi_Host *shost; 3492 3499 int i; 3493 3500 int rc; 3494 3501 struct fcf_record *fcf_record; 3495 - uint32_t fc_flags = 0; 3496 3502 unsigned long iflags; 3497 3503 3498 3504 spin_lock_irqsave(&phba->hbalock, iflags); ··· 3527 3537 phba->fc_topology = bf_get(lpfc_mbx_read_top_topology, la); 3528 3538 phba->link_flag &= ~(LS_NPIV_FAB_SUPPORTED | LS_CT_VEN_RPA); 3529 3539 3530 - shost = lpfc_shost_from_vport(vport); 3531 3540 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { 3532 3541 phba->sli3_options &= ~LPFC_SLI3_NPIV_ENABLED; 3533 3542 ··· 3539 3550 "topology\n"); 3540 3551 /* Get Loop Map information */ 3541 3552 if (bf_get(lpfc_mbx_read_top_il, la)) 3542 - fc_flags |= FC_LBIT; 3553 + set_bit(FC_LBIT, &vport->fc_flag); 3543 3554 3544 3555 vport->fc_myDID = bf_get(lpfc_mbx_read_top_alpa_granted, la); 3545 3556 i = la->lilpBde64.tus.f.bdeSize; ··· 3588 3599 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; 3589 3600 } 3590 3601 vport->fc_myDID = phba->fc_pref_DID; 3591 - fc_flags |= FC_LBIT; 3602 + set_bit(FC_LBIT, &vport->fc_flag); 3592 3603 } 3593 3604 spin_unlock_irqrestore(&phba->hbalock, iflags); 3594 - 3595 - if (fc_flags) { 3596 - spin_lock_irqsave(shost->host_lock, iflags); 3597 - vport->fc_flag |= fc_flags; 3598 - spin_unlock_irqrestore(shost->host_lock, iflags); 3599 - } 3600 3605 3601 3606 lpfc_linkup(phba); 3602 3607 sparam_mbox = NULL; ··· 3734 3751 lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 3735 3752 { 3736 3753 struct lpfc_vport *vport = pmb->vport; 3737 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 3738 3754 struct lpfc_mbx_read_top *la; 3739 3755 struct lpfc_sli_ring *pring; 3740 3756 MAILBOX_t *mb = &pmb->u.mb; 3741 3757 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); 3742 3758 uint8_t attn_type; 3743 - unsigned long iflags; 3744 3759 3745 3760 /* Unblock ELS traffic */ 3746 3761 pring = lpfc_phba_elsring(phba); ··· 3760 3779 3761 3780 memcpy(&phba->alpa_map[0], mp->virt, 128); 3762 3781 3763 - spin_lock_irqsave(shost->host_lock, iflags); 3764 3782 if (bf_get(lpfc_mbx_read_top_pb, la)) 3765 - vport->fc_flag |= FC_BYPASSED_MODE; 3783 + set_bit(FC_BYPASSED_MODE, &vport->fc_flag); 3766 3784 else 3767 - vport->fc_flag &= ~FC_BYPASSED_MODE; 3768 - spin_unlock_irqrestore(shost->host_lock, iflags); 3785 + clear_bit(FC_BYPASSED_MODE, &vport->fc_flag); 3769 3786 3770 3787 if (phba->fc_eventTag <= la->eventTag) { 3771 3788 phba->fc_stat.LinkMultiEvent++; ··· 3811 3832 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3812 3833 "1308 Link Down Event in loop back mode " 3813 3834 "x%x received " 3814 - "Data: x%x x%x x%x\n", 3835 + "Data: x%x x%x x%lx\n", 3815 3836 la->eventTag, phba->fc_eventTag, 3816 3837 phba->pport->port_state, vport->fc_flag); 3817 3838 else if (attn_type == LPFC_ATT_UNEXP_WWPN) 3818 3839 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3819 3840 "1313 Link Down Unexpected FA WWPN Event x%x " 3820 - "received Data: x%x x%x x%x x%x\n", 3841 + "received Data: x%x x%x x%lx x%x\n", 3821 3842 la->eventTag, phba->fc_eventTag, 3822 3843 phba->pport->port_state, vport->fc_flag, 3823 3844 bf_get(lpfc_mbx_read_top_fa, la)); 3824 3845 else 3825 3846 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 3826 3847 "1305 Link Down Event x%x received " 3827 - "Data: x%x x%x x%x x%x\n", 3848 + "Data: x%x x%x x%lx x%x\n", 3828 3849 la->eventTag, phba->fc_eventTag, 3829 3850 phba->pport->port_state, vport->fc_flag, 3830 3851 bf_get(lpfc_mbx_read_top_fa, la)); ··· 3924 3945 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 3925 3946 "2798 Unreg_vpi failed vpi 0x%x, mb status = 0x%x\n", 3926 3947 vport->vpi, mb->mbxStatus); 3927 - if (!(phba->pport->load_flag & FC_UNLOADING)) 3948 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 3928 3949 lpfc_workq_post_event(phba, NULL, NULL, 3929 3950 LPFC_EVT_RESET_HBA); 3930 3951 } 3952 + 3953 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 3931 3954 spin_lock_irq(shost->host_lock); 3932 3955 vport->vpi_state &= ~LPFC_VPI_REGISTERED; 3933 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 3934 3956 spin_unlock_irq(shost->host_lock); 3935 3957 mempool_free(pmb, phba->mbox_mem_pool); 3936 3958 lpfc_cleanup_vports_rrqs(vport, NULL); ··· 3939 3959 * This shost reference might have been taken at the beginning of 3940 3960 * lpfc_vport_delete() 3941 3961 */ 3942 - if ((vport->load_flag & FC_UNLOADING) && (vport != phba->pport)) 3962 + if (test_bit(FC_UNLOADING, &vport->load_flag) && vport != phba->pport) 3943 3963 scsi_host_put(shost); 3944 3964 } 3945 3965 ··· 3982 4002 "0912 cmpl_reg_vpi, mb status = 0x%x\n", 3983 4003 mb->mbxStatus); 3984 4004 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 3985 - spin_lock_irq(shost->host_lock); 3986 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 3987 - spin_unlock_irq(shost->host_lock); 4005 + clear_bit(FC_FABRIC, &vport->fc_flag); 4006 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 3988 4007 vport->fc_myDID = 0; 3989 4008 3990 4009 if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) || ··· 3996 4017 goto out; 3997 4018 } 3998 4019 4020 + clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 3999 4021 spin_lock_irq(shost->host_lock); 4000 4022 vport->vpi_state |= LPFC_VPI_REGISTERED; 4001 - vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 4002 4023 spin_unlock_irq(shost->host_lock); 4003 4024 vport->num_disc_nodes = 0; 4004 4025 /* go thru NPR list and issue ELS PLOGIs */ 4005 - if (vport->fc_npr_cnt) 4026 + if (atomic_read(&vport->fc_npr_cnt)) 4006 4027 lpfc_els_disc_plogi(vport); 4007 4028 4008 4029 if (!vport->num_disc_nodes) { 4009 - spin_lock_irq(shost->host_lock); 4010 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 4011 - spin_unlock_irq(shost->host_lock); 4030 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 4012 4031 lpfc_can_disctmo(vport); 4013 4032 } 4014 4033 vport->port_state = LPFC_VPORT_READY; ··· 4170 4193 struct lpfc_vport *vport = pmb->vport; 4171 4194 MAILBOX_t *mb = &pmb->u.mb; 4172 4195 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; 4173 - struct Scsi_Host *shost; 4174 4196 4175 4197 pmb->ctx_ndlp = NULL; 4176 4198 ··· 4208 4232 if (vport->port_state == LPFC_FABRIC_CFG_LINK) { 4209 4233 /* when physical port receive logo donot start 4210 4234 * vport discovery */ 4211 - if (!(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) 4235 + if (!test_and_clear_bit(FC_LOGO_RCVD_DID_CHNG, &vport->fc_flag)) 4212 4236 lpfc_start_fdiscs(phba); 4213 - else { 4214 - shost = lpfc_shost_from_vport(vport); 4215 - spin_lock_irq(shost->host_lock); 4216 - vport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG ; 4217 - spin_unlock_irq(shost->host_lock); 4218 - } 4219 4237 lpfc_do_scr_ns_plogi(phba, vport); 4220 4238 } 4221 4239 ··· 4490 4520 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); 4491 4521 4492 4522 /* Don't add the remote port if unloading. */ 4493 - if (vport->load_flag & FC_UNLOADING) 4523 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 4494 4524 return; 4495 4525 4496 4526 ndlp->rport = rport = fc_remote_port_add(shost, 0, &rport_ids); ··· 4570 4600 static void 4571 4601 lpfc_nlp_counters(struct lpfc_vport *vport, int state, int count) 4572 4602 { 4573 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4574 - unsigned long iflags; 4575 - 4576 - spin_lock_irqsave(shost->host_lock, iflags); 4577 4603 switch (state) { 4578 4604 case NLP_STE_UNUSED_NODE: 4579 - vport->fc_unused_cnt += count; 4605 + atomic_add(count, &vport->fc_unused_cnt); 4580 4606 break; 4581 4607 case NLP_STE_PLOGI_ISSUE: 4582 - vport->fc_plogi_cnt += count; 4608 + atomic_add(count, &vport->fc_plogi_cnt); 4583 4609 break; 4584 4610 case NLP_STE_ADISC_ISSUE: 4585 - vport->fc_adisc_cnt += count; 4611 + atomic_add(count, &vport->fc_adisc_cnt); 4586 4612 break; 4587 4613 case NLP_STE_REG_LOGIN_ISSUE: 4588 - vport->fc_reglogin_cnt += count; 4614 + atomic_add(count, &vport->fc_reglogin_cnt); 4589 4615 break; 4590 4616 case NLP_STE_PRLI_ISSUE: 4591 - vport->fc_prli_cnt += count; 4617 + atomic_add(count, &vport->fc_prli_cnt); 4592 4618 break; 4593 4619 case NLP_STE_UNMAPPED_NODE: 4594 - vport->fc_unmap_cnt += count; 4620 + atomic_add(count, &vport->fc_unmap_cnt); 4595 4621 break; 4596 4622 case NLP_STE_MAPPED_NODE: 4597 - vport->fc_map_cnt += count; 4623 + atomic_add(count, &vport->fc_map_cnt); 4598 4624 break; 4599 4625 case NLP_STE_NPR_NODE: 4600 - if (vport->fc_npr_cnt == 0 && count == -1) 4601 - vport->fc_npr_cnt = 0; 4626 + if (!atomic_read(&vport->fc_npr_cnt) && count == -1) 4627 + atomic_set(&vport->fc_npr_cnt, 0); 4602 4628 else 4603 - vport->fc_npr_cnt += count; 4629 + atomic_add(count, &vport->fc_npr_cnt); 4604 4630 break; 4605 4631 } 4606 - spin_unlock_irqrestore(shost->host_lock, iflags); 4607 4632 } 4608 4633 4609 4634 /* Register a node with backend if not already done */ ··· 4830 4865 lpfc_nlp_set_state(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 4831 4866 int state) 4832 4867 { 4833 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4834 4868 int old_state = ndlp->nlp_state; 4835 4869 int node_dropped = ndlp->nlp_flag & NLP_DROPPED; 4836 4870 char name1[16], name2[16]; 4871 + unsigned long iflags; 4837 4872 4838 4873 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE, 4839 4874 "0904 NPort state transition x%06x, %s -> %s\n", ··· 4860 4895 } 4861 4896 4862 4897 if (list_empty(&ndlp->nlp_listp)) { 4863 - spin_lock_irq(shost->host_lock); 4898 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 4864 4899 list_add_tail(&ndlp->nlp_listp, &vport->fc_nodes); 4865 - spin_unlock_irq(shost->host_lock); 4900 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 4866 4901 } else if (old_state) 4867 4902 lpfc_nlp_counters(vport, old_state, -1); 4868 4903 ··· 4874 4909 void 4875 4910 lpfc_enqueue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 4876 4911 { 4877 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4912 + unsigned long iflags; 4878 4913 4879 4914 if (list_empty(&ndlp->nlp_listp)) { 4880 - spin_lock_irq(shost->host_lock); 4915 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 4881 4916 list_add_tail(&ndlp->nlp_listp, &vport->fc_nodes); 4882 - spin_unlock_irq(shost->host_lock); 4917 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 4883 4918 } 4884 4919 } 4885 4920 4886 4921 void 4887 4922 lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 4888 4923 { 4889 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4924 + unsigned long iflags; 4890 4925 4891 4926 lpfc_cancel_retry_delay_tmo(vport, ndlp); 4892 4927 if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp)) 4893 4928 lpfc_nlp_counters(vport, ndlp->nlp_state, -1); 4894 - spin_lock_irq(shost->host_lock); 4929 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 4895 4930 list_del_init(&ndlp->nlp_listp); 4896 - spin_unlock_irq(shost->host_lock); 4931 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 4897 4932 lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, 4898 4933 NLP_STE_UNUSED_NODE); 4899 4934 } ··· 4968 5003 void 4969 5004 lpfc_set_disctmo(struct lpfc_vport *vport) 4970 5005 { 4971 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 4972 5006 struct lpfc_hba *phba = vport->phba; 4973 5007 uint32_t tmo; 4974 5008 ··· 4989 5025 } 4990 5026 4991 5027 mod_timer(&vport->fc_disctmo, jiffies + msecs_to_jiffies(1000 * tmo)); 4992 - spin_lock_irq(shost->host_lock); 4993 - vport->fc_flag |= FC_DISC_TMO; 4994 - spin_unlock_irq(shost->host_lock); 5028 + set_bit(FC_DISC_TMO, &vport->fc_flag); 4995 5029 4996 5030 /* Start Discovery Timer state <hba_state> */ 4997 5031 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 4998 5032 "0247 Start Discovery Timer state x%x " 4999 5033 "Data: x%x x%lx x%x x%x\n", 5000 5034 vport->port_state, tmo, 5001 - (unsigned long)&vport->fc_disctmo, vport->fc_plogi_cnt, 5002 - vport->fc_adisc_cnt); 5035 + (unsigned long)&vport->fc_disctmo, 5036 + atomic_read(&vport->fc_plogi_cnt), 5037 + atomic_read(&vport->fc_adisc_cnt)); 5003 5038 5004 5039 return; 5005 5040 } ··· 5009 5046 int 5010 5047 lpfc_can_disctmo(struct lpfc_vport *vport) 5011 5048 { 5012 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 5013 5049 unsigned long iflags; 5014 5050 5015 5051 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, ··· 5016 5054 vport->port_state, vport->fc_ns_retry, vport->fc_flag); 5017 5055 5018 5056 /* Turn off discovery timer if its running */ 5019 - if (vport->fc_flag & FC_DISC_TMO || 5057 + if (test_bit(FC_DISC_TMO, &vport->fc_flag) || 5020 5058 timer_pending(&vport->fc_disctmo)) { 5021 - spin_lock_irqsave(shost->host_lock, iflags); 5022 - vport->fc_flag &= ~FC_DISC_TMO; 5023 - spin_unlock_irqrestore(shost->host_lock, iflags); 5059 + clear_bit(FC_DISC_TMO, &vport->fc_flag); 5024 5060 del_timer_sync(&vport->fc_disctmo); 5025 5061 spin_lock_irqsave(&vport->work_port_lock, iflags); 5026 5062 vport->work_port_events &= ~WORKER_DISC_TMO; ··· 5028 5068 /* Cancel Discovery Timer state <hba_state> */ 5029 5069 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5030 5070 "0248 Cancel Discovery Timer state x%x " 5031 - "Data: x%x x%x x%x\n", 5071 + "Data: x%lx x%x x%x\n", 5032 5072 vport->port_state, vport->fc_flag, 5033 - vport->fc_plogi_cnt, vport->fc_adisc_cnt); 5073 + atomic_read(&vport->fc_plogi_cnt), 5074 + atomic_read(&vport->fc_adisc_cnt)); 5034 5075 return 0; 5035 5076 } 5036 5077 ··· 5235 5274 mbox->mbox_cmpl = lpfc_nlp_logo_unreg; 5236 5275 5237 5276 } else if (phba->sli_rev == LPFC_SLI_REV4 && 5238 - (!(vport->load_flag & FC_UNLOADING)) && 5277 + !test_bit(FC_UNLOADING, &vport->load_flag) && 5239 5278 (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= 5240 5279 LPFC_SLI_INTF_IF_TYPE_2) && 5241 5280 (kref_read(&ndlp->kref) > 0)) { 5242 5281 mbox->mbox_cmpl = lpfc_sli4_unreg_rpi_cmpl_clr; 5243 5282 } else { 5244 - if (vport->load_flag & FC_UNLOADING) { 5283 + if (test_bit(FC_UNLOADING, &vport->load_flag)) { 5245 5284 if (phba->sli_rev == LPFC_SLI_REV4) { 5246 5285 spin_lock_irqsave(&ndlp->lock, iflags); 5247 5286 ndlp->nlp_flag |= NLP_RELEASE_RPI; ··· 5317 5356 acc_plogi = 0; 5318 5357 if (((ndlp->nlp_DID & Fabric_DID_MASK) != 5319 5358 Fabric_DID_MASK) && 5320 - (!(vport->fc_flag & FC_OFFLINE_MODE))) 5359 + (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag))) 5321 5360 ndlp->nlp_flag |= NLP_UNREG_INP; 5322 5361 5323 5362 lpfc_printf_vlog(vport, KERN_INFO, ··· 5349 5388 * will issue a LOGO here and keep the rpi alive if 5350 5389 * not unloading. 5351 5390 */ 5352 - if (!(vport->load_flag & FC_UNLOADING)) { 5391 + if (!test_bit(FC_UNLOADING, &vport->load_flag)) { 5353 5392 ndlp->nlp_flag &= ~NLP_UNREG_INP; 5354 5393 lpfc_issue_els_logo(vport, ndlp, 0); 5355 5394 ndlp->nlp_prev_state = ndlp->nlp_state; ··· 5385 5424 { 5386 5425 struct lpfc_vport **vports; 5387 5426 struct lpfc_nodelist *ndlp; 5388 - struct Scsi_Host *shost; 5389 5427 int i; 5428 + unsigned long iflags; 5390 5429 5391 5430 vports = lpfc_create_vport_work_array(phba); 5392 5431 if (!vports) { ··· 5395 5434 return; 5396 5435 } 5397 5436 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 5398 - shost = lpfc_shost_from_vport(vports[i]); 5399 - spin_lock_irq(shost->host_lock); 5437 + spin_lock_irqsave(&vports[i]->fc_nodes_list_lock, iflags); 5400 5438 list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { 5401 5439 if (ndlp->nlp_flag & NLP_RPI_REGISTERED) { 5402 5440 /* The mempool_alloc might sleep */ 5403 - spin_unlock_irq(shost->host_lock); 5441 + spin_unlock_irqrestore(&vports[i]->fc_nodes_list_lock, 5442 + iflags); 5404 5443 lpfc_unreg_rpi(vports[i], ndlp); 5405 - spin_lock_irq(shost->host_lock); 5444 + spin_lock_irqsave(&vports[i]->fc_nodes_list_lock, 5445 + iflags); 5406 5446 } 5407 5447 } 5408 - spin_unlock_irq(shost->host_lock); 5448 + spin_unlock_irqrestore(&vports[i]->fc_nodes_list_lock, iflags); 5409 5449 } 5410 5450 lpfc_destroy_vport_work_array(phba, vports); 5411 5451 } ··· 5648 5686 struct lpfc_nodelist * 5649 5687 lpfc_findnode_mapped(struct lpfc_vport *vport) 5650 5688 { 5651 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 5652 5689 struct lpfc_nodelist *ndlp; 5653 5690 uint32_t data1; 5654 5691 unsigned long iflags; 5655 5692 5656 - spin_lock_irqsave(shost->host_lock, iflags); 5693 + spin_lock_irqsave(&vport->fc_nodes_list_lock, iflags); 5657 5694 5658 5695 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 5659 5696 if (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE || ··· 5661 5700 ((uint32_t)ndlp->nlp_xri << 16) | 5662 5701 ((uint32_t)ndlp->nlp_type << 8) | 5663 5702 ((uint32_t)ndlp->nlp_rpi & 0xff)); 5664 - spin_unlock_irqrestore(shost->host_lock, iflags); 5703 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, 5704 + iflags); 5665 5705 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE_VERBOSE, 5666 5706 "2025 FIND node DID MAPPED " 5667 5707 "Data: x%px x%x x%x x%x x%px\n", ··· 5672 5710 return ndlp; 5673 5711 } 5674 5712 } 5675 - spin_unlock_irqrestore(shost->host_lock, iflags); 5713 + spin_unlock_irqrestore(&vport->fc_nodes_list_lock, iflags); 5676 5714 5677 5715 /* FIND node did <did> NOT FOUND */ 5678 5716 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE, ··· 5689 5727 if (!ndlp) { 5690 5728 if (vport->phba->nvmet_support) 5691 5729 return NULL; 5692 - if ((vport->fc_flag & FC_RSCN_MODE) != 0 && 5730 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag) && 5693 5731 lpfc_rscn_payload_check(vport, did) == 0) 5694 5732 return NULL; 5695 5733 ndlp = lpfc_nlp_init(vport, did); ··· 5699 5737 5700 5738 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5701 5739 "6453 Setup New Node 2B_DISC x%x " 5702 - "Data:x%x x%x x%x\n", 5740 + "Data:x%x x%x x%lx\n", 5703 5741 ndlp->nlp_DID, ndlp->nlp_flag, 5704 5742 ndlp->nlp_state, vport->fc_flag); 5705 5743 ··· 5713 5751 * The goal is to allow the target to reset its state and clear 5714 5752 * pending IO in preparation for the initiator to recover. 5715 5753 */ 5716 - if ((vport->fc_flag & FC_RSCN_MODE) && 5717 - !(vport->fc_flag & FC_NDISC_ACTIVE)) { 5754 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag) && 5755 + !test_bit(FC_NDISC_ACTIVE, &vport->fc_flag)) { 5718 5756 if (lpfc_rscn_payload_check(vport, did)) { 5719 5757 5720 5758 /* Since this node is marked for discovery, ··· 5724 5762 5725 5763 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5726 5764 "6455 Setup RSCN Node 2B_DISC x%x " 5727 - "Data:x%x x%x x%x\n", 5765 + "Data:x%x x%x x%lx\n", 5728 5766 ndlp->nlp_DID, ndlp->nlp_flag, 5729 5767 ndlp->nlp_state, vport->fc_flag); 5730 5768 ··· 5735 5773 */ 5736 5774 if (vport->phba->nvmet_support) 5737 5775 return ndlp; 5738 - 5739 - /* If we've already received a PLOGI from this NPort 5740 - * we don't need to try to discover it again. 5741 - */ 5742 - if (ndlp->nlp_flag & NLP_RCV_PLOGI && 5743 - !(ndlp->nlp_type & 5744 - (NLP_FCP_TARGET | NLP_NVME_TARGET))) 5745 - return NULL; 5746 5776 5747 5777 if (ndlp->nlp_state > NLP_STE_UNUSED_NODE && 5748 5778 ndlp->nlp_state < NLP_STE_PRLI_ISSUE) { ··· 5748 5794 } else { 5749 5795 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5750 5796 "6456 Skip Setup RSCN Node x%x " 5751 - "Data:x%x x%x x%x\n", 5797 + "Data:x%x x%x x%lx\n", 5752 5798 ndlp->nlp_DID, ndlp->nlp_flag, 5753 5799 ndlp->nlp_state, vport->fc_flag); 5754 5800 ndlp = NULL; ··· 5756 5802 } else { 5757 5803 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5758 5804 "6457 Setup Active Node 2B_DISC x%x " 5759 - "Data:x%x x%x x%x\n", 5805 + "Data:x%x x%x x%lx\n", 5760 5806 ndlp->nlp_DID, ndlp->nlp_flag, 5761 5807 ndlp->nlp_state, vport->fc_flag); 5762 5808 ··· 5884 5930 void 5885 5931 lpfc_disc_start(struct lpfc_vport *vport) 5886 5932 { 5887 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 5888 5933 struct lpfc_hba *phba = vport->phba; 5889 5934 uint32_t num_sent; 5890 5935 uint32_t clear_la_pending; ··· 5911 5958 /* Start Discovery state <hba_state> */ 5912 5959 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, 5913 5960 "0202 Start Discovery port state x%x " 5914 - "flg x%x Data: x%x x%x x%x\n", 5915 - vport->port_state, vport->fc_flag, vport->fc_plogi_cnt, 5916 - vport->fc_adisc_cnt, vport->fc_npr_cnt); 5961 + "flg x%lx Data: x%x x%x x%x\n", 5962 + vport->port_state, vport->fc_flag, 5963 + atomic_read(&vport->fc_plogi_cnt), 5964 + atomic_read(&vport->fc_adisc_cnt), 5965 + atomic_read(&vport->fc_npr_cnt)); 5917 5966 5918 5967 /* First do ADISCs - if any */ 5919 5968 num_sent = lpfc_els_disc_adisc(vport); ··· 5925 5970 5926 5971 /* Register the VPI for SLI3, NPIV only. */ 5927 5972 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 5928 - !(vport->fc_flag & FC_PT2PT) && 5929 - !(vport->fc_flag & FC_RSCN_MODE) && 5973 + !test_bit(FC_PT2PT, &vport->fc_flag) && 5974 + !test_bit(FC_RSCN_MODE, &vport->fc_flag) && 5930 5975 (phba->sli_rev < LPFC_SLI_REV4)) { 5931 5976 lpfc_issue_clear_la(phba, vport); 5932 5977 lpfc_issue_reg_vpi(phba, vport); ··· 5941 5986 /* If we get here, there is nothing to ADISC */ 5942 5987 lpfc_issue_clear_la(phba, vport); 5943 5988 5944 - if (!(vport->fc_flag & FC_ABORT_DISCOVERY)) { 5989 + if (!test_bit(FC_ABORT_DISCOVERY, &vport->fc_flag)) { 5945 5990 vport->num_disc_nodes = 0; 5946 5991 /* go thru NPR nodes and issue ELS PLOGIs */ 5947 - if (vport->fc_npr_cnt) 5992 + if (atomic_read(&vport->fc_npr_cnt)) 5948 5993 lpfc_els_disc_plogi(vport); 5949 5994 5950 5995 if (!vport->num_disc_nodes) { 5951 - spin_lock_irq(shost->host_lock); 5952 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 5953 - spin_unlock_irq(shost->host_lock); 5996 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 5954 5997 lpfc_can_disctmo(vport); 5955 5998 } 5956 5999 } ··· 5960 6007 if (num_sent) 5961 6008 return; 5962 6009 5963 - if (vport->fc_flag & FC_RSCN_MODE) { 6010 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 5964 6011 /* Check to see if more RSCNs came in while we 5965 6012 * were processing this one. 5966 6013 */ 5967 - if ((vport->fc_rscn_id_cnt == 0) && 5968 - (!(vport->fc_flag & FC_RSCN_DISCOVERY))) { 5969 - spin_lock_irq(shost->host_lock); 5970 - vport->fc_flag &= ~FC_RSCN_MODE; 5971 - spin_unlock_irq(shost->host_lock); 6014 + if (vport->fc_rscn_id_cnt == 0 && 6015 + !test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag)) { 6016 + clear_bit(FC_RSCN_MODE, &vport->fc_flag); 5972 6017 lpfc_can_disctmo(vport); 5973 - } else 6018 + } else { 5974 6019 lpfc_els_handle_rscn(vport); 6020 + } 5975 6021 } 5976 6022 } 5977 6023 return; ··· 6037 6085 struct lpfc_nodelist *ndlp, *next_ndlp; 6038 6086 struct lpfc_hba *phba = vport->phba; 6039 6087 6040 - if (vport->fc_plogi_cnt || vport->fc_adisc_cnt) { 6088 + if (atomic_read(&vport->fc_plogi_cnt) || 6089 + atomic_read(&vport->fc_adisc_cnt)) { 6041 6090 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, 6042 6091 nlp_listp) { 6043 6092 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE || ··· 6119 6166 static void 6120 6167 lpfc_disc_timeout_handler(struct lpfc_vport *vport) 6121 6168 { 6122 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 6123 6169 struct lpfc_hba *phba = vport->phba; 6124 6170 struct lpfc_sli *psli = &phba->sli; 6125 6171 struct lpfc_nodelist *ndlp, *next_ndlp; 6126 6172 LPFC_MBOXQ_t *initlinkmbox; 6127 6173 int rc, clrlaerr = 0; 6128 6174 6129 - if (!(vport->fc_flag & FC_DISC_TMO)) 6175 + if (!test_and_clear_bit(FC_DISC_TMO, &vport->fc_flag)) 6130 6176 return; 6131 - 6132 - spin_lock_irq(shost->host_lock); 6133 - vport->fc_flag &= ~FC_DISC_TMO; 6134 - spin_unlock_irq(shost->host_lock); 6135 6177 6136 6178 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 6137 6179 "disc timeout: state:x%x rtry:x%x flg:x%x", ··· 6281 6333 break; 6282 6334 6283 6335 case LPFC_VPORT_READY: 6284 - if (vport->fc_flag & FC_RSCN_MODE) { 6336 + if (test_bit(FC_RSCN_MODE, &vport->fc_flag)) { 6285 6337 lpfc_printf_vlog(vport, KERN_ERR, 6286 6338 LOG_TRACE_EVENT, 6287 6339 "0231 RSCN timeout Data: x%x " ··· 6698 6750 struct lpfc_vport **vports; 6699 6751 int i, ret = 0; 6700 6752 struct lpfc_nodelist *ndlp; 6701 - struct Scsi_Host *shost; 6753 + unsigned long iflags; 6702 6754 6703 6755 vports = lpfc_create_vport_work_array(phba); 6704 6756 ··· 6707 6759 return 1; 6708 6760 6709 6761 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 6710 - shost = lpfc_shost_from_vport(vports[i]); 6711 - spin_lock_irq(shost->host_lock); 6712 6762 /* 6713 6763 * IF the CVL_RCVD bit is not set then we have sent the 6714 6764 * flogi. 6715 6765 * If dev_loss fires while we are waiting we do not want to 6716 6766 * unreg the fcf. 6717 6767 */ 6718 - if (!(vports[i]->fc_flag & FC_VPORT_CVL_RCVD)) { 6719 - spin_unlock_irq(shost->host_lock); 6768 + if (!test_bit(FC_VPORT_CVL_RCVD, &vports[i]->fc_flag)) { 6720 6769 ret = 1; 6721 6770 goto out; 6722 6771 } 6772 + spin_lock_irqsave(&vports[i]->fc_nodes_list_lock, iflags); 6723 6773 list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { 6724 6774 if (ndlp->rport && 6725 6775 (ndlp->rport->roles & FC_RPORT_ROLE_FCP_TARGET)) { 6726 6776 ret = 1; 6727 - spin_unlock_irq(shost->host_lock); 6777 + spin_unlock_irqrestore(&vports[i]->fc_nodes_list_lock, 6778 + iflags); 6728 6779 goto out; 6729 6780 } else if (ndlp->nlp_flag & NLP_RPI_REGISTERED) { 6730 6781 ret = 1; ··· 6735 6788 ndlp->nlp_flag); 6736 6789 } 6737 6790 } 6738 - spin_unlock_irq(shost->host_lock); 6791 + spin_unlock_irqrestore(&vports[i]->fc_nodes_list_lock, iflags); 6739 6792 } 6740 6793 out: 6741 6794 lpfc_destroy_vport_work_array(phba, vports); ··· 6753 6806 lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) 6754 6807 { 6755 6808 struct lpfc_vport *vport = mboxq->vport; 6756 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 6757 6809 6758 6810 if (mboxq->u.mb.mbxStatus) { 6759 6811 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, ··· 6760 6814 "HBA state x%x\n", 6761 6815 mboxq->u.mb.mbxStatus, vport->port_state); 6762 6816 } 6763 - spin_lock_irq(shost->host_lock); 6764 - phba->pport->fc_flag &= ~FC_VFI_REGISTERED; 6765 - spin_unlock_irq(shost->host_lock); 6817 + clear_bit(FC_VFI_REGISTERED, &phba->pport->fc_flag); 6766 6818 mempool_free(mboxq, phba->mbox_mem_pool); 6767 6819 return; 6768 6820 } ··· 6824 6880 lpfc_mbx_unreg_vpi(vports[i]); 6825 6881 shost = lpfc_shost_from_vport(vports[i]); 6826 6882 spin_lock_irq(shost->host_lock); 6827 - vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 6828 6883 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; 6829 6884 spin_unlock_irq(shost->host_lock); 6885 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &vports[i]->fc_flag); 6830 6886 } 6831 6887 lpfc_destroy_vport_work_array(phba, vports); 6832 6888 if (i == 0 && (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED))) { ··· 6839 6895 lpfc_mbx_unreg_vpi(phba->pport); 6840 6896 shost = lpfc_shost_from_vport(phba->pport); 6841 6897 spin_lock_irq(shost->host_lock); 6842 - phba->pport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 6843 6898 phba->pport->vpi_state &= ~LPFC_VPI_REGISTERED; 6844 6899 spin_unlock_irq(shost->host_lock); 6900 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &phba->pport->fc_flag); 6845 6901 } 6846 6902 6847 6903 /* Cleanup any outstanding ELS commands */ ··· 6925 6981 * If driver is not unloading, check if there is any other 6926 6982 * FCF record that can be used for discovery. 6927 6983 */ 6928 - if ((phba->pport->load_flag & FC_UNLOADING) || 6929 - (phba->link_state < LPFC_LINK_UP)) 6984 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag) || 6985 + phba->link_state < LPFC_LINK_UP) 6930 6986 return; 6931 6987 6932 6988 /* This is considered as the initial FCF discovery scan */
+2 -2
drivers/scsi/lpfc/lpfc_hw4.h
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2009-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 4069 4069 #define LPFC_TRAILER_CODE_GRP5 0x5 4070 4070 #define LPFC_TRAILER_CODE_FC 0x10 4071 4071 #define LPFC_TRAILER_CODE_SLI 0x11 4072 - #define LPFC_TRAILER_CODE_CMSTAT 0x13 4073 4072 }; 4074 4073 4075 4074 struct lpfc_acqe_link { ··· 4338 4339 #define LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE 0x10 4339 4340 #define LPFC_SLI_EVENT_TYPE_CGN_SIGNAL 0x11 4340 4341 #define LPFC_SLI_EVENT_TYPE_RD_SIGNAL 0x12 4342 + #define LPFC_SLI_EVENT_TYPE_RESET_CM_STATS 0x13 4341 4343 }; 4342 4344 4343 4345 /*
+68 -69
drivers/scsi/lpfc/lpfc_init.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 94 94 static uint16_t lpfc_find_cpu_handle(struct lpfc_hba *, uint16_t, int); 95 95 static void lpfc_setup_bg(struct lpfc_hba *, struct Scsi_Host *); 96 96 static int lpfc_sli4_cgn_parm_chg_evt(struct lpfc_hba *); 97 + static void lpfc_sli4_async_cmstat_evt(struct lpfc_hba *phba); 97 98 static void lpfc_sli4_prep_dev_for_reset(struct lpfc_hba *phba); 98 99 99 100 static struct scsi_transport_template *lpfc_transport_template = NULL; ··· 892 891 readl(phba->HCregaddr); /* flush */ 893 892 } 894 893 895 - if (phba->pport->load_flag & FC_UNLOADING) 894 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 896 895 lpfc_cleanup_discovery_resources(phba->pport); 897 896 else { 898 897 vports = lpfc_create_vport_work_array(phba); ··· 1232 1231 1233 1232 phba = from_timer(phba, t, rrq_tmr); 1234 1233 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); 1235 - if (!(phba->pport->load_flag & FC_UNLOADING)) 1234 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1236 1235 phba->hba_flag |= HBA_RRQ_ACTIVE; 1237 1236 else 1238 1237 phba->hba_flag &= ~HBA_RRQ_ACTIVE; 1239 1238 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); 1240 1239 1241 - if (!(phba->pport->load_flag & FC_UNLOADING)) 1240 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1242 1241 lpfc_worker_wake_up(phba); 1243 1242 } 1244 1243 ··· 1269 1268 1270 1269 /* Check and reset heart-beat timer if necessary */ 1271 1270 mempool_free(pmboxq, phba->mbox_mem_pool); 1272 - if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && 1273 - !(phba->link_state == LPFC_HBA_ERROR) && 1274 - !(phba->pport->load_flag & FC_UNLOADING)) 1271 + if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) && 1272 + !(phba->link_state == LPFC_HBA_ERROR) && 1273 + !test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1275 1274 mod_timer(&phba->hb_tmofunc, 1276 1275 jiffies + 1277 1276 msecs_to_jiffies(1000 * LPFC_HB_MBOX_INTERVAL)); ··· 1298 1297 u32 i, idle_percent; 1299 1298 u64 wall, wall_idle, diff_wall, diff_idle, busy_time; 1300 1299 1301 - if (phba->pport->load_flag & FC_UNLOADING) 1300 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1302 1301 return; 1303 1302 1304 1303 if (phba->link_state == LPFC_HBA_ERROR || 1305 - phba->pport->fc_flag & FC_OFFLINE_MODE || 1304 + test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) || 1306 1305 phba->cmf_active_mode != LPFC_CFG_OFF) 1307 1306 goto requeue; 1308 1307 ··· 1359 1358 uint32_t usdelay; 1360 1359 int i; 1361 1360 1362 - if (!phba->cfg_auto_imax || phba->pport->load_flag & FC_UNLOADING) 1361 + if (!phba->cfg_auto_imax || 1362 + test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1363 1363 return; 1364 1364 1365 1365 if (phba->link_state == LPFC_HBA_ERROR || 1366 - phba->pport->fc_flag & FC_OFFLINE_MODE) 1366 + test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 1367 1367 goto requeue; 1368 1368 1369 1369 ena_delay = kcalloc(phba->sli4_hba.num_possible_cpu, sizeof(*ena_delay), ··· 1535 1533 } 1536 1534 lpfc_destroy_vport_work_array(phba, vports); 1537 1535 1538 - if ((phba->link_state == LPFC_HBA_ERROR) || 1539 - (phba->pport->load_flag & FC_UNLOADING) || 1540 - (phba->pport->fc_flag & FC_OFFLINE_MODE)) 1536 + if (phba->link_state == LPFC_HBA_ERROR || 1537 + test_bit(FC_UNLOADING, &phba->pport->load_flag) || 1538 + test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 1541 1539 return; 1542 1540 1543 1541 if (phba->elsbuf_cnt && ··· 1738 1736 break; 1739 1737 } 1740 1738 /* If driver is unloading let the worker thread continue */ 1741 - if (phba->pport->load_flag & FC_UNLOADING) { 1739 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 1742 1740 phba->work_hs = 0; 1743 1741 break; 1744 1742 } ··· 1749 1747 * first write to the host attention register clear the 1750 1748 * host status register. 1751 1749 */ 1752 - if ((!phba->work_hs) && (!(phba->pport->load_flag & FC_UNLOADING))) 1750 + if (!phba->work_hs && !test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1753 1751 phba->work_hs = old_host_status & ~HS_FFER1; 1754 1752 1755 1753 spin_lock_irq(&phba->hbalock); ··· 3087 3085 * The flush here is only when the pci slot 3088 3086 * is offline. 3089 3087 */ 3090 - if (vport->load_flag & FC_UNLOADING && 3088 + if (test_bit(FC_UNLOADING, &vport->load_flag) && 3091 3089 pci_channel_offline(phba->pcidev)) 3092 3090 lpfc_sli_flush_io_rings(vport->phba); 3093 3091 ··· 3413 3411 return; 3414 3412 3415 3413 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 3416 - if (vports[i]->load_flag & FC_UNLOADING) 3414 + if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) 3417 3415 continue; 3418 3416 3419 3417 list_for_each_entry_safe(ndlp, next_ndlp, ··· 3613 3611 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) 3614 3612 lpfc_destroy_expedite_pool(phba); 3615 3613 3616 - if (!(phba->pport->load_flag & FC_UNLOADING)) 3614 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 3617 3615 lpfc_sli_flush_io_rings(phba); 3618 3616 3619 3617 hwq_count = phba->cfg_hdw_queue; ··· 3699 3697 return 0; 3700 3698 vport = phba->pport; 3701 3699 3702 - if (!(vport->fc_flag & FC_OFFLINE_MODE)) 3700 + if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) 3703 3701 return 0; 3704 3702 3705 3703 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, ··· 3739 3737 vports = lpfc_create_vport_work_array(phba); 3740 3738 if (vports != NULL) { 3741 3739 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 3742 - struct Scsi_Host *shost; 3743 - shost = lpfc_shost_from_vport(vports[i]); 3744 - spin_lock_irq(shost->host_lock); 3745 - vports[i]->fc_flag &= ~FC_OFFLINE_MODE; 3740 + clear_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); 3746 3741 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) 3747 - vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 3742 + set_bit(FC_VPORT_NEEDS_REG_VPI, 3743 + &vports[i]->fc_flag); 3748 3744 if (phba->sli_rev == LPFC_SLI_REV4) { 3749 - vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 3745 + set_bit(FC_VPORT_NEEDS_INIT_VPI, 3746 + &vports[i]->fc_flag); 3750 3747 if ((vpis_cleared) && 3751 3748 (vports[i]->port_type != 3752 3749 LPFC_PHYSICAL_PORT)) 3753 3750 vports[i]->vpi = 0; 3754 3751 } 3755 - spin_unlock_irq(shost->host_lock); 3756 3752 } 3757 3753 } 3758 3754 lpfc_destroy_vport_work_array(phba, vports); ··· 3805 3805 int offline; 3806 3806 bool hba_pci_err; 3807 3807 3808 - if (vport->fc_flag & FC_OFFLINE_MODE) 3808 + if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) 3809 3809 return; 3810 3810 3811 3811 lpfc_block_mgmt_io(phba, mbx_action); ··· 3819 3819 vports = lpfc_create_vport_work_array(phba); 3820 3820 if (vports != NULL) { 3821 3821 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { 3822 - if (vports[i]->load_flag & FC_UNLOADING) 3822 + if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) 3823 3823 continue; 3824 3824 shost = lpfc_shost_from_vport(vports[i]); 3825 3825 spin_lock_irq(shost->host_lock); 3826 3826 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; 3827 - vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 3828 - vports[i]->fc_flag &= ~FC_VFI_REGISTERED; 3829 3827 spin_unlock_irq(shost->host_lock); 3828 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vports[i]->fc_flag); 3829 + clear_bit(FC_VFI_REGISTERED, &vports[i]->fc_flag); 3830 3830 3831 - shost = lpfc_shost_from_vport(vports[i]); 3832 3831 list_for_each_entry_safe(ndlp, next_ndlp, 3833 3832 &vports[i]->fc_nodes, 3834 3833 nlp_listp) { ··· 3909 3910 struct lpfc_vport **vports; 3910 3911 int i; 3911 3912 3912 - if (phba->pport->fc_flag & FC_OFFLINE_MODE) 3913 + if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 3913 3914 return; 3914 3915 3915 3916 /* stop port and all timers associated with this hba */ ··· 3940 3941 shost = lpfc_shost_from_vport(vports[i]); 3941 3942 spin_lock_irq(shost->host_lock); 3942 3943 vports[i]->work_port_events = 0; 3943 - vports[i]->fc_flag |= FC_OFFLINE_MODE; 3944 3944 spin_unlock_irq(shost->host_lock); 3945 + set_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); 3945 3946 } 3946 3947 lpfc_destroy_vport_work_array(phba, vports); 3947 3948 /* If OFFLINE flag is clear (i.e. unloading), cpuhp removal is handled 3948 3949 * in hba_unset 3949 3950 */ 3950 - if (phba->pport->fc_flag & FC_OFFLINE_MODE) 3951 + if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 3951 3952 __lpfc_cpuhp_remove(phba); 3952 3953 3953 3954 if (phba->cfg_xri_rebalancing) ··· 4765 4766 4766 4767 vport = (struct lpfc_vport *) shost->hostdata; 4767 4768 vport->phba = phba; 4768 - vport->load_flag |= FC_LOADING; 4769 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 4769 + set_bit(FC_LOADING, &vport->load_flag); 4770 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 4770 4771 vport->fc_rscn_flush = 0; 4772 + atomic_set(&vport->fc_plogi_cnt, 0); 4773 + atomic_set(&vport->fc_adisc_cnt, 0); 4774 + atomic_set(&vport->fc_reglogin_cnt, 0); 4775 + atomic_set(&vport->fc_prli_cnt, 0); 4776 + atomic_set(&vport->fc_unmap_cnt, 0); 4777 + atomic_set(&vport->fc_map_cnt, 0); 4778 + atomic_set(&vport->fc_npr_cnt, 0); 4779 + atomic_set(&vport->fc_unused_cnt, 0); 4771 4780 lpfc_get_vport_cfgparam(vport); 4772 4781 4773 4782 /* Adjust value in vport */ ··· 4831 4824 4832 4825 /* Initialize all internally managed lists. */ 4833 4826 INIT_LIST_HEAD(&vport->fc_nodes); 4827 + spin_lock_init(&vport->fc_nodes_list_lock); 4834 4828 INIT_LIST_HEAD(&vport->rcv_buffer_list); 4835 4829 spin_lock_init(&vport->work_port_lock); 4836 4830 ··· 4929 4921 4930 4922 spin_lock_irq(shost->host_lock); 4931 4923 4932 - if (vport->load_flag & FC_UNLOADING) { 4924 + if (test_bit(FC_UNLOADING, &vport->load_flag)) { 4933 4925 stat = 1; 4934 4926 goto finished; 4935 4927 } ··· 4953 4945 goto finished; 4954 4946 if (vport->num_disc_nodes || vport->fc_prli_sent) 4955 4947 goto finished; 4956 - if (vport->fc_map_cnt == 0 && time < msecs_to_jiffies(2 * 1000)) 4948 + if (!atomic_read(&vport->fc_map_cnt) && 4949 + time < msecs_to_jiffies(2 * 1000)) 4957 4950 goto finished; 4958 4951 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) 4959 4952 goto finished; ··· 5043 5034 fc_host_active_fc4s(shost)[7] = 1; 5044 5035 5045 5036 fc_host_max_npiv_vports(shost) = phba->max_vpi; 5046 - spin_lock_irq(shost->host_lock); 5047 - vport->load_flag &= ~FC_LOADING; 5048 - spin_unlock_irq(shost->host_lock); 5037 + clear_bit(FC_LOADING, &vport->load_flag); 5049 5038 } 5050 5039 5051 5040 /** ··· 5179 5172 5180 5173 /* Is the vmid inactivity timer enabled */ 5181 5174 if (phba->pport->vmid_inactivity_timeout || 5182 - phba->pport->load_flag & FC_DEREGISTER_ALL_APP_ID) { 5175 + test_bit(FC_DEREGISTER_ALL_APP_ID, &phba->pport->load_flag)) { 5183 5176 wake_up = 1; 5184 5177 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; 5185 5178 } ··· 6643 6636 acqe_sli->event_data1, acqe_sli->event_data2, 6644 6637 acqe_sli->event_data3); 6645 6638 break; 6639 + case LPFC_SLI_EVENT_TYPE_RESET_CM_STATS: 6640 + lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT, 6641 + "2905 Reset CM statistics\n"); 6642 + lpfc_sli4_async_cmstat_evt(phba); 6643 + break; 6646 6644 default: 6647 6645 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 6648 6646 "3193 Unrecognized SLI event, type: 0x%x", ··· 6701 6689 return NULL; 6702 6690 lpfc_linkdown_port(vport); 6703 6691 lpfc_cleanup_pending_mbox(vport); 6704 - spin_lock_irq(shost->host_lock); 6705 - vport->fc_flag |= FC_VPORT_CVL_RCVD; 6706 - spin_unlock_irq(shost->host_lock); 6692 + set_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); 6707 6693 6708 6694 return ndlp; 6709 6695 } ··· 6898 6888 if (vports) { 6899 6889 for (i = 0; i <= phba->max_vports && vports[i] != NULL; 6900 6890 i++) { 6901 - if ((!(vports[i]->fc_flag & 6902 - FC_VPORT_CVL_RCVD)) && 6903 - (vports[i]->port_state > LPFC_FDISC)) { 6891 + if (!test_bit(FC_VPORT_CVL_RCVD, 6892 + &vports[i]->fc_flag) && 6893 + vports[i]->port_state > LPFC_FDISC) { 6904 6894 active_vlink_present = 1; 6905 6895 break; 6906 6896 } ··· 6913 6903 * If we are here first then vport_delete is going to wait 6914 6904 * for discovery to complete. 6915 6905 */ 6916 - if (!(vport->load_flag & FC_UNLOADING) && 6917 - active_vlink_present) { 6906 + if (!test_bit(FC_UNLOADING, &vport->load_flag) && 6907 + active_vlink_present) { 6918 6908 /* 6919 6909 * If there are other active VLinks present, 6920 6910 * re-instantiate the Vlink using FDISC. ··· 7355 7345 break; 7356 7346 case LPFC_TRAILER_CODE_SLI: 7357 7347 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); 7358 - break; 7359 - case LPFC_TRAILER_CODE_CMSTAT: 7360 - lpfc_sli4_async_cmstat_evt(phba); 7361 7348 break; 7362 7349 default: 7363 7350 lpfc_printf_log(phba, KERN_ERR, ··· 9092 9085 { 9093 9086 struct lpfc_hba *phba = vport->phba; 9094 9087 9095 - vport->load_flag |= FC_ALLOW_FDMI; 9088 + set_bit(FC_ALLOW_FDMI, &vport->load_flag); 9096 9089 if (phba->cfg_enable_SmartSAN || 9097 9090 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { 9098 9091 /* Setup appropriate attribute masks */ ··· 12778 12771 12779 12772 static void lpfc_cpuhp_remove(struct lpfc_hba *phba) 12780 12773 { 12781 - if (phba->pport && (phba->pport->fc_flag & FC_OFFLINE_MODE)) 12774 + if (phba->pport && 12775 + test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) 12782 12776 return; 12783 12777 12784 12778 __lpfc_cpuhp_remove(phba); ··· 12804 12796 12805 12797 static int __lpfc_cpuhp_checks(struct lpfc_hba *phba, int *retval) 12806 12798 { 12807 - if (phba->pport->load_flag & FC_UNLOADING) { 12799 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 12808 12800 *retval = -EAGAIN; 12809 12801 return true; 12810 12802 } ··· 13324 13316 static void 13325 13317 lpfc_unset_hba(struct lpfc_hba *phba) 13326 13318 { 13327 - struct lpfc_vport *vport = phba->pport; 13328 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 13329 - 13330 - spin_lock_irq(shost->host_lock); 13331 - vport->load_flag |= FC_UNLOADING; 13332 - spin_unlock_irq(shost->host_lock); 13319 + set_bit(FC_UNLOADING, &phba->pport->load_flag); 13333 13320 13334 13321 kfree(phba->vpi_bmask); 13335 13322 kfree(phba->vpi_ids); ··· 14116 14113 struct lpfc_hba *phba = vport->phba; 14117 14114 int i; 14118 14115 14119 - spin_lock_irq(&phba->hbalock); 14120 - vport->load_flag |= FC_UNLOADING; 14121 - spin_unlock_irq(&phba->hbalock); 14116 + set_bit(FC_UNLOADING, &vport->load_flag); 14122 14117 14123 14118 lpfc_free_sysfs_attr(vport); 14124 14119 ··· 14959 14958 int i; 14960 14959 14961 14960 /* Mark the device unloading flag */ 14962 - spin_lock_irq(&phba->hbalock); 14963 - vport->load_flag |= FC_UNLOADING; 14964 - spin_unlock_irq(&phba->hbalock); 14961 + set_bit(FC_UNLOADING, &vport->load_flag); 14965 14962 if (phba->cgn_i) 14966 14963 lpfc_unreg_congestion_buf(phba); 14967 14964
+5 -5
drivers/scsi/lpfc/lpfc_mbox.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 949 949 * Set the re-reg VPI bit for f/w to update the MAC address. 950 950 */ 951 951 if ((phba->sli_rev == LPFC_SLI_REV4) && 952 - !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) 952 + !test_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag)) 953 953 mb->un.varRegVpi.upd = 1; 954 954 955 955 mb->un.varRegVpi.vpi = phba->vpi_ids[vport->vpi]; ··· 2244 2244 2245 2245 /* Only FC supports upd bit */ 2246 2246 if ((phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) && 2247 - (vport->fc_flag & FC_VFI_REGISTERED) && 2247 + test_bit(FC_VFI_REGISTERED, &vport->fc_flag) && 2248 2248 (!phba->fc_topology_changed)) 2249 2249 bf_set(lpfc_reg_vfi_upd, reg_vfi, 1); 2250 2250 ··· 2271 2271 } 2272 2272 lpfc_printf_vlog(vport, KERN_INFO, LOG_MBOX, 2273 2273 "3134 Register VFI, mydid:x%x, fcfi:%d, " 2274 - " vfi:%d, vpi:%d, fc_pname:%x%x fc_flag:x%x" 2275 - " port_state:x%x topology chg:%d bbscn_fabric :%d\n", 2274 + "vfi:%d, vpi:%d, fc_pname:%x%x fc_flag:x%lx " 2275 + "port_state:x%x topology chg:%d bbscn_fabric :%d\n", 2276 2276 vport->fc_myDID, 2277 2277 phba->fcf.fcfi, 2278 2278 phba->sli4_hba.vfi_ids[vport->vfi],
+41 -50
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 382 382 /* PLOGI chkparm OK */ 383 383 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 384 384 "0114 PLOGI chkparm OK Data: x%x x%x x%x " 385 - "x%x x%x x%x\n", 385 + "x%x x%x x%lx\n", 386 386 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag, 387 387 ndlp->nlp_rpi, vport->port_state, 388 388 vport->fc_flag); ··· 434 434 } 435 435 if (nlp_portwwn != 0 && 436 436 nlp_portwwn != wwn_to_u64(sp->portName.u.wwn)) 437 - lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 437 + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 438 438 "0143 PLOGI recv'd from DID: x%x " 439 439 "WWPN changed: old %llx new %llx\n", 440 440 ndlp->nlp_DID, ··· 464 464 save_iocb = NULL; 465 465 466 466 /* Check for Nport to NPort pt2pt protocol */ 467 - if ((vport->fc_flag & FC_PT2PT) && 468 - !(vport->fc_flag & FC_PT2PT_PLOGI)) { 467 + if (test_bit(FC_PT2PT, &vport->fc_flag) && 468 + !test_bit(FC_PT2PT_PLOGI, &vport->fc_flag)) { 469 469 /* rcv'ed PLOGI decides what our NPortId will be */ 470 470 if (phba->sli_rev == LPFC_SLI_REV4) { 471 471 vport->fc_myDID = bf_get(els_rsp64_sid, ··· 580 580 * This only applies to a fabric environment. 581 581 */ 582 582 if ((ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) && 583 - (vport->fc_flag & FC_FABRIC)) { 583 + test_bit(FC_FABRIC, &vport->fc_flag)) { 584 584 /* software abort outstanding PLOGI */ 585 585 lpfc_els_abort(phba, ndlp); 586 586 } ··· 748 748 /* Save the ELS cmd */ 749 749 elsiocb->drvrTimeout = cmd; 750 750 751 - lpfc_sli4_resume_rpi(ndlp, 752 - lpfc_mbx_cmpl_resume_rpi, elsiocb); 751 + if (lpfc_sli4_resume_rpi(ndlp, 752 + lpfc_mbx_cmpl_resume_rpi, 753 + elsiocb)) 754 + kfree(elsiocb); 753 755 goto out; 754 756 } 755 757 } ··· 804 802 lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 805 803 struct lpfc_iocbq *cmdiocb, uint32_t els_cmd) 806 804 { 807 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 808 805 struct lpfc_hba *phba = vport->phba; 809 806 struct lpfc_vport **vports; 810 807 int i, active_vlink_present = 0 ; ··· 836 835 837 836 if (ndlp->nlp_DID == Fabric_DID) { 838 837 if (vport->port_state <= LPFC_FDISC || 839 - vport->fc_flag & FC_PT2PT) 838 + test_bit(FC_PT2PT, &vport->fc_flag)) 840 839 goto out; 841 840 lpfc_linkdown_port(vport); 842 - spin_lock_irq(shost->host_lock); 843 - vport->fc_flag |= FC_VPORT_LOGO_RCVD; 844 - spin_unlock_irq(shost->host_lock); 841 + set_bit(FC_VPORT_LOGO_RCVD, &vport->fc_flag); 845 842 vports = lpfc_create_vport_work_array(phba); 846 843 if (vports) { 847 844 for (i = 0; i <= phba->max_vports && vports[i] != NULL; 848 845 i++) { 849 - if ((!(vports[i]->fc_flag & 850 - FC_VPORT_LOGO_RCVD)) && 851 - (vports[i]->port_state > LPFC_FDISC)) { 846 + if (!test_bit(FC_VPORT_LOGO_RCVD, 847 + &vports[i]->fc_flag) && 848 + vports[i]->port_state > LPFC_FDISC) { 852 849 active_vlink_present = 1; 853 850 break; 854 851 } ··· 859 860 * If we are here first then vport_delete is going to wait 860 861 * for discovery to complete. 861 862 */ 862 - if (!(vport->load_flag & FC_UNLOADING) && 863 - active_vlink_present) { 863 + if (!test_bit(FC_UNLOADING, &vport->load_flag) && 864 + active_vlink_present) { 864 865 /* 865 866 * If there are other active VLinks present, 866 867 * re-instantiate the Vlink using FDISC. ··· 873 874 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; 874 875 vport->port_state = LPFC_FDISC; 875 876 } else { 876 - spin_lock_irq(shost->host_lock); 877 - phba->pport->fc_flag &= ~FC_LOGO_RCVD_DID_CHNG; 878 - spin_unlock_irq(shost->host_lock); 877 + clear_bit(FC_LOGO_RCVD_DID_CHNG, &phba->pport->fc_flag); 879 878 lpfc_retry_pport_discovery(phba); 880 879 } 881 880 } else { 882 881 lpfc_printf_vlog(vport, KERN_INFO, 883 882 LOG_NODE | LOG_ELS | LOG_DISCOVERY, 884 883 "3203 LOGO recover nport x%06x state x%x " 885 - "ntype x%x fc_flag x%x\n", 884 + "ntype x%x fc_flag x%lx\n", 886 885 ndlp->nlp_DID, ndlp->nlp_state, 887 886 ndlp->nlp_type, vport->fc_flag); 888 887 889 888 /* Special cases for rports that recover post LOGO. */ 890 889 if ((!(ndlp->nlp_type == NLP_FABRIC) && 891 890 (ndlp->nlp_type & (NLP_FCP_TARGET | NLP_NVME_TARGET) || 892 - vport->fc_flag & FC_PT2PT)) || 891 + test_bit(FC_PT2PT, &vport->fc_flag))) || 893 892 (ndlp->nlp_state >= NLP_STE_ADISC_ISSUE || 894 893 ndlp->nlp_state <= NLP_STE_PRLI_ISSUE)) { 895 894 mod_timer(&ndlp->nlp_delayfunc, ··· 1052 1055 return 0; 1053 1056 } 1054 1057 1055 - if (!(vport->fc_flag & FC_PT2PT)) { 1058 + if (!test_bit(FC_PT2PT, &vport->fc_flag)) { 1056 1059 /* Check config parameter use-adisc or FCP-2 */ 1057 - if (vport->cfg_use_adisc && ((vport->fc_flag & FC_RSCN_MODE) || 1060 + if (vport->cfg_use_adisc && 1061 + (test_bit(FC_RSCN_MODE, &vport->fc_flag) || 1058 1062 ((ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) && 1059 1063 (ndlp->nlp_type & NLP_FCP_TARGET)))) { 1060 1064 spin_lock_irq(&ndlp->lock); ··· 1119 1121 } 1120 1122 1121 1123 if (((ndlp->nlp_DID & Fabric_DID_MASK) != Fabric_DID_MASK) && 1122 - (!(vport->fc_flag & FC_OFFLINE_MODE))) 1124 + (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag))) 1123 1125 ndlp->nlp_flag |= NLP_UNREG_INP; 1124 1126 1125 1127 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, ··· 1145 1147 1146 1148 phba = vport->phba; 1147 1149 /* Release the RPI if reglogin completing */ 1148 - if (!(phba->pport->load_flag & FC_UNLOADING) && 1149 - (evt == NLP_EVT_CMPL_REG_LOGIN) && 1150 - (!pmb->u.mb.mbxStatus)) { 1150 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && 1151 + evt == NLP_EVT_CMPL_REG_LOGIN && !pmb->u.mb.mbxStatus) { 1151 1152 rpi = pmb->u.mb.un.varWords[0]; 1152 1153 lpfc_release_rpi(phba, vport, ndlp, rpi); 1153 1154 } ··· 1241 1244 lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 1242 1245 void *arg, uint32_t evt) 1243 1246 { 1244 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1245 1247 struct lpfc_hba *phba = vport->phba; 1246 1248 struct lpfc_iocbq *cmdiocb = arg; 1247 1249 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; ··· 1275 1279 /* Check if there are more PLOGIs to be sent */ 1276 1280 lpfc_more_plogi(vport); 1277 1281 if (vport->num_disc_nodes == 0) { 1278 - spin_lock_irq(shost->host_lock); 1279 - vport->fc_flag &= ~FC_NDISC_ACTIVE; 1280 - spin_unlock_irq(shost->host_lock); 1282 + clear_bit(FC_NDISC_ACTIVE, &vport->fc_flag); 1281 1283 lpfc_can_disctmo(vport); 1282 1284 lpfc_end_rscn(vport); 1283 1285 } ··· 1415 1421 ndlp->nlp_maxframe = 1416 1422 ((sp->cmn.bbRcvSizeMsb & 0x0F) << 8) | sp->cmn.bbRcvSizeLsb; 1417 1423 1418 - if ((vport->fc_flag & FC_PT2PT) && 1419 - (vport->fc_flag & FC_PT2PT_PLOGI)) { 1424 + if (test_bit(FC_PT2PT, &vport->fc_flag) && 1425 + test_bit(FC_PT2PT_PLOGI, &vport->fc_flag)) { 1420 1426 ed_tov = be32_to_cpu(sp->cmn.e_d_tov); 1421 1427 if (sp->cmn.edtovResolution) { 1422 1428 /* E_D_TOV ticks are in nanoseconds */ ··· 1570 1576 1571 1577 phba = vport->phba; 1572 1578 /* Release the RPI */ 1573 - if (!(phba->pport->load_flag & FC_UNLOADING) && 1574 - !mb->mbxStatus) { 1579 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && 1580 + !mb->mbxStatus) { 1575 1581 rpi = pmb->u.mb.un.varWords[0]; 1576 1582 lpfc_release_rpi(phba, vport, ndlp, rpi); 1577 1583 } ··· 1607 1613 /* Don't do anything that will mess up processing of the 1608 1614 * previous RSCN. 1609 1615 */ 1610 - if (vport->fc_flag & FC_RSCN_DEFERRED) 1616 + if (test_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) 1611 1617 return ndlp->nlp_state; 1612 1618 1613 1619 /* software abort outstanding PLOGI */ ··· 1793 1799 /* Don't do anything that will mess up processing of the 1794 1800 * previous RSCN. 1795 1801 */ 1796 - if (vport->fc_flag & FC_RSCN_DEFERRED) 1802 + if (test_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) 1797 1803 return ndlp->nlp_state; 1798 1804 1799 1805 /* software abort outstanding ADISC */ ··· 1983 1989 * know what PRLI to send yet. Figure that out now and 1984 1990 * call PRLI depending on the outcome. 1985 1991 */ 1986 - if (vport->fc_flag & FC_PT2PT) { 1992 + if (test_bit(FC_PT2PT, &vport->fc_flag)) { 1987 1993 /* If we are pt2pt, there is no Fabric to determine 1988 1994 * the FC4 type of the remote nport. So if NVME 1989 1995 * is configured try it. 1990 1996 */ 1991 1997 ndlp->nlp_fc4_type |= NLP_FC4_FCP; 1992 - if ((!(vport->fc_flag & FC_PT2PT_NO_NVME)) && 1998 + if ((!test_bit(FC_PT2PT_NO_NVME, &vport->fc_flag)) && 1993 1999 (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH || 1994 2000 vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) { 1995 2001 ndlp->nlp_fc4_type |= NLP_FC4_NVME; ··· 2021 2027 lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); 2022 2028 } 2023 2029 } else { 2024 - if ((vport->fc_flag & FC_PT2PT) && phba->nvmet_support) 2030 + if (test_bit(FC_PT2PT, &vport->fc_flag) && phba->nvmet_support) 2025 2031 phba->targetport->port_id = vport->fc_myDID; 2026 2032 2027 2033 /* Only Fabric ports should transition. NVME target ··· 2062 2068 /* Don't do anything that will mess up processing of the 2063 2069 * previous RSCN. 2064 2070 */ 2065 - if (vport->fc_flag & FC_RSCN_DEFERRED) 2071 + if (test_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) 2066 2072 return ndlp->nlp_state; 2067 2073 2068 2074 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; ··· 2378 2384 /* Don't do anything that will mess up processing of the 2379 2385 * previous RSCN. 2380 2386 */ 2381 - if (vport->fc_flag & FC_RSCN_DEFERRED) 2387 + if (test_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) 2382 2388 return ndlp->nlp_state; 2383 2389 2384 2390 /* software abort outstanding PRLI */ ··· 2822 2828 lpfc_cmpl_logo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 2823 2829 void *arg, uint32_t evt) 2824 2830 { 2825 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2826 - 2827 2831 /* For the fabric port just clear the fc flags. */ 2828 2832 if (ndlp->nlp_DID == Fabric_DID) { 2829 - spin_lock_irq(shost->host_lock); 2830 - vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 2831 - spin_unlock_irq(shost->host_lock); 2833 + clear_bit(FC_FABRIC, &vport->fc_flag); 2834 + clear_bit(FC_PUBLIC_LOOP, &vport->fc_flag); 2832 2835 } 2833 2836 lpfc_unreg_rpi(vport, ndlp); 2834 2837 return ndlp->nlp_state; ··· 2897 2906 /* Don't do anything that will mess up processing of the 2898 2907 * previous RSCN. 2899 2908 */ 2900 - if (vport->fc_flag & FC_RSCN_DEFERRED) 2909 + if (test_bit(FC_RSCN_DEFERRED, &vport->fc_flag)) 2901 2910 return ndlp->nlp_state; 2902 2911 2903 2912 lpfc_cancel_retry_delay_tmo(vport, ndlp);
+10 -10
drivers/scsi/lpfc/lpfc_nvme.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 94 94 lport = (struct lpfc_nvme_lport *)pnvme_lport->private; 95 95 vport = lport->vport; 96 96 97 - if (!vport || vport->load_flag & FC_UNLOADING || 97 + if (!vport || test_bit(FC_UNLOADING, &vport->load_flag) || 98 98 vport->phba->hba_flag & HBA_IOQ_FLUSH) 99 99 return -ENODEV; 100 100 ··· 674 674 return -EINVAL; 675 675 676 676 vport = lport->vport; 677 - if (vport->load_flag & FC_UNLOADING || 677 + if (test_bit(FC_UNLOADING, &vport->load_flag) || 678 678 vport->phba->hba_flag & HBA_IOQ_FLUSH) 679 679 return -ENODEV; 680 680 ··· 765 765 struct lpfc_nvme_lport *lport; 766 766 int rc; 767 767 768 - if (axchg->phba->pport->load_flag & FC_UNLOADING) 768 + if (test_bit(FC_UNLOADING, &axchg->phba->pport->load_flag)) 769 769 return -ENODEV; 770 770 771 771 lport = (struct lpfc_nvme_lport *)localport->private; ··· 810 810 return; 811 811 vport = lport->vport; 812 812 813 - if (vport->load_flag & FC_UNLOADING) 813 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 814 814 return; 815 815 816 816 ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); ··· 1567 1567 1568 1568 phba = vport->phba; 1569 1569 1570 - if ((unlikely(vport->load_flag & FC_UNLOADING)) || 1570 + if ((unlikely(test_bit(FC_UNLOADING, &vport->load_flag))) || 1571 1571 phba->hba_flag & HBA_IOQ_FLUSH) { 1572 1572 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR, 1573 1573 "6124 Fail IO, Driver unload\n"); ··· 1886 1886 1887 1887 if (unlikely(!freqpriv)) 1888 1888 return; 1889 - if (vport->load_flag & FC_UNLOADING) 1889 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 1890 1890 return; 1891 1891 1892 1892 /* Announce entry to new IO submit field. */ ··· 2263 2263 if (!vport->localport || 2264 2264 test_bit(HBA_PCI_ERR, &vport->phba->bit_flags) || 2265 2265 phba->link_state == LPFC_HBA_ERROR || 2266 - vport->load_flag & FC_UNLOADING) 2266 + test_bit(FC_UNLOADING, &vport->load_flag)) 2267 2267 return; 2268 2268 2269 2269 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 2625 2625 * return values is ignored. The upcall is a courtesy to the 2626 2626 * transport. 2627 2627 */ 2628 - if (vport->load_flag & FC_UNLOADING || 2628 + if (test_bit(FC_UNLOADING, &vport->load_flag) || 2629 2629 unlikely(vport->phba->link_state == LPFC_HBA_ERROR)) 2630 2630 (void)nvme_fc_set_remoteport_devloss(remoteport, 0); 2631 2631 ··· 2644 2644 "port_state x%x\n", 2645 2645 ret, remoteport->port_state); 2646 2646 2647 - if (vport->load_flag & FC_UNLOADING) { 2647 + if (test_bit(FC_UNLOADING, &vport->load_flag)) { 2648 2648 /* Only 1 thread can drop the initial node 2649 2649 * reference. Check if another thread has set 2650 2650 * NLP_DROPPED.
+7 -7
drivers/scsi/lpfc/lpfc_nvmet.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 872 872 struct ulp_bde64 bpl; 873 873 int rc; 874 874 875 - if (phba->pport->load_flag & FC_UNLOADING) 875 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 876 876 return -ENODEV; 877 877 878 878 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, ··· 984 984 struct lpfc_nvmet_tgtport *nvmep = tgtport->private; 985 985 int rc; 986 986 987 - if (axchg->phba->pport->load_flag & FC_UNLOADING) 987 + if (test_bit(FC_UNLOADING, &axchg->phba->pport->load_flag)) 988 988 return -ENODEV; 989 989 990 990 rc = __lpfc_nvme_xmt_ls_rsp(axchg, ls_rsp, lpfc_nvmet_xmt_ls_rsp_cmp); ··· 1022 1022 int id; 1023 1023 #endif 1024 1024 1025 - if (phba->pport->load_flag & FC_UNLOADING) { 1025 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 1026 1026 rc = -ENODEV; 1027 1027 goto aerr; 1028 1028 } ··· 1145 1145 struct lpfc_queue *wq; 1146 1146 unsigned long flags; 1147 1147 1148 - if (phba->pport->load_flag & FC_UNLOADING) 1148 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1149 1149 return; 1150 1150 1151 1151 if (!ctxp->hdwq) ··· 1317 1317 return -EINVAL; 1318 1318 1319 1319 phba = lpfc_nvmet->phba; 1320 - if (phba->pport->load_flag & FC_UNLOADING) 1320 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1321 1321 return -EINVAL; 1322 1322 1323 1323 hstate = atomic_read(&lpfc_nvmet->state); ··· 1353 1353 int ret; 1354 1354 1355 1355 phba = lpfc_nvmet->phba; 1356 - if (phba->pport->load_flag & FC_UNLOADING) 1356 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 1357 1357 return; 1358 1358 1359 1359 ndlp = (struct lpfc_nodelist *)hosthandle;
+5 -5
drivers/scsi/lpfc/lpfc_scsi.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 2728 2728 sgde = scsi_sglist(cmd); 2729 2729 blksize = scsi_prot_interval(cmd); 2730 2730 data_src = (uint8_t *)sg_virt(sgde); 2731 - data_len = sgde->length; 2731 + data_len = sg_dma_len(sgde); 2732 2732 if ((data_len & (blksize - 1)) == 0) 2733 2733 chk_guard = 1; 2734 2734 2735 2735 src = (struct scsi_dif_tuple *)sg_virt(sgpe); 2736 2736 start_ref_tag = scsi_prot_ref_tag(cmd); 2737 2737 start_app_tag = src->app_tag; 2738 - len = sgpe->length; 2738 + len = sg_dma_len(sgpe); 2739 2739 while (src && protsegcnt) { 2740 2740 while (len) { 2741 2741 ··· 2800 2800 goto out; 2801 2801 2802 2802 data_src = (uint8_t *)sg_virt(sgde); 2803 - data_len = sgde->length; 2803 + data_len = sg_dma_len(sgde); 2804 2804 if ((data_len & (blksize - 1)) == 0) 2805 2805 chk_guard = 1; 2806 2806 } ··· 2810 2810 sgpe = sg_next(sgpe); 2811 2811 if (sgpe) { 2812 2812 src = (struct scsi_dif_tuple *)sg_virt(sgpe); 2813 - len = sgpe->length; 2813 + len = sg_dma_len(sgpe); 2814 2814 } else { 2815 2815 src = NULL; 2816 2816 }
+33 -23
drivers/scsi/lpfc/lpfc_sli.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 1036 1036 } 1037 1037 spin_unlock_irqrestore(&phba->hbalock, iflags); 1038 1038 if ((!list_empty(&phba->active_rrq_list)) && 1039 - (!(phba->pport->load_flag & FC_UNLOADING))) 1039 + (!test_bit(FC_UNLOADING, &phba->pport->load_flag))) 1040 1040 mod_timer(&phba->rrq_tmr, next_time); 1041 1041 list_for_each_entry_safe(rrq, nextrrq, &send_rrq, list) { 1042 1042 list_del(&rrq->list); ··· 1180 1180 return -EINVAL; 1181 1181 1182 1182 spin_lock_irqsave(&phba->hbalock, iflags); 1183 - if (phba->pport->load_flag & FC_UNLOADING) { 1183 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 1184 1184 phba->hba_flag &= ~HBA_RRQ_ACTIVE; 1185 1185 goto out; 1186 1186 } 1187 1187 1188 - if (ndlp->vport && (ndlp->vport->load_flag & FC_UNLOADING)) 1188 + if (ndlp->vport && test_bit(FC_UNLOADING, &ndlp->vport->load_flag)) 1189 1189 goto out; 1190 1190 1191 1191 if (!ndlp->active_rrqs_xri_bitmap) ··· 1732 1732 (ulp_command != CMD_ABORT_XRI_CN) && 1733 1733 (ulp_command != CMD_CLOSE_XRI_CN)) { 1734 1734 BUG_ON(!piocb->vport); 1735 - if (!(piocb->vport->load_flag & FC_UNLOADING)) 1735 + if (!test_bit(FC_UNLOADING, &piocb->vport->load_flag)) 1736 1736 mod_timer(&piocb->vport->els_tmofunc, 1737 1737 jiffies + 1738 1738 msecs_to_jiffies(1000 * (phba->fc_ratov << 1))); ··· 2882 2882 * If a REG_LOGIN succeeded after node is destroyed or node 2883 2883 * is in re-discovery driver need to cleanup the RPI. 2884 2884 */ 2885 - if (!(phba->pport->load_flag & FC_UNLOADING) && 2885 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && 2886 2886 pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 && 2887 2887 !pmb->u.mb.mbxStatus) { 2888 2888 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; ··· 2904 2904 } 2905 2905 2906 2906 if ((pmb->u.mb.mbxCommand == MBX_REG_VPI) && 2907 - !(phba->pport->load_flag & FC_UNLOADING) && 2907 + !test_bit(FC_UNLOADING, &phba->pport->load_flag) && 2908 2908 !pmb->u.mb.mbxStatus) { 2909 2909 shost = lpfc_shost_from_vport(vport); 2910 2910 spin_lock_irq(shost->host_lock); 2911 2911 vport->vpi_state |= LPFC_VPI_REGISTERED; 2912 - vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 2913 2912 spin_unlock_irq(shost->host_lock); 2913 + clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 2914 2914 } 2915 2915 2916 2916 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { ··· 2927 2927 vport, 2928 2928 KERN_INFO, LOG_MBOX | LOG_DISCOVERY, 2929 2929 "1438 UNREG cmpl deferred mbox x%x " 2930 - "on NPort x%x Data: x%x x%x x%px x%x x%x\n", 2930 + "on NPort x%x Data: x%x x%x x%px x%lx x%x\n", 2931 2931 ndlp->nlp_rpi, ndlp->nlp_DID, 2932 2932 ndlp->nlp_flag, ndlp->nlp_defer_did, 2933 2933 ndlp, vport->load_flag, kref_read(&ndlp->kref)); ··· 3235 3235 lpfc_nvmeio_data(phba, "NVME LS RCV: xri x%x sz %d from %06x\n", 3236 3236 oxid, size, sid); 3237 3237 3238 - if (phba->pport->load_flag & FC_UNLOADING) { 3238 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 3239 3239 failwhy = "Driver Unloading"; 3240 3240 } else if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { 3241 3241 failwhy = "NVME FC4 Disabled"; ··· 3940 3940 if (!(phba->hba_flag & HBA_SETUP)) 3941 3941 return; 3942 3942 3943 - if (phba->pport->load_flag & FC_UNLOADING) 3943 + if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) 3944 3944 return; 3945 3945 3946 3946 /* Here we will also keep track of interrupts per sec of the hba */ ··· 7582 7582 struct lpfc_sglq *sglq_entry = NULL; 7583 7583 struct lpfc_sglq *sglq_entry_next = NULL; 7584 7584 struct lpfc_sglq *sglq_entry_first = NULL; 7585 - int status, total_cnt; 7585 + int status = 0, total_cnt; 7586 7586 int post_cnt = 0, num_posted = 0, block_cnt = 0; 7587 7587 int last_xritag = NO_XRI; 7588 7588 LIST_HEAD(prep_sgl_list); ··· 10888 10888 * all ELS pt2pt protocol traffic as well. 10889 10889 */ 10890 10890 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) || 10891 - (vport->fc_flag & FC_PT2PT)) { 10891 + test_bit(FC_PT2PT, &vport->fc_flag)) { 10892 10892 if (expect_rsp) { 10893 10893 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID); 10894 10894 ··· 12428 12428 * If we're unloading, don't abort iocb on the ELS ring, but change 12429 12429 * the callback so that nothing happens when it finishes. 12430 12430 */ 12431 - if ((vport->load_flag & FC_UNLOADING) && 12431 + if (test_bit(FC_UNLOADING, &vport->load_flag) && 12432 12432 pring->ringno == LPFC_ELS_RING) { 12433 12433 if (cmdiocb->cmd_flag & LPFC_IO_FABRIC) 12434 12434 cmdiocb->fabric_cmd_cmpl = lpfc_ignore_els_cmpl; ··· 14658 14658 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { 14659 14659 spin_unlock_irqrestore(&phba->hbalock, iflags); 14660 14660 /* Handle MDS Loopback frames */ 14661 - if (!(phba->pport->load_flag & FC_UNLOADING)) 14661 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 14662 14662 lpfc_sli4_handle_mds_loopback(phba->pport, 14663 14663 dma_buf); 14664 14664 else ··· 18552 18552 18553 18553 if (did == Fabric_DID) 18554 18554 return phba->pport; 18555 - if ((phba->pport->fc_flag & FC_PT2PT) && 18556 - !(phba->link_state == LPFC_HBA_READY)) 18555 + if (test_bit(FC_PT2PT, &phba->pport->fc_flag) && 18556 + phba->link_state != LPFC_HBA_READY) 18557 18557 return phba->pport; 18558 18558 18559 18559 vports = lpfc_create_vport_work_array(phba); ··· 18933 18933 "oxid:x%x SID:x%x\n", oxid, sid); 18934 18934 return; 18935 18935 } 18936 - /* Put ndlp onto pport node list */ 18936 + /* Put ndlp onto vport node list */ 18937 18937 lpfc_enqueue_node(vport, ndlp); 18938 18938 } 18939 18939 ··· 18953 18953 return; 18954 18954 } 18955 18955 18956 - ctiocb->vport = phba->pport; 18956 + ctiocb->vport = vport; 18957 18957 ctiocb->cmd_cmpl = lpfc_sli4_seq_abort_rsp_cmpl; 18958 18958 ctiocb->sli4_lxritag = NO_XRI; 18959 18959 ctiocb->sli4_xritag = NO_XRI; ··· 19039 19039 lpfc_nlp_put(ndlp); 19040 19040 ctiocb->ndlp = NULL; 19041 19041 lpfc_sli_release_iocbq(phba, ctiocb); 19042 + } 19043 + 19044 + /* if only usage of this nodelist is BLS response, release initial ref 19045 + * to free ndlp when transmit completes 19046 + */ 19047 + if (ndlp->nlp_state == NLP_STE_UNUSED_NODE && 19048 + !(ndlp->nlp_flag & NLP_DROPPED) && 19049 + !(ndlp->fc4_xpt_flags & (NVME_XPT_REGD | SCSI_XPT_REGD))) { 19050 + ndlp->nlp_flag |= NLP_DROPPED; 19051 + lpfc_nlp_put(ndlp); 19042 19052 } 19043 19053 } 19044 19054 ··· 19457 19447 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { 19458 19448 vport = phba->pport; 19459 19449 /* Handle MDS Loopback frames */ 19460 - if (!(phba->pport->load_flag & FC_UNLOADING)) 19450 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 19461 19451 lpfc_sli4_handle_mds_loopback(vport, dmabuf); 19462 19452 else 19463 19453 lpfc_in_buf_free(phba, &dmabuf->dbuf); ··· 19507 19497 * The pt2pt protocol allows for discovery frames 19508 19498 * to be received without a registered VPI. 19509 19499 */ 19510 - if (!(vport->fc_flag & FC_PT2PT) || 19511 - (phba->link_state == LPFC_HBA_READY)) { 19500 + if (!test_bit(FC_PT2PT, &vport->fc_flag) || 19501 + phba->link_state == LPFC_HBA_READY) { 19512 19502 lpfc_in_buf_free(phba, &dmabuf->dbuf); 19513 19503 return; 19514 19504 } ··· 22666 22656 if_type = bf_get(lpfc_sli_intf_if_type, 22667 22657 &phba->sli4_hba.sli_intf); 22668 22658 if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) { 22669 - if (job->vport->fc_flag & FC_PT2PT) { 22659 + if (test_bit(FC_PT2PT, &job->vport->fc_flag)) { 22670 22660 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); 22671 22661 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, 22672 22662 job->vport->fc_myDID);
+3 -3
drivers/scsi/lpfc/lpfc_version.h
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "14.2.0.17" 23 + #define LPFC_DRIVER_VERSION "14.4.0.0" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */ ··· 32 32 33 33 #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ 34 34 LPFC_DRIVER_VERSION 35 - #define LPFC_COPYRIGHT "Copyright (C) 2017-2023 Broadcom. All Rights " \ 35 + #define LPFC_COPYRIGHT "Copyright (C) 2017-2024 Broadcom. All Rights " \ 36 36 "Reserved. The term \"Broadcom\" refers to Broadcom Inc. " \ 37 37 "and/or its subsidiaries."
+30 -39
drivers/scsi/lpfc/lpfc_vport.c
··· 1 1 /******************************************************************* 2 2 * This file is part of the Emulex Linux Device Driver for * 3 3 * Fibre Channel Host Bus Adapters. * 4 - * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2016 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 238 238 static void lpfc_discovery_wait(struct lpfc_vport *vport) 239 239 { 240 240 struct lpfc_hba *phba = vport->phba; 241 - uint32_t wait_flags = 0; 242 241 unsigned long wait_time_max; 243 242 unsigned long start_time; 244 - 245 - wait_flags = FC_RSCN_MODE | FC_RSCN_DISCOVERY | FC_NLP_MORE | 246 - FC_RSCN_DEFERRED | FC_NDISC_ACTIVE | FC_DISC_TMO; 247 243 248 244 /* 249 245 * The time constraint on this loop is a balance between the ··· 251 255 start_time = jiffies; 252 256 while (time_before(jiffies, wait_time_max)) { 253 257 if ((vport->num_disc_nodes > 0) || 254 - (vport->fc_flag & wait_flags) || 258 + test_bit(FC_RSCN_MODE, &vport->fc_flag) || 259 + test_bit(FC_RSCN_DISCOVERY, &vport->fc_flag) || 260 + test_bit(FC_NLP_MORE, &vport->fc_flag) || 261 + test_bit(FC_RSCN_DEFERRED, &vport->fc_flag) || 262 + test_bit(FC_NDISC_ACTIVE, &vport->fc_flag) || 263 + test_bit(FC_DISC_TMO, &vport->fc_flag) || 255 264 ((vport->port_state > LPFC_VPORT_FAILED) && 256 265 (vport->port_state < LPFC_VPORT_READY))) { 257 266 lpfc_printf_vlog(vport, KERN_INFO, LOG_VPORT, 258 - "1833 Vport discovery quiesce Wait:" 259 - " state x%x fc_flags x%x" 260 - " num_nodes x%x, waiting 1000 msecs" 261 - " total wait msecs x%x\n", 267 + "1833 Vport discovery quiesce Wait: " 268 + "state x%x fc_flags x%lx " 269 + "num_nodes x%x, waiting 1000 msecs " 270 + "total wait msecs x%x\n", 262 271 vport->port_state, vport->fc_flag, 263 272 vport->num_disc_nodes, 264 273 jiffies_to_msecs(jiffies - start_time)); ··· 271 270 } else { 272 271 /* Base case. Wait variants satisfied. Break out */ 273 272 lpfc_printf_vlog(vport, KERN_INFO, LOG_VPORT, 274 - "1834 Vport discovery quiesced:" 275 - " state x%x fc_flags x%x" 276 - " wait msecs x%x\n", 273 + "1834 Vport discovery quiesced: " 274 + "state x%x fc_flags x%lx " 275 + "wait msecs x%x\n", 277 276 vport->port_state, vport->fc_flag, 278 277 jiffies_to_msecs(jiffies 279 278 - start_time)); ··· 284 283 if (time_after(jiffies, wait_time_max)) 285 284 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 286 285 "1835 Vport discovery quiesce failed:" 287 - " state x%x fc_flags x%x wait msecs x%x\n", 286 + " state x%x fc_flags x%lx wait msecs x%x\n", 288 287 vport->port_state, vport->fc_flag, 289 288 jiffies_to_msecs(jiffies - start_time)); 290 289 } ··· 408 407 vport->fc_vport = fc_vport; 409 408 410 409 /* At this point we are fully registered with SCSI Layer. */ 411 - vport->load_flag |= FC_ALLOW_FDMI; 410 + set_bit(FC_ALLOW_FDMI, &vport->load_flag); 412 411 if (phba->cfg_enable_SmartSAN || 413 412 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { 414 413 /* Setup appropriate attribute masks */ ··· 421 420 * by the port. 422 421 */ 423 422 if ((phba->sli_rev == LPFC_SLI_REV4) && 424 - (pport->fc_flag & FC_VFI_REGISTERED)) { 423 + test_bit(FC_VFI_REGISTERED, &pport->fc_flag)) { 425 424 rc = lpfc_sli4_init_vpi(vport); 426 425 if (rc) { 427 426 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, ··· 436 435 * Driver cannot INIT_VPI now. Set the flags to 437 436 * init_vpi when reg_vfi complete. 438 437 */ 439 - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 438 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 440 439 lpfc_vport_set_state(vport, FC_VPORT_LINKDOWN); 441 440 rc = VPORT_OK; 442 441 goto out; ··· 536 535 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 537 536 struct lpfc_hba *phba = vport->phba; 538 537 struct lpfc_nodelist *ndlp = NULL; 539 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 540 538 541 539 /* Can't disable during an outstanding delete. */ 542 - if (vport->load_flag & FC_UNLOADING) 540 + if (test_bit(FC_UNLOADING, &vport->load_flag)) 543 541 return 0; 544 542 545 543 ndlp = lpfc_findnode_did(vport, Fabric_DID); ··· 556 556 * scsi_host_put() to release the vport. 557 557 */ 558 558 lpfc_mbx_unreg_vpi(vport); 559 - if (phba->sli_rev == LPFC_SLI_REV4) { 560 - spin_lock_irq(shost->host_lock); 561 - vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; 562 - spin_unlock_irq(shost->host_lock); 563 - } 559 + if (phba->sli_rev == LPFC_SLI_REV4) 560 + set_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag); 564 561 565 562 lpfc_vport_set_state(vport, FC_VPORT_DISABLED); 566 563 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT, ··· 571 574 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 572 575 struct lpfc_hba *phba = vport->phba; 573 576 struct lpfc_nodelist *ndlp = NULL; 574 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 575 577 576 578 if ((phba->link_state < LPFC_LINK_UP) || 577 579 (phba->fc_topology == LPFC_TOPOLOGY_LOOP)) { ··· 578 582 return VPORT_OK; 579 583 } 580 584 581 - spin_lock_irq(shost->host_lock); 582 - vport->load_flag |= FC_LOADING; 583 - if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI) { 584 - spin_unlock_irq(shost->host_lock); 585 + set_bit(FC_LOADING, &vport->load_flag); 586 + if (test_bit(FC_VPORT_NEEDS_INIT_VPI, &vport->fc_flag)) { 585 587 lpfc_issue_init_vpi(vport); 586 588 goto out; 587 589 } 588 590 589 - vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 590 - spin_unlock_irq(shost->host_lock); 591 + set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); 591 592 592 593 /* Use the Physical nodes Fabric NDLP to determine if the link is 593 594 * up and ready to FDISC. ··· 636 643 637 644 /* If the vport is a static vport fail the deletion. */ 638 645 if ((vport->vport_flag & STATIC_VPORT) && 639 - !(phba->pport->load_flag & FC_UNLOADING)) { 646 + !test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 640 647 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 641 648 "1837 vport_delete failed: Cannot delete " 642 649 "static vport.\n"); 643 650 return VPORT_ERROR; 644 651 } 645 652 646 - spin_lock_irq(&phba->hbalock); 647 - vport->load_flag |= FC_UNLOADING; 648 - spin_unlock_irq(&phba->hbalock); 653 + set_bit(FC_UNLOADING, &vport->load_flag); 649 654 650 655 /* 651 656 * If we are not unloading the driver then prevent the vport_delete 652 657 * from happening until after this vport's discovery is finished. 653 658 */ 654 - if (!(phba->pport->load_flag & FC_UNLOADING)) { 659 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 655 660 int check_count = 0; 656 661 while (check_count < ((phba->fc_ratov * 3) + 3) && 657 662 vport->port_state > LPFC_VPORT_FAILED && ··· 716 725 goto skip_logo; 717 726 } 718 727 719 - if (!(phba->pport->load_flag & FC_UNLOADING)) 728 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) 720 729 lpfc_discovery_wait(vport); 721 730 722 731 skip_logo: ··· 727 736 lpfc_sli_host_down(vport); 728 737 lpfc_stop_vport_timers(vport); 729 738 730 - if (!(phba->pport->load_flag & FC_UNLOADING)) { 739 + if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) { 731 740 lpfc_unreg_all_rpis(vport); 732 741 lpfc_unreg_default_rpis(vport); 733 742 /* ··· 764 773 return NULL; 765 774 spin_lock_irq(&phba->port_list_lock); 766 775 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 767 - if (port_iterator->load_flag & FC_UNLOADING) 776 + if (test_bit(FC_UNLOADING, &port_iterator->load_flag)) 768 777 continue; 769 778 if (!scsi_host_get(lpfc_shost_from_vport(port_iterator))) { 770 779 lpfc_printf_vlog(port_iterator, KERN_ERR,
+1 -1
drivers/scsi/megaraid.c
··· 219 219 raw_mbox[3] = ENQ3_GET_SOLICITED_FULL; /* i.e. 0x02 */ 220 220 221 221 /* Issue a blocking command to the card */ 222 - if ((retval = issue_scb_block(adapter, raw_mbox))) { 222 + if (issue_scb_block(adapter, raw_mbox)) { 223 223 /* the adapter does not support 40ld */ 224 224 225 225 mraid_ext_inquiry *ext_inq;
+10 -2
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 8 8 */ 9 9 10 10 #include "mpi3mr.h" 11 + #include <linux/idr.h> 11 12 12 13 /* global driver scop variables */ 13 14 LIST_HEAD(mrioc_list); 14 15 DEFINE_SPINLOCK(mrioc_list_lock); 15 - static int mrioc_ids; 16 + static DEFINE_IDA(mrioc_ida); 16 17 static int warn_non_secure_ctlr; 17 18 atomic64_t event_counter; 18 19 ··· 5073 5072 } 5074 5073 5075 5074 mrioc = shost_priv(shost); 5076 - mrioc->id = mrioc_ids++; 5075 + retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL); 5076 + if (retval < 0) 5077 + goto id_alloc_failed; 5078 + mrioc->id = (u8)retval; 5077 5079 sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME); 5078 5080 sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id); 5079 5081 INIT_LIST_HEAD(&mrioc->list); ··· 5226 5222 resource_alloc_failed: 5227 5223 destroy_workqueue(mrioc->fwevt_worker_thread); 5228 5224 fwevtthread_failed: 5225 + ida_free(&mrioc_ida, mrioc->id); 5229 5226 spin_lock(&mrioc_list_lock); 5230 5227 list_del(&mrioc->list); 5231 5228 spin_unlock(&mrioc_list_lock); 5229 + id_alloc_failed: 5232 5230 scsi_host_put(shost); 5233 5231 shost_failed: 5234 5232 return retval; ··· 5316 5310 mrioc->sas_hba.num_phys = 0; 5317 5311 } 5318 5312 5313 + ida_free(&mrioc_ida, mrioc->id); 5319 5314 spin_lock(&mrioc_list_lock); 5320 5315 list_del(&mrioc->list); 5321 5316 spin_unlock(&mrioc_list_lock); ··· 5532 5525 &driver_attr_event_counter); 5533 5526 pci_unregister_driver(&mpi3mr_pci_driver); 5534 5527 sas_release_transport(mpi3mr_transport_template); 5528 + ida_destroy(&mrioc_ida); 5535 5529 } 5536 5530 5537 5531 module_init(mpi3mr_init);
+74 -39
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 5481 5481 * mpt3sas_atto_get_sas_addr - get the ATTO SAS address from mfg page 1 5482 5482 * 5483 5483 * @ioc : per adapter object 5484 - * @*sas_addr : return sas address 5484 + * @sas_addr : return sas address 5485 5485 * Return: 0 for success, non-zero for failure. 5486 5486 */ 5487 5487 static int ··· 7916 7916 } 7917 7917 7918 7918 /** 7919 + * mpt3sas_base_unlock_and_get_host_diagnostic- enable Host Diagnostic Register writes 7920 + * @ioc: per adapter object 7921 + * @host_diagnostic: host diagnostic register content 7922 + * 7923 + * Return: 0 for success, non-zero for failure. 7924 + */ 7925 + 7926 + int 7927 + mpt3sas_base_unlock_and_get_host_diagnostic(struct MPT3SAS_ADAPTER *ioc, 7928 + u32 *host_diagnostic) 7929 + { 7930 + 7931 + u32 count; 7932 + *host_diagnostic = 0; 7933 + count = 0; 7934 + 7935 + do { 7936 + /* Write magic sequence to WriteSequence register 7937 + * Loop until in diagnostic mode 7938 + */ 7939 + drsprintk(ioc, ioc_info(ioc, "write magic sequence\n")); 7940 + writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); 7941 + writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence); 7942 + writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence); 7943 + writel(MPI2_WRSEQ_3RD_KEY_VALUE, &ioc->chip->WriteSequence); 7944 + writel(MPI2_WRSEQ_4TH_KEY_VALUE, &ioc->chip->WriteSequence); 7945 + writel(MPI2_WRSEQ_5TH_KEY_VALUE, &ioc->chip->WriteSequence); 7946 + writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); 7947 + 7948 + /* wait 100 msec */ 7949 + msleep(100); 7950 + 7951 + if (count++ > 20) { 7952 + ioc_info(ioc, 7953 + "Stop writing magic sequence after 20 retries\n"); 7954 + _base_dump_reg_set(ioc); 7955 + return -EFAULT; 7956 + } 7957 + 7958 + *host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic); 7959 + drsprintk(ioc, 7960 + ioc_info(ioc, "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n", 7961 + count, *host_diagnostic)); 7962 + 7963 + } while ((*host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE) == 0); 7964 + return 0; 7965 + } 7966 + 7967 + /** 7968 + * mpt3sas_base_lock_host_diagnostic: Disable Host Diagnostic Register writes 7969 + * @ioc: per adapter object 7970 + */ 7971 + 7972 + void 7973 + mpt3sas_base_lock_host_diagnostic(struct MPT3SAS_ADAPTER *ioc) 7974 + { 7975 + drsprintk(ioc, ioc_info(ioc, "disable writes to the diagnostic register\n")); 7976 + writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); 7977 + } 7978 + 7979 + /** 7919 7980 * _base_diag_reset - the "big hammer" start of day reset 7920 7981 * @ioc: per adapter object 7921 7982 * ··· 7996 7935 7997 7936 drsprintk(ioc, ioc_info(ioc, "clear interrupts\n")); 7998 7937 7999 - count = 0; 8000 - do { 8001 - /* Write magic sequence to WriteSequence register 8002 - * Loop until in diagnostic mode 8003 - */ 8004 - drsprintk(ioc, ioc_info(ioc, "write magic sequence\n")); 8005 - writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); 8006 - writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence); 8007 - writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence); 8008 - writel(MPI2_WRSEQ_3RD_KEY_VALUE, &ioc->chip->WriteSequence); 8009 - writel(MPI2_WRSEQ_4TH_KEY_VALUE, &ioc->chip->WriteSequence); 8010 - writel(MPI2_WRSEQ_5TH_KEY_VALUE, &ioc->chip->WriteSequence); 8011 - writel(MPI2_WRSEQ_6TH_KEY_VALUE, &ioc->chip->WriteSequence); 8012 - 8013 - /* wait 100 msec */ 8014 - msleep(100); 8015 - 8016 - if (count++ > 20) { 8017 - ioc_info(ioc, 8018 - "Stop writing magic sequence after 20 retries\n"); 8019 - _base_dump_reg_set(ioc); 8020 - goto out; 8021 - } 8022 - 8023 - host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic); 8024 - drsprintk(ioc, 8025 - ioc_info(ioc, "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n", 8026 - count, host_diagnostic)); 8027 - 8028 - } while ((host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE) == 0); 7938 + mutex_lock(&ioc->hostdiag_unlock_mutex); 7939 + if (mpt3sas_base_unlock_and_get_host_diagnostic(ioc, &host_diagnostic)) 7940 + goto out; 8029 7941 8030 7942 hcb_size = ioc->base_readl(&ioc->chip->HCBSize); 8031 - 8032 7943 drsprintk(ioc, ioc_info(ioc, "diag reset: issued\n")); 8033 7944 writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER, 8034 7945 &ioc->chip->HostDiagnostic); 8035 7946 8036 - /*This delay allows the chip PCIe hardware time to finish reset tasks*/ 7947 + /* This delay allows the chip PCIe hardware time to finish reset tasks */ 8037 7948 msleep(MPI2_HARD_RESET_PCIE_FIRST_READ_DELAY_MICRO_SEC/1000); 8038 7949 8039 7950 /* Approximately 300 second max wait */ 8040 7951 for (count = 0; count < (300000000 / 8041 - MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) { 7952 + MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) { 8042 7953 8043 7954 host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic); 8044 7955 ··· 8023 7990 if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER)) 8024 7991 break; 8025 7992 8026 - msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC / 1000); 7993 + /* Wait to pass the second read delay window */ 7994 + msleep(MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC/1000); 8027 7995 } 8028 7996 8029 7997 if (host_diagnostic & MPI2_DIAG_HCB_MODE) { 8030 7998 8031 7999 drsprintk(ioc, 8032 - ioc_info(ioc, "restart the adapter assuming the HCB Address points to good F/W\n")); 8000 + ioc_info(ioc, "restart the adapter assuming the\n" 8001 + "HCB Address points to good F/W\n")); 8033 8002 host_diagnostic &= ~MPI2_DIAG_BOOT_DEVICE_SELECT_MASK; 8034 8003 host_diagnostic |= MPI2_DIAG_BOOT_DEVICE_SELECT_HCDW; 8035 8004 writel(host_diagnostic, &ioc->chip->HostDiagnostic); ··· 8045 8010 writel(host_diagnostic & ~MPI2_DIAG_HOLD_IOC_RESET, 8046 8011 &ioc->chip->HostDiagnostic); 8047 8012 8048 - drsprintk(ioc, 8049 - ioc_info(ioc, "disable writes to the diagnostic register\n")); 8050 - writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence); 8013 + mpt3sas_base_lock_host_diagnostic(ioc); 8014 + mutex_unlock(&ioc->hostdiag_unlock_mutex); 8051 8015 8052 8016 drsprintk(ioc, ioc_info(ioc, "Wait for FW to go to the READY state\n")); 8053 8017 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20); ··· 8064 8030 out: 8065 8031 pci_cfg_access_unlock(ioc->pdev); 8066 8032 ioc_err(ioc, "diag reset: FAILED\n"); 8033 + mutex_unlock(&ioc->hostdiag_unlock_mutex); 8067 8034 return -EFAULT; 8068 8035 } 8069 8036
+6 -2
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 77 77 #define MPT3SAS_DRIVER_NAME "mpt3sas" 78 78 #define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>" 79 79 #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" 80 - #define MPT3SAS_DRIVER_VERSION "43.100.00.00" 81 - #define MPT3SAS_MAJOR_VERSION 43 80 + #define MPT3SAS_DRIVER_VERSION "48.100.00.00" 81 + #define MPT3SAS_MAJOR_VERSION 48 82 82 #define MPT3SAS_MINOR_VERSION 100 83 83 #define MPT3SAS_BUILD_VERSION 0 84 84 #define MPT3SAS_RELEASE_VERSION 00 ··· 1366 1366 u8 got_task_abort_from_ioctl; 1367 1367 1368 1368 struct mutex reset_in_progress_mutex; 1369 + struct mutex hostdiag_unlock_mutex; 1369 1370 spinlock_t ioc_reset_in_progress_lock; 1370 1371 u8 ioc_link_reset_in_progress; 1371 1372 ··· 1791 1790 int mpt3sas_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num); 1792 1791 void mpt3sas_base_pause_mq_polling(struct MPT3SAS_ADAPTER *ioc); 1793 1792 void mpt3sas_base_resume_mq_polling(struct MPT3SAS_ADAPTER *ioc); 1793 + int mpt3sas_base_unlock_and_get_host_diagnostic(struct MPT3SAS_ADAPTER *ioc, 1794 + u32 *host_diagnostic); 1795 + void mpt3sas_base_lock_host_diagnostic(struct MPT3SAS_ADAPTER *ioc); 1794 1796 1795 1797 /* scsih shared API */ 1796 1798 struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
+54
drivers/scsi/mpt3sas/mpt3sas_ctl.c
··· 2543 2543 return 0; 2544 2544 } 2545 2545 2546 + /** 2547 + * _ctl_enable_diag_sbr_reload - enable sbr reload bit 2548 + * @ioc: per adapter object 2549 + * @arg: user space buffer containing ioctl content 2550 + * 2551 + * Enable the SBR reload bit 2552 + */ 2553 + static int 2554 + _ctl_enable_diag_sbr_reload(struct MPT3SAS_ADAPTER *ioc, void __user *arg) 2555 + { 2556 + u32 ioc_state, host_diagnostic; 2557 + 2558 + if (ioc->shost_recovery || 2559 + ioc->pci_error_recovery || ioc->is_driver_loading || 2560 + ioc->remove_host) 2561 + return -EAGAIN; 2562 + 2563 + ioc_state = mpt3sas_base_get_iocstate(ioc, 1); 2564 + 2565 + if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) 2566 + return -EFAULT; 2567 + 2568 + host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic); 2569 + 2570 + if (host_diagnostic & MPI2_DIAG_SBR_RELOAD) 2571 + return 0; 2572 + 2573 + if (mutex_trylock(&ioc->hostdiag_unlock_mutex)) { 2574 + if (mpt3sas_base_unlock_and_get_host_diagnostic(ioc, &host_diagnostic)) { 2575 + mutex_unlock(&ioc->hostdiag_unlock_mutex); 2576 + return -EFAULT; 2577 + } 2578 + } else 2579 + return -EAGAIN; 2580 + 2581 + host_diagnostic |= MPI2_DIAG_SBR_RELOAD; 2582 + writel(host_diagnostic, &ioc->chip->HostDiagnostic); 2583 + host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic); 2584 + mpt3sas_base_lock_host_diagnostic(ioc); 2585 + mutex_unlock(&ioc->hostdiag_unlock_mutex); 2586 + 2587 + if (!(host_diagnostic & MPI2_DIAG_SBR_RELOAD)) { 2588 + ioc_err(ioc, "%s: Failed to set Diag SBR Reload Bit\n", __func__); 2589 + return -EFAULT; 2590 + } 2591 + 2592 + ioc_info(ioc, "%s: Successfully set the Diag SBR Reload Bit\n", __func__); 2593 + return 0; 2594 + } 2595 + 2546 2596 #ifdef CONFIG_COMPAT 2547 2597 /** 2548 2598 * _ctl_compat_mpt_command - convert 32bit pointers to 64bit. ··· 2768 2718 case MPT3ADDNLDIAGQUERY: 2769 2719 if (_IOC_SIZE(cmd) == sizeof(struct mpt3_addnl_diag_query)) 2770 2720 ret = _ctl_addnl_diag_query(ioc, arg); 2721 + break; 2722 + case MPT3ENABLEDIAGSBRRELOAD: 2723 + if (_IOC_SIZE(cmd) == sizeof(struct mpt3_enable_diag_sbr_reload)) 2724 + ret = _ctl_enable_diag_sbr_reload(ioc, arg); 2771 2725 break; 2772 2726 default: 2773 2727 dctlprintk(ioc,
+10
drivers/scsi/mpt3sas/mpt3sas_ctl.h
··· 98 98 struct mpt3_diag_read_buffer) 99 99 #define MPT3ADDNLDIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 32, \ 100 100 struct mpt3_addnl_diag_query) 101 + #define MPT3ENABLEDIAGSBRRELOAD _IOWR(MPT3_MAGIC_NUMBER, 33, \ 102 + struct mpt3_enable_diag_sbr_reload) 101 103 102 104 /* Trace Buffer default UniqueId */ 103 105 #define MPT2DIAGBUFFUNIQUEID (0x07075900) ··· 448 446 uint32_t unique_id; 449 447 struct htb_rel_query rel_query; 450 448 uint32_t reserved2[2]; 449 + }; 450 + 451 + /** 452 + * struct mpt3_enable_diag_sbr_reload - enable sbr reload 453 + * @hdr - generic header 454 + */ 455 + struct mpt3_enable_diag_sbr_reload { 456 + struct mpt3_ioctl_header hdr; 451 457 }; 452 458 453 459 #endif /* MPT3SAS_CTL_H_INCLUDED */
+1
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 12240 12240 12241 12241 /* misc semaphores and spin locks */ 12242 12242 mutex_init(&ioc->reset_in_progress_mutex); 12243 + mutex_init(&ioc->hostdiag_unlock_mutex); 12243 12244 /* initializing pci_access_mutex lock */ 12244 12245 mutex_init(&ioc->pci_access_mutex); 12245 12246 spin_lock_init(&ioc->ioc_reset_in_progress_lock);
+3 -3
drivers/scsi/pm8001/pm8001_ctl.c
··· 880 880 if (pm8001_ha->fw_status != FLASH_IN_PROGRESS) 881 881 pm8001_ha->fw_status = FLASH_OK; 882 882 883 - return snprintf(buf, PAGE_SIZE, "status=%x %s\n", 884 - flash_error_table[i].err_code, 885 - flash_error_table[i].reason); 883 + return sysfs_emit(buf, "status=%x %s\n", 884 + flash_error_table[i].err_code, 885 + flash_error_table[i].reason); 886 886 } 887 887 static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, 888 888 pm8001_show_update_fw, pm8001_store_update_fw);
-1
drivers/scsi/qla1280.c
··· 2478 2478 /* Load return mailbox registers. */ 2479 2479 optr = mb; 2480 2480 iptr = (uint16_t *) &ha->mailbox_out[0]; 2481 - mr = MAILBOX_REGISTER_COUNT; 2482 2481 memcpy(optr, iptr, MAILBOX_REGISTER_COUNT * sizeof(uint16_t)); 2483 2482 2484 2483 if (ha->flags.reset_marker)
+2 -2
drivers/scsi/scsi_debug.c
··· 899 899 static char sdebug_proc_name[] = MY_NAME; 900 900 static const char *my_name = MY_NAME; 901 901 902 - static struct bus_type pseudo_lld_bus; 902 + static const struct bus_type pseudo_lld_bus; 903 903 904 904 static struct device_driver sdebug_driverfs_driver = { 905 905 .name = sdebug_proc_name, ··· 8405 8405 scsi_host_put(sdbg_host->shost); 8406 8406 } 8407 8407 8408 - static struct bus_type pseudo_lld_bus = { 8408 + static const struct bus_type pseudo_lld_bus = { 8409 8409 .name = "pseudo", 8410 8410 .probe = sdebug_driver_probe, 8411 8411 .remove = sdebug_driver_remove,
+3 -3
drivers/scsi/scsi_devinfo.c
··· 551 551 if (model) 552 552 strflags = strsep(&next, next_check); 553 553 if (!model || !strflags) { 554 - printk(KERN_ERR "%s: bad dev info string '%s' '%s'" 555 - " '%s'\n", __func__, vendor, model, 556 - strflags); 554 + pr_err("%s: bad dev info string '%s' '%s' '%s'\n", 555 + __func__, vendor, model ? model : "", 556 + strflags ? strflags : ""); 557 557 res = -EINVAL; 558 558 } else 559 559 res = scsi_dev_info_list_add(0 /* compatible */, vendor,
+114 -10
drivers/scsi/scsi_lib.c
··· 184 184 __scsi_queue_insert(cmd, reason, true); 185 185 } 186 186 187 + void scsi_failures_reset_retries(struct scsi_failures *failures) 188 + { 189 + struct scsi_failure *failure; 190 + 191 + failures->total_retries = 0; 192 + 193 + for (failure = failures->failure_definitions; failure->result; 194 + failure++) 195 + failure->retries = 0; 196 + } 197 + EXPORT_SYMBOL_GPL(scsi_failures_reset_retries); 198 + 199 + /** 200 + * scsi_check_passthrough - Determine if passthrough scsi_cmnd needs a retry. 201 + * @scmd: scsi_cmnd to check. 202 + * @failures: scsi_failures struct that lists failures to check for. 203 + * 204 + * Returns -EAGAIN if the caller should retry else 0. 205 + */ 206 + static int scsi_check_passthrough(struct scsi_cmnd *scmd, 207 + struct scsi_failures *failures) 208 + { 209 + struct scsi_failure *failure; 210 + struct scsi_sense_hdr sshdr; 211 + enum sam_status status; 212 + 213 + if (!failures) 214 + return 0; 215 + 216 + for (failure = failures->failure_definitions; failure->result; 217 + failure++) { 218 + if (failure->result == SCMD_FAILURE_RESULT_ANY) 219 + goto maybe_retry; 220 + 221 + if (host_byte(scmd->result) && 222 + host_byte(scmd->result) == host_byte(failure->result)) 223 + goto maybe_retry; 224 + 225 + status = status_byte(scmd->result); 226 + if (!status) 227 + continue; 228 + 229 + if (failure->result == SCMD_FAILURE_STAT_ANY && 230 + !scsi_status_is_good(scmd->result)) 231 + goto maybe_retry; 232 + 233 + if (status != status_byte(failure->result)) 234 + continue; 235 + 236 + if (status_byte(failure->result) != SAM_STAT_CHECK_CONDITION || 237 + failure->sense == SCMD_FAILURE_SENSE_ANY) 238 + goto maybe_retry; 239 + 240 + if (!scsi_command_normalize_sense(scmd, &sshdr)) 241 + return 0; 242 + 243 + if (failure->sense != sshdr.sense_key) 244 + continue; 245 + 246 + if (failure->asc == SCMD_FAILURE_ASC_ANY) 247 + goto maybe_retry; 248 + 249 + if (failure->asc != sshdr.asc) 250 + continue; 251 + 252 + if (failure->ascq == SCMD_FAILURE_ASCQ_ANY || 253 + failure->ascq == sshdr.ascq) 254 + goto maybe_retry; 255 + } 256 + 257 + return 0; 258 + 259 + maybe_retry: 260 + if (failure->allowed) { 261 + if (failure->allowed == SCMD_FAILURE_NO_LIMIT || 262 + ++failure->retries <= failure->allowed) 263 + return -EAGAIN; 264 + } else { 265 + if (failures->total_allowed == SCMD_FAILURE_NO_LIMIT || 266 + ++failures->total_retries <= failures->total_allowed) 267 + return -EAGAIN; 268 + } 269 + 270 + return 0; 271 + } 272 + 187 273 /** 188 274 * scsi_execute_cmd - insert request and wait for the result 189 275 * @sdev: scsi_device ··· 278 192 * @buffer: data buffer 279 193 * @bufflen: len of buffer 280 194 * @timeout: request timeout in HZ 281 - * @retries: number of times to retry request 195 + * @ml_retries: number of times SCSI midlayer will retry request 282 196 * @args: Optional args. See struct definition for field descriptions 283 197 * 284 198 * Returns the scsi_cmnd result field if a command was executed, or a negative ··· 286 200 */ 287 201 int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd, 288 202 blk_opf_t opf, void *buffer, unsigned int bufflen, 289 - int timeout, int retries, 203 + int timeout, int ml_retries, 290 204 const struct scsi_exec_args *args) 291 205 { 292 206 static const struct scsi_exec_args default_args; ··· 300 214 args->sense_len != SCSI_SENSE_BUFFERSIZE)) 301 215 return -EINVAL; 302 216 217 + retry: 303 218 req = scsi_alloc_request(sdev->request_queue, opf, args->req_flags); 304 219 if (IS_ERR(req)) 305 220 return PTR_ERR(req); ··· 314 227 scmd = blk_mq_rq_to_pdu(req); 315 228 scmd->cmd_len = COMMAND_SIZE(cmd[0]); 316 229 memcpy(scmd->cmnd, cmd, scmd->cmd_len); 317 - scmd->allowed = retries; 230 + scmd->allowed = ml_retries; 318 231 scmd->flags |= args->scmd_flags; 319 232 req->timeout = timeout; 320 233 req->rq_flags |= RQF_QUIET; ··· 323 236 * head injection *required* here otherwise quiesce won't work 324 237 */ 325 238 blk_execute_rq(req, true); 239 + 240 + if (scsi_check_passthrough(scmd, args->failures) == -EAGAIN) { 241 + blk_mq_free_request(req); 242 + goto retry; 243 + } 326 244 327 245 /* 328 246 * Some devices (USB mass-storage in particular) may transfer ··· 2264 2172 unsigned char cmd[12]; 2265 2173 int use_10_for_ms; 2266 2174 int header_length; 2267 - int result, retry_count = retries; 2175 + int result; 2268 2176 struct scsi_sense_hdr my_sshdr; 2177 + struct scsi_failure failure_defs[] = { 2178 + { 2179 + .sense = UNIT_ATTENTION, 2180 + .asc = SCMD_FAILURE_ASC_ANY, 2181 + .ascq = SCMD_FAILURE_ASCQ_ANY, 2182 + .allowed = retries, 2183 + .result = SAM_STAT_CHECK_CONDITION, 2184 + }, 2185 + {} 2186 + }; 2187 + struct scsi_failures failures = { 2188 + .failure_definitions = failure_defs, 2189 + }; 2269 2190 const struct scsi_exec_args exec_args = { 2270 2191 /* caller might not be interested in sense, but we need it */ 2271 2192 .sshdr = sshdr ? : &my_sshdr, 2193 + .failures = &failures, 2272 2194 }; 2273 2195 2274 2196 memset(data, 0, sizeof(*data)); ··· 2343 2237 sdev->use_10_for_ms = 0; 2344 2238 goto retry; 2345 2239 } 2346 - } 2347 - if (scsi_status_is_check_condition(result) && 2348 - sshdr->sense_key == UNIT_ATTENTION && 2349 - retry_count) { 2350 - retry_count--; 2351 - goto retry; 2352 2240 } 2353 2241 } 2354 2242 return -EIO; ··· 3436 3336 scmd->result = SAM_STAT_CHECK_CONDITION; 3437 3337 } 3438 3338 EXPORT_SYMBOL_GPL(scsi_build_sense); 3339 + 3340 + #ifdef CONFIG_SCSI_LIB_KUNIT_TEST 3341 + #include "scsi_lib_test.c" 3342 + #endif
+330
drivers/scsi/scsi_lib_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * KUnit tests for scsi_lib.c. 4 + * 5 + * Copyright (C) 2023, Oracle Corporation 6 + */ 7 + #include <kunit/test.h> 8 + 9 + #include <scsi/scsi_proto.h> 10 + #include <scsi/scsi_cmnd.h> 11 + #include <scsi/scsi_device.h> 12 + 13 + #define SCSI_LIB_TEST_MAX_ALLOWED 3 14 + #define SCSI_LIB_TEST_TOTAL_MAX_ALLOWED 5 15 + 16 + static void scsi_lib_test_multiple_sense(struct kunit *test) 17 + { 18 + struct scsi_failure multiple_sense_failure_defs[] = { 19 + { 20 + .sense = DATA_PROTECT, 21 + .asc = 0x1, 22 + .ascq = 0x1, 23 + .result = SAM_STAT_CHECK_CONDITION, 24 + }, 25 + { 26 + .sense = UNIT_ATTENTION, 27 + .asc = 0x11, 28 + .ascq = 0x0, 29 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 30 + .result = SAM_STAT_CHECK_CONDITION, 31 + }, 32 + { 33 + .sense = NOT_READY, 34 + .asc = 0x11, 35 + .ascq = 0x22, 36 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 37 + .result = SAM_STAT_CHECK_CONDITION, 38 + }, 39 + { 40 + .sense = ABORTED_COMMAND, 41 + .asc = 0x11, 42 + .ascq = SCMD_FAILURE_ASCQ_ANY, 43 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 44 + .result = SAM_STAT_CHECK_CONDITION, 45 + }, 46 + { 47 + .sense = HARDWARE_ERROR, 48 + .asc = SCMD_FAILURE_ASC_ANY, 49 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 50 + .result = SAM_STAT_CHECK_CONDITION, 51 + }, 52 + { 53 + .sense = ILLEGAL_REQUEST, 54 + .asc = 0x91, 55 + .ascq = 0x36, 56 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 57 + .result = SAM_STAT_CHECK_CONDITION, 58 + }, 59 + {} 60 + }; 61 + struct scsi_failures failures = { 62 + .failure_definitions = multiple_sense_failure_defs, 63 + }; 64 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 65 + struct scsi_cmnd sc = { 66 + .sense_buffer = sense, 67 + }; 68 + int i; 69 + 70 + /* Match end of array */ 71 + scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36); 72 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 73 + /* Basic match in array */ 74 + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x11, 0x0); 75 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 76 + /* No matching sense entry */ 77 + scsi_build_sense(&sc, 0, MISCOMPARE, 0x11, 0x11); 78 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 79 + /* Match using SCMD_FAILURE_ASCQ_ANY */ 80 + scsi_build_sense(&sc, 0, ABORTED_COMMAND, 0x11, 0x22); 81 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 82 + /* Fail to match */ 83 + scsi_build_sense(&sc, 0, ABORTED_COMMAND, 0x22, 0x22); 84 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 85 + /* Match using SCMD_FAILURE_ASC_ANY */ 86 + scsi_build_sense(&sc, 0, HARDWARE_ERROR, 0x11, 0x22); 87 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 88 + /* No matching status entry */ 89 + sc.result = SAM_STAT_RESERVATION_CONFLICT; 90 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 91 + 92 + /* Test hitting allowed limit */ 93 + scsi_build_sense(&sc, 0, NOT_READY, 0x11, 0x22); 94 + for (i = 0; i < SCSI_LIB_TEST_MAX_ALLOWED; i++) 95 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, 96 + &failures)); 97 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 98 + 99 + /* reset retries so we can retest */ 100 + failures.failure_definitions = multiple_sense_failure_defs; 101 + scsi_failures_reset_retries(&failures); 102 + 103 + /* Test no retries allowed */ 104 + scsi_build_sense(&sc, 0, DATA_PROTECT, 0x1, 0x1); 105 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 106 + } 107 + 108 + static void scsi_lib_test_any_sense(struct kunit *test) 109 + { 110 + struct scsi_failure any_sense_failure_defs[] = { 111 + { 112 + .result = SCMD_FAILURE_SENSE_ANY, 113 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 114 + }, 115 + {} 116 + }; 117 + struct scsi_failures failures = { 118 + .failure_definitions = any_sense_failure_defs, 119 + }; 120 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 121 + struct scsi_cmnd sc = { 122 + .sense_buffer = sense, 123 + }; 124 + 125 + /* Match using SCMD_FAILURE_SENSE_ANY */ 126 + failures.failure_definitions = any_sense_failure_defs; 127 + scsi_build_sense(&sc, 0, MEDIUM_ERROR, 0x11, 0x22); 128 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 129 + } 130 + 131 + static void scsi_lib_test_host(struct kunit *test) 132 + { 133 + struct scsi_failure retryable_host_failure_defs[] = { 134 + { 135 + .result = DID_TRANSPORT_DISRUPTED << 16, 136 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 137 + }, 138 + { 139 + .result = DID_TIME_OUT << 16, 140 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 141 + }, 142 + {} 143 + }; 144 + struct scsi_failures failures = { 145 + .failure_definitions = retryable_host_failure_defs, 146 + }; 147 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 148 + struct scsi_cmnd sc = { 149 + .sense_buffer = sense, 150 + }; 151 + 152 + /* No matching host byte entry */ 153 + failures.failure_definitions = retryable_host_failure_defs; 154 + sc.result = DID_NO_CONNECT << 16; 155 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 156 + /* Matching host byte entry */ 157 + sc.result = DID_TIME_OUT << 16; 158 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 159 + } 160 + 161 + static void scsi_lib_test_any_failure(struct kunit *test) 162 + { 163 + struct scsi_failure any_failure_defs[] = { 164 + { 165 + .result = SCMD_FAILURE_RESULT_ANY, 166 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 167 + }, 168 + {} 169 + }; 170 + struct scsi_failures failures = { 171 + .failure_definitions = any_failure_defs, 172 + }; 173 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 174 + struct scsi_cmnd sc = { 175 + .sense_buffer = sense, 176 + }; 177 + 178 + /* Match SCMD_FAILURE_RESULT_ANY */ 179 + failures.failure_definitions = any_failure_defs; 180 + sc.result = DID_TRANSPORT_FAILFAST << 16; 181 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 182 + } 183 + 184 + static void scsi_lib_test_any_status(struct kunit *test) 185 + { 186 + struct scsi_failure any_status_failure_defs[] = { 187 + { 188 + .result = SCMD_FAILURE_STAT_ANY, 189 + .allowed = SCSI_LIB_TEST_MAX_ALLOWED, 190 + }, 191 + {} 192 + }; 193 + struct scsi_failures failures = { 194 + .failure_definitions = any_status_failure_defs, 195 + }; 196 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 197 + struct scsi_cmnd sc = { 198 + .sense_buffer = sense, 199 + }; 200 + 201 + /* Test any status handling */ 202 + failures.failure_definitions = any_status_failure_defs; 203 + sc.result = SAM_STAT_RESERVATION_CONFLICT; 204 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 205 + } 206 + 207 + static void scsi_lib_test_total_allowed(struct kunit *test) 208 + { 209 + struct scsi_failure total_allowed_defs[] = { 210 + { 211 + .sense = UNIT_ATTENTION, 212 + .asc = SCMD_FAILURE_ASC_ANY, 213 + .ascq = SCMD_FAILURE_ASCQ_ANY, 214 + .result = SAM_STAT_CHECK_CONDITION, 215 + }, 216 + /* Fail all CCs except the UA above */ 217 + { 218 + .sense = SCMD_FAILURE_SENSE_ANY, 219 + .result = SAM_STAT_CHECK_CONDITION, 220 + }, 221 + /* Retry any other errors not listed above */ 222 + { 223 + .result = SCMD_FAILURE_RESULT_ANY, 224 + }, 225 + {} 226 + }; 227 + struct scsi_failures failures = { 228 + .failure_definitions = total_allowed_defs, 229 + }; 230 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 231 + struct scsi_cmnd sc = { 232 + .sense_buffer = sense, 233 + }; 234 + int i; 235 + 236 + /* Test total_allowed */ 237 + failures.failure_definitions = total_allowed_defs; 238 + scsi_failures_reset_retries(&failures); 239 + failures.total_allowed = SCSI_LIB_TEST_TOTAL_MAX_ALLOWED; 240 + 241 + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x28, 0x0); 242 + for (i = 0; i < SCSI_LIB_TEST_TOTAL_MAX_ALLOWED; i++) 243 + /* Retry since we under the total_allowed limit */ 244 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, 245 + &failures)); 246 + sc.result = DID_TIME_OUT << 16; 247 + /* We have now hit the total_allowed limit so no more retries */ 248 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 249 + } 250 + 251 + static void scsi_lib_test_mixed_total(struct kunit *test) 252 + { 253 + struct scsi_failure mixed_total_defs[] = { 254 + { 255 + .sense = UNIT_ATTENTION, 256 + .asc = 0x28, 257 + .result = SAM_STAT_CHECK_CONDITION, 258 + }, 259 + { 260 + .sense = UNIT_ATTENTION, 261 + .asc = 0x29, 262 + .result = SAM_STAT_CHECK_CONDITION, 263 + }, 264 + { 265 + .allowed = 1, 266 + .result = DID_TIME_OUT << 16, 267 + }, 268 + {} 269 + }; 270 + u8 sense[SCSI_SENSE_BUFFERSIZE] = {}; 271 + struct scsi_failures failures = { 272 + .failure_definitions = mixed_total_defs, 273 + }; 274 + struct scsi_cmnd sc = { 275 + .sense_buffer = sense, 276 + }; 277 + int i; 278 + 279 + /* 280 + * Test total_allowed when there is a mix of per failure allowed 281 + * and total_allowed limits. 282 + */ 283 + failures.failure_definitions = mixed_total_defs; 284 + scsi_failures_reset_retries(&failures); 285 + failures.total_allowed = SCSI_LIB_TEST_TOTAL_MAX_ALLOWED; 286 + 287 + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x28, 0x0); 288 + for (i = 0; i < SCSI_LIB_TEST_TOTAL_MAX_ALLOWED; i++) 289 + /* Retry since we under the total_allowed limit */ 290 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, 291 + &failures)); 292 + /* Do not retry since we are now over total_allowed limit */ 293 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 294 + 295 + scsi_failures_reset_retries(&failures); 296 + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x28, 0x0); 297 + for (i = 0; i < SCSI_LIB_TEST_TOTAL_MAX_ALLOWED; i++) 298 + /* Retry since we under the total_allowed limit */ 299 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, 300 + &failures)); 301 + sc.result = DID_TIME_OUT << 16; 302 + /* Retry because this failure has a per failure limit */ 303 + KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures)); 304 + scsi_build_sense(&sc, 0, UNIT_ATTENTION, 0x29, 0x0); 305 + /* total_allowed is now hit so no more retries */ 306 + KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures)); 307 + } 308 + 309 + static void scsi_lib_test_check_passthough(struct kunit *test) 310 + { 311 + scsi_lib_test_multiple_sense(test); 312 + scsi_lib_test_any_sense(test); 313 + scsi_lib_test_host(test); 314 + scsi_lib_test_any_failure(test); 315 + scsi_lib_test_any_status(test); 316 + scsi_lib_test_total_allowed(test); 317 + scsi_lib_test_mixed_total(test); 318 + } 319 + 320 + static struct kunit_case scsi_lib_test_cases[] = { 321 + KUNIT_CASE(scsi_lib_test_check_passthough), 322 + {} 323 + }; 324 + 325 + static struct kunit_suite scsi_lib_test_suite = { 326 + .name = "scsi_lib", 327 + .test_cases = scsi_lib_test_cases, 328 + }; 329 + 330 + kunit_test_suite(scsi_lib_test_suite);
+1 -1
drivers/scsi/scsi_priv.h
··· 156 156 extern struct scsi_transport_template blank_transport_template; 157 157 extern void __scsi_remove_device(struct scsi_device *); 158 158 159 - extern struct bus_type scsi_bus_type; 159 + extern const struct bus_type scsi_bus_type; 160 160 extern const struct attribute_group *scsi_shost_groups[]; 161 161 162 162 /* scsi_netlink.c */
+65 -42
drivers/scsi/scsi_scan.c
··· 412 412 put_device(parent); 413 413 } 414 414 415 - static struct device_type scsi_target_type = { 415 + static const struct device_type scsi_target_type = { 416 416 .name = "scsi_target", 417 417 .release = scsi_target_dev_release, 418 418 }; ··· 626 626 } 627 627 EXPORT_SYMBOL(scsi_sanitize_inquiry_string); 628 628 629 + 629 630 /** 630 631 * scsi_probe_lun - probe a single LUN using a SCSI INQUIRY 631 632 * @sdev: scsi_device to probe ··· 648 647 int first_inquiry_len, try_inquiry_len, next_inquiry_len; 649 648 int response_len = 0; 650 649 int pass, count, result, resid; 651 - struct scsi_sense_hdr sshdr; 650 + struct scsi_failure failure_defs[] = { 651 + /* 652 + * not-ready to ready transition [asc/ascq=0x28/0x0] or 653 + * power-on, reset [asc/ascq=0x29/0x0], continue. INQUIRY 654 + * should not yield UNIT_ATTENTION but many buggy devices do 655 + * so anyway. 656 + */ 657 + { 658 + .sense = UNIT_ATTENTION, 659 + .asc = 0x28, 660 + .result = SAM_STAT_CHECK_CONDITION, 661 + }, 662 + { 663 + .sense = UNIT_ATTENTION, 664 + .asc = 0x29, 665 + .result = SAM_STAT_CHECK_CONDITION, 666 + }, 667 + { 668 + .allowed = 1, 669 + .result = DID_TIME_OUT << 16, 670 + }, 671 + {} 672 + }; 673 + struct scsi_failures failures = { 674 + .total_allowed = 3, 675 + .failure_definitions = failure_defs, 676 + }; 652 677 const struct scsi_exec_args exec_args = { 653 - .sshdr = &sshdr, 654 678 .resid = &resid, 679 + .failures = &failures, 655 680 }; 656 681 657 682 *bflags = 0; ··· 695 668 pass, try_inquiry_len)); 696 669 697 670 /* Each pass gets up to three chances to ignore Unit Attention */ 671 + scsi_failures_reset_retries(&failures); 672 + 698 673 for (count = 0; count < 3; ++count) { 699 674 memset(scsi_cmd, 0, 6); 700 675 scsi_cmd[0] = INQUIRY; ··· 713 684 "scsi scan: INQUIRY %s with code 0x%x\n", 714 685 result ? "failed" : "successful", result)); 715 686 716 - if (result > 0) { 717 - /* 718 - * not-ready to ready transition [asc/ascq=0x28/0x0] 719 - * or power-on, reset [asc/ascq=0x29/0x0], continue. 720 - * INQUIRY should not yield UNIT_ATTENTION 721 - * but many buggy devices do so anyway. 722 - */ 723 - if (scsi_status_is_check_condition(result) && 724 - scsi_sense_valid(&sshdr)) { 725 - if ((sshdr.sense_key == UNIT_ATTENTION) && 726 - ((sshdr.asc == 0x28) || 727 - (sshdr.asc == 0x29)) && 728 - (sshdr.ascq == 0)) 729 - continue; 730 - } 731 - } else if (result == 0) { 687 + if (result == 0) { 732 688 /* 733 689 * if nothing was transferred, we try 734 690 * again. It's a workaround for some USB ··· 1416 1402 unsigned int length; 1417 1403 u64 lun; 1418 1404 unsigned int num_luns; 1419 - unsigned int retries; 1420 1405 int result; 1421 1406 struct scsi_lun *lunp, *lun_data; 1422 - struct scsi_sense_hdr sshdr; 1423 1407 struct scsi_device *sdev; 1424 1408 struct Scsi_Host *shost = dev_to_shost(&starget->dev); 1409 + struct scsi_failure failure_defs[] = { 1410 + { 1411 + .sense = UNIT_ATTENTION, 1412 + .asc = SCMD_FAILURE_ASC_ANY, 1413 + .ascq = SCMD_FAILURE_ASCQ_ANY, 1414 + .result = SAM_STAT_CHECK_CONDITION, 1415 + }, 1416 + /* Fail all CCs except the UA above */ 1417 + { 1418 + .sense = SCMD_FAILURE_SENSE_ANY, 1419 + .result = SAM_STAT_CHECK_CONDITION, 1420 + }, 1421 + /* Retry any other errors not listed above */ 1422 + { 1423 + .result = SCMD_FAILURE_RESULT_ANY, 1424 + }, 1425 + {} 1426 + }; 1427 + struct scsi_failures failures = { 1428 + .total_allowed = 3, 1429 + .failure_definitions = failure_defs, 1430 + }; 1425 1431 const struct scsi_exec_args exec_args = { 1426 - .sshdr = &sshdr, 1432 + .failures = &failures, 1427 1433 }; 1428 1434 int ret = 0; 1429 1435 ··· 1514 1480 * should come through as a check condition, and will not generate 1515 1481 * a retry. 1516 1482 */ 1517 - for (retries = 0; retries < 3; retries++) { 1518 - SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, 1519 - "scsi scan: Sending REPORT LUNS to (try %d)\n", 1520 - retries)); 1483 + scsi_failures_reset_retries(&failures); 1521 1484 1522 - result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, 1523 - lun_data, length, 1524 - SCSI_REPORT_LUNS_TIMEOUT, 3, 1525 - &exec_args); 1485 + SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, 1486 + "scsi scan: Sending REPORT LUNS\n")); 1526 1487 1527 - SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, 1528 - "scsi scan: REPORT LUNS" 1529 - " %s (try %d) result 0x%x\n", 1530 - result ? "failed" : "successful", 1531 - retries, result)); 1532 - if (result == 0) 1533 - break; 1534 - else if (scsi_sense_valid(&sshdr)) { 1535 - if (sshdr.sense_key != UNIT_ATTENTION) 1536 - break; 1537 - } 1538 - } 1488 + result = scsi_execute_cmd(sdev, scsi_cmd, REQ_OP_DRV_IN, lun_data, 1489 + length, SCSI_REPORT_LUNS_TIMEOUT, 3, 1490 + &exec_args); 1539 1491 1492 + SCSI_LOG_SCAN_BUS(3, sdev_printk (KERN_INFO, sdev, 1493 + "scsi scan: REPORT LUNS %s result 0x%x\n", 1494 + result ? "failed" : "successful", result)); 1540 1495 if (result) { 1541 1496 /* 1542 1497 * The device probably does not support a REPORT LUN command
+3 -3
drivers/scsi/scsi_sysfs.c
··· 27 27 #include "scsi_priv.h" 28 28 #include "scsi_logging.h" 29 29 30 - static struct device_type scsi_dev_type; 30 + static const struct device_type scsi_dev_type; 31 31 32 32 static const struct { 33 33 enum scsi_device_state value; ··· 549 549 return 0; 550 550 } 551 551 552 - struct bus_type scsi_bus_type = { 552 + const struct bus_type scsi_bus_type = { 553 553 .name = "scsi", 554 554 .match = scsi_bus_match, 555 555 .uevent = scsi_bus_uevent, ··· 1626 1626 return 0; 1627 1627 } 1628 1628 1629 - static struct device_type scsi_dev_type = { 1629 + static const struct device_type scsi_dev_type = { 1630 1630 .name = "scsi_device", 1631 1631 .release = scsi_device_dev_release, 1632 1632 .groups = scsi_sdev_attr_groups,
+2 -2
drivers/scsi/scsi_transport_iscsi.c
··· 1201 1201 .release = iscsi_flashnode_conn_release, 1202 1202 }; 1203 1203 1204 - static struct bus_type iscsi_flashnode_bus; 1204 + static const struct bus_type iscsi_flashnode_bus; 1205 1205 1206 1206 int iscsi_flashnode_bus_match(struct device *dev, 1207 1207 struct device_driver *drv) ··· 1212 1212 } 1213 1213 EXPORT_SYMBOL_GPL(iscsi_flashnode_bus_match); 1214 1214 1215 - static struct bus_type iscsi_flashnode_bus = { 1215 + static const struct bus_type iscsi_flashnode_bus = { 1216 1216 .name = "iscsi_flashnode", 1217 1217 .match = &iscsi_flashnode_bus_match, 1218 1218 };
+18 -17
drivers/scsi/scsi_transport_spi.c
··· 108 108 enum req_op op, void *buffer, unsigned int bufflen, 109 109 struct scsi_sense_hdr *sshdr) 110 110 { 111 - int i, result; 112 - struct scsi_sense_hdr sshdr_tmp; 113 111 blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | 114 112 REQ_FAILFAST_DRIVER; 113 + struct scsi_failure failure_defs[] = { 114 + { 115 + .sense = UNIT_ATTENTION, 116 + .asc = SCMD_FAILURE_ASC_ANY, 117 + .ascq = SCMD_FAILURE_ASCQ_ANY, 118 + .allowed = DV_RETRIES, 119 + .result = SAM_STAT_CHECK_CONDITION, 120 + }, 121 + {} 122 + }; 123 + struct scsi_failures failures = { 124 + .failure_definitions = failure_defs, 125 + }; 115 126 const struct scsi_exec_args exec_args = { 127 + /* bypass the SDEV_QUIESCE state with BLK_MQ_REQ_PM */ 116 128 .req_flags = BLK_MQ_REQ_PM, 117 - .sshdr = sshdr ? : &sshdr_tmp, 129 + .sshdr = sshdr, 130 + .failures = &failures, 118 131 }; 119 132 120 - sshdr = exec_args.sshdr; 121 - 122 - for(i = 0; i < DV_RETRIES; i++) { 123 - /* 124 - * The purpose of the RQF_PM flag below is to bypass the 125 - * SDEV_QUIESCE state. 126 - */ 127 - result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, 128 - DV_TIMEOUT, 1, &exec_args); 129 - if (result < 0 || !scsi_sense_valid(sshdr) || 130 - sshdr->sense_key != UNIT_ATTENTION) 131 - break; 132 - } 133 - return result; 133 + return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1, 134 + &exec_args); 134 135 } 135 136 136 137 static struct {
+139 -81
drivers/scsi/sd.c
··· 1645 1645 1646 1646 static int sd_sync_cache(struct scsi_disk *sdkp) 1647 1647 { 1648 - int retries, res; 1648 + int res; 1649 1649 struct scsi_device *sdp = sdkp->device; 1650 1650 const int timeout = sdp->request_queue->rq_timeout 1651 1651 * SD_FLUSH_TIMEOUT_MULTIPLIER; 1652 + /* Leave the rest of the command zero to indicate flush everything. */ 1653 + const unsigned char cmd[16] = { sdp->use_16_for_sync ? 1654 + SYNCHRONIZE_CACHE_16 : SYNCHRONIZE_CACHE }; 1652 1655 struct scsi_sense_hdr sshdr; 1656 + struct scsi_failure failure_defs[] = { 1657 + { 1658 + .allowed = 3, 1659 + .result = SCMD_FAILURE_RESULT_ANY, 1660 + }, 1661 + {} 1662 + }; 1663 + struct scsi_failures failures = { 1664 + .failure_definitions = failure_defs, 1665 + }; 1653 1666 const struct scsi_exec_args exec_args = { 1654 1667 .req_flags = BLK_MQ_REQ_PM, 1655 1668 .sshdr = &sshdr, 1669 + .failures = &failures, 1656 1670 }; 1657 1671 1658 1672 if (!scsi_device_online(sdp)) 1659 1673 return -ENODEV; 1660 1674 1661 - for (retries = 3; retries > 0; --retries) { 1662 - unsigned char cmd[16] = { 0 }; 1663 - 1664 - if (sdp->use_16_for_sync) 1665 - cmd[0] = SYNCHRONIZE_CACHE_16; 1666 - else 1667 - cmd[0] = SYNCHRONIZE_CACHE; 1668 - /* 1669 - * Leave the rest of the command zero to indicate 1670 - * flush everything. 1671 - */ 1672 - res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, 1673 - timeout, sdkp->max_retries, &exec_args); 1674 - if (res == 0) 1675 - break; 1676 - } 1677 - 1675 + res = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0, timeout, 1676 + sdkp->max_retries, &exec_args); 1678 1677 if (res) { 1679 1678 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); 1680 1679 ··· 1800 1801 struct scsi_device *sdev = sdkp->device; 1801 1802 struct scsi_sense_hdr sshdr; 1802 1803 u8 cmd[10] = { PERSISTENT_RESERVE_IN, sa }; 1804 + struct scsi_failure failure_defs[] = { 1805 + { 1806 + .sense = UNIT_ATTENTION, 1807 + .asc = SCMD_FAILURE_ASC_ANY, 1808 + .ascq = SCMD_FAILURE_ASCQ_ANY, 1809 + .allowed = 5, 1810 + .result = SAM_STAT_CHECK_CONDITION, 1811 + }, 1812 + {} 1813 + }; 1814 + struct scsi_failures failures = { 1815 + .failure_definitions = failure_defs, 1816 + }; 1803 1817 const struct scsi_exec_args exec_args = { 1804 1818 .sshdr = &sshdr, 1819 + .failures = &failures, 1805 1820 }; 1806 1821 int result; 1807 1822 ··· 1902 1889 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); 1903 1890 struct scsi_device *sdev = sdkp->device; 1904 1891 struct scsi_sense_hdr sshdr; 1892 + struct scsi_failure failure_defs[] = { 1893 + { 1894 + .sense = UNIT_ATTENTION, 1895 + .asc = SCMD_FAILURE_ASC_ANY, 1896 + .ascq = SCMD_FAILURE_ASCQ_ANY, 1897 + .allowed = 5, 1898 + .result = SAM_STAT_CHECK_CONDITION, 1899 + }, 1900 + {} 1901 + }; 1902 + struct scsi_failures failures = { 1903 + .failure_definitions = failure_defs, 1904 + }; 1905 1905 const struct scsi_exec_args exec_args = { 1906 1906 .sshdr = &sshdr, 1907 + .failures = &failures, 1907 1908 }; 1908 1909 int result; 1909 1910 u8 cmd[16] = { 0, }; ··· 2262 2235 static void 2263 2236 sd_spinup_disk(struct scsi_disk *sdkp) 2264 2237 { 2265 - unsigned char cmd[10]; 2238 + static const u8 cmd[10] = { TEST_UNIT_READY }; 2266 2239 unsigned long spintime_expire = 0; 2267 - int retries, spintime; 2240 + int spintime, sense_valid = 0; 2268 2241 unsigned int the_result; 2269 2242 struct scsi_sense_hdr sshdr; 2243 + struct scsi_failure failure_defs[] = { 2244 + /* Do not retry Medium Not Present */ 2245 + { 2246 + .sense = UNIT_ATTENTION, 2247 + .asc = 0x3A, 2248 + .ascq = SCMD_FAILURE_ASCQ_ANY, 2249 + .result = SAM_STAT_CHECK_CONDITION, 2250 + }, 2251 + { 2252 + .sense = NOT_READY, 2253 + .asc = 0x3A, 2254 + .ascq = SCMD_FAILURE_ASCQ_ANY, 2255 + .result = SAM_STAT_CHECK_CONDITION, 2256 + }, 2257 + /* Retry when scsi_status_is_good would return false 3 times */ 2258 + { 2259 + .result = SCMD_FAILURE_STAT_ANY, 2260 + .allowed = 3, 2261 + }, 2262 + {} 2263 + }; 2264 + struct scsi_failures failures = { 2265 + .failure_definitions = failure_defs, 2266 + }; 2270 2267 const struct scsi_exec_args exec_args = { 2271 2268 .sshdr = &sshdr, 2269 + .failures = &failures, 2272 2270 }; 2273 - int sense_valid = 0; 2274 2271 2275 2272 spintime = 0; 2276 2273 2277 2274 /* Spin up drives, as required. Only do this at boot time */ 2278 2275 /* Spinup needs to be done for module loads too. */ 2279 2276 do { 2280 - retries = 0; 2277 + bool media_was_present = sdkp->media_present; 2281 2278 2282 - do { 2283 - bool media_was_present = sdkp->media_present; 2279 + scsi_failures_reset_retries(&failures); 2284 2280 2285 - cmd[0] = TEST_UNIT_READY; 2286 - memset((void *) &cmd[1], 0, 9); 2281 + the_result = scsi_execute_cmd(sdkp->device, cmd, REQ_OP_DRV_IN, 2282 + NULL, 0, SD_TIMEOUT, 2283 + sdkp->max_retries, &exec_args); 2287 2284 2288 - the_result = scsi_execute_cmd(sdkp->device, cmd, 2289 - REQ_OP_DRV_IN, NULL, 0, 2290 - SD_TIMEOUT, 2291 - sdkp->max_retries, 2292 - &exec_args); 2293 2285 2294 - if (the_result > 0) { 2295 - /* 2296 - * If the drive has indicated to us that it 2297 - * doesn't have any media in it, don't bother 2298 - * with any more polling. 2299 - */ 2300 - if (media_not_present(sdkp, &sshdr)) { 2301 - if (media_was_present) 2302 - sd_printk(KERN_NOTICE, sdkp, 2303 - "Media removed, stopped polling\n"); 2304 - return; 2305 - } 2306 - 2307 - sense_valid = scsi_sense_valid(&sshdr); 2286 + if (the_result > 0) { 2287 + /* 2288 + * If the drive has indicated to us that it doesn't 2289 + * have any media in it, don't bother with any more 2290 + * polling. 2291 + */ 2292 + if (media_not_present(sdkp, &sshdr)) { 2293 + if (media_was_present) 2294 + sd_printk(KERN_NOTICE, sdkp, 2295 + "Media removed, stopped polling\n"); 2296 + return; 2308 2297 } 2309 - retries++; 2310 - } while (retries < 3 && 2311 - (!scsi_status_is_good(the_result) || 2312 - (scsi_status_is_check_condition(the_result) && 2313 - sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 2298 + sense_valid = scsi_sense_valid(&sshdr); 2299 + } 2314 2300 2315 2301 if (!scsi_status_is_check_condition(the_result)) { 2316 2302 /* no sense, TUR either succeeded or failed ··· 2358 2318 * Issue command to spin up drive when not ready 2359 2319 */ 2360 2320 if (!spintime) { 2321 + /* Return immediately and start spin cycle */ 2322 + const u8 start_cmd[10] = { 2323 + [0] = START_STOP, 2324 + [1] = 1, 2325 + [4] = sdkp->device->start_stop_pwr_cond ? 2326 + 0x11 : 1, 2327 + }; 2328 + 2361 2329 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); 2362 - cmd[0] = START_STOP; 2363 - cmd[1] = 1; /* Return immediately */ 2364 - memset((void *) &cmd[2], 0, 8); 2365 - cmd[4] = 1; /* Start spin cycle */ 2366 - if (sdkp->device->start_stop_pwr_cond) 2367 - cmd[4] |= 1 << 4; 2368 - scsi_execute_cmd(sdkp->device, cmd, 2330 + scsi_execute_cmd(sdkp->device, start_cmd, 2369 2331 REQ_OP_DRV_IN, NULL, 0, 2370 2332 SD_TIMEOUT, sdkp->max_retries, 2371 2333 &exec_args); ··· 2588 2546 static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, 2589 2547 unsigned char *buffer) 2590 2548 { 2591 - unsigned char cmd[16]; 2549 + static const u8 cmd[10] = { READ_CAPACITY }; 2592 2550 struct scsi_sense_hdr sshdr; 2551 + struct scsi_failure failure_defs[] = { 2552 + /* Do not retry Medium Not Present */ 2553 + { 2554 + .sense = UNIT_ATTENTION, 2555 + .asc = 0x3A, 2556 + .result = SAM_STAT_CHECK_CONDITION, 2557 + }, 2558 + { 2559 + .sense = NOT_READY, 2560 + .asc = 0x3A, 2561 + .result = SAM_STAT_CHECK_CONDITION, 2562 + }, 2563 + /* Device reset might occur several times so retry a lot */ 2564 + { 2565 + .sense = UNIT_ATTENTION, 2566 + .asc = 0x29, 2567 + .allowed = READ_CAPACITY_RETRIES_ON_RESET, 2568 + .result = SAM_STAT_CHECK_CONDITION, 2569 + }, 2570 + /* Any other error not listed above retry 3 times */ 2571 + { 2572 + .result = SCMD_FAILURE_RESULT_ANY, 2573 + .allowed = 3, 2574 + }, 2575 + {} 2576 + }; 2577 + struct scsi_failures failures = { 2578 + .failure_definitions = failure_defs, 2579 + }; 2593 2580 const struct scsi_exec_args exec_args = { 2594 2581 .sshdr = &sshdr, 2582 + .failures = &failures, 2595 2583 }; 2596 2584 int sense_valid = 0; 2597 2585 int the_result; 2598 - int retries = 3, reset_retries = READ_CAPACITY_RETRIES_ON_RESET; 2599 2586 sector_t lba; 2600 2587 unsigned sector_size; 2601 2588 2602 - do { 2603 - cmd[0] = READ_CAPACITY; 2604 - memset(&cmd[1], 0, 9); 2605 - memset(buffer, 0, 8); 2589 + memset(buffer, 0, 8); 2606 2590 2607 - the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, 2608 - 8, SD_TIMEOUT, sdkp->max_retries, 2609 - &exec_args); 2591 + the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, 2592 + 8, SD_TIMEOUT, sdkp->max_retries, 2593 + &exec_args); 2594 + 2595 + if (the_result > 0) { 2596 + sense_valid = scsi_sense_valid(&sshdr); 2610 2597 2611 2598 if (media_not_present(sdkp, &sshdr)) 2612 2599 return -ENODEV; 2613 - 2614 - if (the_result > 0) { 2615 - sense_valid = scsi_sense_valid(&sshdr); 2616 - if (sense_valid && 2617 - sshdr.sense_key == UNIT_ATTENTION && 2618 - sshdr.asc == 0x29 && sshdr.ascq == 0x00) 2619 - /* Device reset might occur several times, 2620 - * give it one more chance */ 2621 - if (--reset_retries > 0) 2622 - continue; 2623 - } 2624 - retries--; 2625 - 2626 - } while (the_result && retries); 2600 + } 2627 2601 2628 2602 if (the_result) { 2629 2603 sd_print_result(sdkp, "Read Capacity(10) failed", the_result); ··· 3810 3752 blk_pm_runtime_init(sdp->request_queue, dev); 3811 3753 if (sdp->rpm_autosuspend) { 3812 3754 pm_runtime_set_autosuspend_delay(dev, 3813 - sdp->host->hostt->rpm_autosuspend_delay); 3755 + sdp->host->rpm_autosuspend_delay); 3814 3756 } 3815 3757 3816 3758 error = device_add_disk(dev, gd, NULL);
+46 -20
drivers/scsi/ses.c
··· 87 87 0 88 88 }; 89 89 unsigned char recv_page_code; 90 - unsigned int retries = SES_RETRIES; 91 - struct scsi_sense_hdr sshdr; 90 + struct scsi_failure failure_defs[] = { 91 + { 92 + .sense = UNIT_ATTENTION, 93 + .asc = 0x29, 94 + .ascq = SCMD_FAILURE_ASCQ_ANY, 95 + .allowed = SES_RETRIES, 96 + .result = SAM_STAT_CHECK_CONDITION, 97 + }, 98 + { 99 + .sense = NOT_READY, 100 + .asc = SCMD_FAILURE_ASC_ANY, 101 + .ascq = SCMD_FAILURE_ASCQ_ANY, 102 + .allowed = SES_RETRIES, 103 + .result = SAM_STAT_CHECK_CONDITION, 104 + }, 105 + {} 106 + }; 107 + struct scsi_failures failures = { 108 + .failure_definitions = failure_defs, 109 + }; 92 110 const struct scsi_exec_args exec_args = { 93 - .sshdr = &sshdr, 111 + .failures = &failures, 94 112 }; 95 113 96 - do { 97 - ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen, 98 - SES_TIMEOUT, 1, &exec_args); 99 - } while (ret > 0 && --retries && scsi_sense_valid(&sshdr) && 100 - (sshdr.sense_key == NOT_READY || 101 - (sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29))); 102 - 114 + ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen, 115 + SES_TIMEOUT, 1, &exec_args); 103 116 if (unlikely(ret)) 104 117 return ret; 105 118 ··· 144 131 bufflen & 0xff, 145 132 0 146 133 }; 147 - struct scsi_sense_hdr sshdr; 148 - unsigned int retries = SES_RETRIES; 134 + struct scsi_failure failure_defs[] = { 135 + { 136 + .sense = UNIT_ATTENTION, 137 + .asc = 0x29, 138 + .ascq = SCMD_FAILURE_ASCQ_ANY, 139 + .allowed = SES_RETRIES, 140 + .result = SAM_STAT_CHECK_CONDITION, 141 + }, 142 + { 143 + .sense = NOT_READY, 144 + .asc = SCMD_FAILURE_ASC_ANY, 145 + .ascq = SCMD_FAILURE_ASCQ_ANY, 146 + .allowed = SES_RETRIES, 147 + .result = SAM_STAT_CHECK_CONDITION, 148 + }, 149 + {} 150 + }; 151 + struct scsi_failures failures = { 152 + .failure_definitions = failure_defs, 153 + }; 149 154 const struct scsi_exec_args exec_args = { 150 - .sshdr = &sshdr, 155 + .failures = &failures, 151 156 }; 152 157 153 - do { 154 - result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf, 155 - bufflen, SES_TIMEOUT, 1, &exec_args); 156 - } while (result > 0 && --retries && scsi_sense_valid(&sshdr) && 157 - (sshdr.sense_key == NOT_READY || 158 - (sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29))); 159 - 158 + result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf, bufflen, 159 + SES_TIMEOUT, 1, &exec_args); 160 160 if (result) 161 161 sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n", 162 162 result);
+20 -18
drivers/scsi/sr.c
··· 717 717 718 718 static void get_sectorsize(struct scsi_cd *cd) 719 719 { 720 - unsigned char cmd[10]; 721 - unsigned char buffer[8]; 722 - int the_result, retries = 3; 720 + static const u8 cmd[10] = { READ_CAPACITY }; 721 + unsigned char buffer[8] = { }; 722 + int the_result; 723 723 int sector_size; 724 724 struct request_queue *queue; 725 + struct scsi_failure failure_defs[] = { 726 + { 727 + .result = SCMD_FAILURE_RESULT_ANY, 728 + .allowed = 3, 729 + }, 730 + {} 731 + }; 732 + struct scsi_failures failures = { 733 + .failure_definitions = failure_defs, 734 + }; 735 + const struct scsi_exec_args exec_args = { 736 + .failures = &failures, 737 + }; 725 738 726 - do { 727 - cmd[0] = READ_CAPACITY; 728 - memset((void *) &cmd[1], 0, 9); 729 - memset(buffer, 0, sizeof(buffer)); 730 - 731 - /* Do the command and wait.. */ 732 - the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, 733 - buffer, sizeof(buffer), 734 - SR_TIMEOUT, MAX_RETRIES, NULL); 735 - 736 - retries--; 737 - 738 - } while (the_result && retries); 739 - 740 - 739 + /* Do the command and wait.. */ 740 + the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer, 741 + sizeof(buffer), SR_TIMEOUT, MAX_RETRIES, 742 + &exec_args); 741 743 if (the_result) { 742 744 cd->capacity = 0x1fffff; 743 745 sector_size = 2048; /* A guess, just in case */
+1 -1
drivers/target/loopback/tcm_loop.c
··· 83 83 static int tcm_loop_driver_probe(struct device *); 84 84 static void tcm_loop_driver_remove(struct device *); 85 85 86 - static struct bus_type tcm_loop_lld_bus = { 86 + static const struct bus_type tcm_loop_lld_bus = { 87 87 .name = "tcm_loop_bus", 88 88 .probe = tcm_loop_driver_probe, 89 89 .remove = tcm_loop_driver_remove,
+8 -4
drivers/ufs/core/ufs-mcq.c
··· 258 258 * Current MCQ specification doesn't provide a Task Tag or its equivalent in 259 259 * the Completion Queue Entry. Find the Task Tag using an indirect method. 260 260 */ 261 - static int ufshcd_mcq_get_tag(struct ufs_hba *hba, 262 - struct ufs_hw_queue *hwq, 263 - struct cq_entry *cqe) 261 + static int ufshcd_mcq_get_tag(struct ufs_hba *hba, struct cq_entry *cqe) 264 262 { 265 263 u64 addr; 266 264 ··· 276 278 struct ufs_hw_queue *hwq) 277 279 { 278 280 struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq); 279 - int tag = ufshcd_mcq_get_tag(hba, hwq, cqe); 281 + int tag = ufshcd_mcq_get_tag(hba, cqe); 280 282 281 283 if (cqe->command_desc_base_addr) { 282 284 ufshcd_compl_one_cqe(hba, tag, cqe); ··· 396 398 REG_UFS_MEM_CFG); 397 399 } 398 400 EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi); 401 + 402 + void ufshcd_mcq_enable(struct ufs_hba *hba) 403 + { 404 + ufshcd_rmwl(hba, MCQ_MODE_SELECT, MCQ_MODE_SELECT, REG_UFS_MEM_CFG); 405 + } 406 + EXPORT_SYMBOL_GPL(ufshcd_mcq_enable); 399 407 400 408 void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg) 401 409 {
+49
drivers/ufs/core/ufs-sysfs.c
··· 405 405 return count; 406 406 } 407 407 408 + /** 409 + * pm_qos_enable_show - sysfs handler to show pm qos enable value 410 + * @dev: device associated with the UFS controller 411 + * @attr: sysfs attribute handle 412 + * @buf: buffer for sysfs file 413 + * 414 + * Print 1 if PM QoS feature is enabled, 0 if disabled. 415 + * 416 + * Returns number of characters written to @buf. 417 + */ 418 + static ssize_t pm_qos_enable_show(struct device *dev, 419 + struct device_attribute *attr, char *buf) 420 + { 421 + struct ufs_hba *hba = dev_get_drvdata(dev); 422 + 423 + return sysfs_emit(buf, "%d\n", hba->pm_qos_enabled); 424 + } 425 + 426 + /** 427 + * pm_qos_enable_store - sysfs handler to store value 428 + * @dev: device associated with the UFS controller 429 + * @attr: sysfs attribute handle 430 + * @buf: buffer for sysfs file 431 + * @count: stores buffer characters count 432 + * 433 + * Input 0 to disable PM QoS and 1 value to enable. 434 + * Default state: 1 435 + * 436 + * Return: number of characters written to @buf on success, < 0 upon failure. 437 + */ 438 + static ssize_t pm_qos_enable_store(struct device *dev, 439 + struct device_attribute *attr, const char *buf, size_t count) 440 + { 441 + struct ufs_hba *hba = dev_get_drvdata(dev); 442 + bool value; 443 + 444 + if (kstrtobool(buf, &value)) 445 + return -EINVAL; 446 + 447 + if (value) 448 + ufshcd_pm_qos_init(hba); 449 + else 450 + ufshcd_pm_qos_exit(hba); 451 + 452 + return count; 453 + } 454 + 408 455 static DEVICE_ATTR_RW(rpm_lvl); 409 456 static DEVICE_ATTR_RO(rpm_target_dev_state); 410 457 static DEVICE_ATTR_RO(rpm_target_link_state); ··· 463 416 static DEVICE_ATTR_RW(enable_wb_buf_flush); 464 417 static DEVICE_ATTR_RW(wb_flush_threshold); 465 418 static DEVICE_ATTR_RW(rtc_update_ms); 419 + static DEVICE_ATTR_RW(pm_qos_enable); 466 420 467 421 static struct attribute *ufs_sysfs_ufshcd_attrs[] = { 468 422 &dev_attr_rpm_lvl.attr, ··· 477 429 &dev_attr_enable_wb_buf_flush.attr, 478 430 &dev_attr_wb_flush_threshold.attr, 479 431 &dev_attr_rtc_update_ms.attr, 432 + &dev_attr_pm_qos_enable.attr, 480 433 NULL 481 434 }; 482 435
+71 -19
drivers/ufs/core/ufshcd.c
··· 1015 1015 } 1016 1016 1017 1017 /** 1018 + * ufshcd_pm_qos_init - initialize PM QoS request 1019 + * @hba: per adapter instance 1020 + */ 1021 + void ufshcd_pm_qos_init(struct ufs_hba *hba) 1022 + { 1023 + 1024 + if (hba->pm_qos_enabled) 1025 + return; 1026 + 1027 + cpu_latency_qos_add_request(&hba->pm_qos_req, PM_QOS_DEFAULT_VALUE); 1028 + 1029 + if (cpu_latency_qos_request_active(&hba->pm_qos_req)) 1030 + hba->pm_qos_enabled = true; 1031 + } 1032 + 1033 + /** 1034 + * ufshcd_pm_qos_exit - remove request from PM QoS 1035 + * @hba: per adapter instance 1036 + */ 1037 + void ufshcd_pm_qos_exit(struct ufs_hba *hba) 1038 + { 1039 + if (!hba->pm_qos_enabled) 1040 + return; 1041 + 1042 + cpu_latency_qos_remove_request(&hba->pm_qos_req); 1043 + hba->pm_qos_enabled = false; 1044 + } 1045 + 1046 + /** 1047 + * ufshcd_pm_qos_update - update PM QoS request 1048 + * @hba: per adapter instance 1049 + * @on: If True, vote for perf PM QoS mode otherwise power save mode 1050 + */ 1051 + static void ufshcd_pm_qos_update(struct ufs_hba *hba, bool on) 1052 + { 1053 + if (!hba->pm_qos_enabled) 1054 + return; 1055 + 1056 + cpu_latency_qos_update_request(&hba->pm_qos_req, on ? 0 : PM_QOS_DEFAULT_VALUE); 1057 + } 1058 + 1059 + /** 1018 1060 * ufshcd_set_clk_freq - set UFS controller clock frequencies 1019 1061 * @hba: per adapter instance 1020 1062 * @scale_up: If True, set max possible frequency othewise set low frequency ··· 1202 1160 hba->devfreq->previous_freq); 1203 1161 else 1204 1162 ufshcd_set_clk_freq(hba, !scale_up); 1163 + goto out; 1205 1164 } 1165 + 1166 + ufshcd_pm_qos_update(hba, scale_up); 1206 1167 1207 1168 out: 1208 1169 trace_ufshcd_profile_clk_scaling(dev_name(hba->dev), ··· 5647 5602 struct ufshcd_lrb *lrbp; 5648 5603 struct scsi_cmnd *cmd; 5649 5604 unsigned long flags; 5650 - u32 hwq_num, utag; 5651 5605 int tag; 5652 5606 5653 5607 for (tag = 0; tag < hba->nutrs; tag++) { ··· 5656 5612 test_bit(SCMD_STATE_COMPLETE, &cmd->state)) 5657 5613 continue; 5658 5614 5659 - utag = blk_mq_unique_tag(scsi_cmd_to_rq(cmd)); 5660 - hwq_num = blk_mq_unique_tag_to_hwq(utag); 5661 - hwq = &hba->uhq[hwq_num]; 5615 + hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); 5662 5616 5663 5617 if (force_compl) { 5664 5618 ufshcd_mcq_compl_all_cqes_lock(hba, hwq); ··· 8029 7987 8030 7988 static inline void ufshcd_blk_pm_runtime_init(struct scsi_device *sdev) 8031 7989 { 7990 + struct Scsi_Host *shost = sdev->host; 7991 + 8032 7992 scsi_autopm_get_device(sdev); 8033 7993 blk_pm_runtime_init(sdev->request_queue, &sdev->sdev_gendev); 8034 7994 if (sdev->rpm_autosuspend) 8035 7995 pm_runtime_set_autosuspend_delay(&sdev->sdev_gendev, 8036 - RPM_AUTOSUSPEND_DELAY_MS); 7996 + shost->rpm_autosuspend_delay); 8037 7997 scsi_autopm_put_device(sdev); 8038 7998 } 8039 7999 ··· 8845 8801 hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; 8846 8802 hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED; 8847 8803 8848 - /* Select MCQ mode */ 8849 - ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x1, 8850 - REG_UFS_MEM_CFG); 8804 + ufshcd_mcq_enable(hba); 8851 8805 hba->mcq_enabled = true; 8852 8806 8853 8807 dev_info(hba->dev, "MCQ configured, nr_queues=%d, io_queues=%d, read_queue=%d, poll_queues=%d, queue_depth=%d\n", ··· 9107 9065 .track_queue_depth = 1, 9108 9066 .skip_settle_delay = 1, 9109 9067 .sdev_groups = ufshcd_driver_groups, 9110 - .rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS, 9111 9068 }; 9112 9069 9113 9070 static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, ··· 9321 9280 if (ret) 9322 9281 return ret; 9323 9282 9283 + if (!ufshcd_is_clkscaling_supported(hba)) 9284 + ufshcd_pm_qos_update(hba, on); 9324 9285 out: 9325 9286 if (ret) { 9326 9287 list_for_each_entry(clki, head, list) { ··· 9500 9457 static void ufshcd_hba_exit(struct ufs_hba *hba) 9501 9458 { 9502 9459 if (hba->is_powered) { 9460 + ufshcd_pm_qos_exit(hba); 9503 9461 ufshcd_exit_clk_scaling(hba); 9504 9462 ufshcd_exit_clk_gating(hba); 9505 9463 if (hba->eh_wq) ··· 9520 9476 struct scsi_sense_hdr *sshdr) 9521 9477 { 9522 9478 const unsigned char cdb[6] = { START_STOP, 0, 0, 0, pwr_mode << 4, 0 }; 9479 + struct scsi_failure failure_defs[] = { 9480 + { 9481 + .allowed = 2, 9482 + .result = SCMD_FAILURE_RESULT_ANY, 9483 + }, 9484 + }; 9485 + struct scsi_failures failures = { 9486 + .failure_definitions = failure_defs, 9487 + }; 9523 9488 const struct scsi_exec_args args = { 9489 + .failures = &failures, 9524 9490 .sshdr = sshdr, 9525 9491 .req_flags = BLK_MQ_REQ_PM, 9526 9492 .scmd_flags = SCMD_FAIL_IF_RECOVERING, ··· 9556 9502 struct scsi_sense_hdr sshdr; 9557 9503 struct scsi_device *sdp; 9558 9504 unsigned long flags; 9559 - int ret, retries; 9505 + int ret; 9560 9506 9561 9507 spin_lock_irqsave(hba->host->host_lock, flags); 9562 9508 sdp = hba->ufs_device_wlun; ··· 9582 9528 * callbacks hence set the RQF_PM flag so that it doesn't resume the 9583 9529 * already suspended childs. 9584 9530 */ 9585 - for (retries = 3; retries > 0; --retries) { 9586 - ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); 9587 - /* 9588 - * scsi_execute() only returns a negative value if the request 9589 - * queue is dying. 9590 - */ 9591 - if (ret <= 0) 9592 - break; 9593 - } 9531 + ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); 9594 9532 if (ret) { 9595 9533 sdev_printk(KERN_WARNING, sdp, 9596 9534 "START_STOP failed for power mode: %d, result %x\n", ··· 10155 10109 ufshcd_vreg_set_lpm(hba); 10156 10110 /* Put the host controller in low power mode if possible */ 10157 10111 ufshcd_hba_vreg_set_lpm(hba); 10112 + ufshcd_pm_qos_update(hba, false); 10158 10113 return ret; 10159 10114 } 10160 10115 ··· 10567 10520 host->max_cmd_len = UFS_CDB_SIZE; 10568 10521 host->queuecommand_may_block = !!(hba->caps & UFSHCD_CAP_CLK_GATING); 10569 10522 10523 + /* Use default RPM delay if host not set */ 10524 + if (host->rpm_autosuspend_delay == 0) 10525 + host->rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS; 10526 + 10570 10527 hba->max_pwr_info.is_valid = false; 10571 10528 10572 10529 /* Initialize work queues */ ··· 10706 10655 ufs_sysfs_add_nodes(hba->dev); 10707 10656 10708 10657 device_enable_async_suspend(dev); 10658 + ufshcd_pm_qos_init(hba); 10709 10659 return 0; 10710 10660 10711 10661 free_tmf_queue:
+61 -29
drivers/ufs/host/ufs-mediatek.c
··· 17 17 #include <linux/of_platform.h> 18 18 #include <linux/phy/phy.h> 19 19 #include <linux/platform_device.h> 20 - #include <linux/pm_qos.h> 21 20 #include <linux/regulator/consumer.h> 22 21 #include <linux/reset.h> 23 22 #include <linux/soc/mediatek/mtk_sip_svc.h> ··· 625 626 dev_info(hba->dev, "caps: 0x%x", host->caps); 626 627 } 627 628 628 - static void ufs_mtk_boost_pm_qos(struct ufs_hba *hba, bool boost) 629 - { 630 - struct ufs_mtk_host *host = ufshcd_get_variant(hba); 631 - 632 - if (!host || !host->pm_qos_init) 633 - return; 634 - 635 - cpu_latency_qos_update_request(&host->pm_qos_req, 636 - boost ? 0 : PM_QOS_DEFAULT_VALUE); 637 - } 638 - 639 629 static void ufs_mtk_scale_perf(struct ufs_hba *hba, bool scale_up) 640 630 { 641 631 ufs_mtk_boost_crypt(hba, scale_up); 642 - ufs_mtk_boost_pm_qos(hba, scale_up); 643 632 } 644 633 645 634 static void ufs_mtk_pwr_ctrl(struct ufs_hba *hba, bool on) ··· 645 658 ufs_mtk_setup_ref_clk(hba, on); 646 659 phy_power_off(host->mphy); 647 660 } 661 + } 662 + 663 + static void ufs_mtk_mcq_disable_irq(struct ufs_hba *hba) 664 + { 665 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 666 + u32 irq, i; 667 + 668 + if (!is_mcq_enabled(hba)) 669 + return; 670 + 671 + if (host->mcq_nr_intr == 0) 672 + return; 673 + 674 + for (i = 0; i < host->mcq_nr_intr; i++) { 675 + irq = host->mcq_intr_info[i].irq; 676 + disable_irq(irq); 677 + } 678 + host->is_mcq_intr_enabled = false; 679 + } 680 + 681 + static void ufs_mtk_mcq_enable_irq(struct ufs_hba *hba) 682 + { 683 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 684 + u32 irq, i; 685 + 686 + if (!is_mcq_enabled(hba)) 687 + return; 688 + 689 + if (host->mcq_nr_intr == 0) 690 + return; 691 + 692 + if (host->is_mcq_intr_enabled == true) 693 + return; 694 + 695 + for (i = 0; i < host->mcq_nr_intr; i++) { 696 + irq = host->mcq_intr_info[i].irq; 697 + enable_irq(irq); 698 + } 699 + host->is_mcq_intr_enabled = true; 648 700 } 649 701 650 702 /** ··· 729 703 730 704 if (clk_pwr_off) 731 705 ufs_mtk_pwr_ctrl(hba, false); 706 + ufs_mtk_mcq_disable_irq(hba); 732 707 } else if (on && status == POST_CHANGE) { 733 708 ufs_mtk_pwr_ctrl(hba, true); 709 + ufs_mtk_mcq_enable_irq(hba); 734 710 } 735 711 736 712 return ret; ··· 921 893 const struct of_device_id *id; 922 894 struct device *dev = hba->dev; 923 895 struct ufs_mtk_host *host; 896 + struct Scsi_Host *shost = hba->host; 924 897 int err = 0; 925 898 926 899 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); ··· 966 937 /* Enable clk scaling*/ 967 938 hba->caps |= UFSHCD_CAP_CLK_SCALING; 968 939 940 + /* Set runtime pm delay to replace default */ 941 + shost->rpm_autosuspend_delay = MTK_RPM_AUTOSUSPEND_DELAY_MS; 942 + 969 943 hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL; 970 944 hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR; 971 945 hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC; ··· 990 958 ufs_mtk_setup_clocks(hba, true, POST_CHANGE); 991 959 992 960 host->ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER); 993 - 994 - /* Initialize pm-qos request */ 995 - cpu_latency_qos_add_request(&host->pm_qos_req, PM_QOS_DEFAULT_VALUE); 996 - host->pm_qos_init = true; 997 961 998 962 goto out; 999 963 ··· 1234 1206 return err; 1235 1207 1236 1208 err = ufshcd_uic_hibern8_exit(hba); 1237 - if (!err) 1238 - ufshcd_set_link_active(hba); 1239 - else 1209 + if (err) 1240 1210 return err; 1241 1211 1242 - if (!hba->mcq_enabled) { 1243 - err = ufshcd_make_hba_operational(hba); 1244 - } else { 1212 + /* Check link state to make sure exit h8 success */ 1213 + ufs_mtk_wait_idle_state(hba, 5); 1214 + err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100); 1215 + if (err) { 1216 + dev_warn(hba->dev, "exit h8 state fail, err=%d\n", err); 1217 + return err; 1218 + } 1219 + ufshcd_set_link_active(hba); 1220 + 1221 + err = ufshcd_make_hba_operational(hba); 1222 + if (err) 1223 + return err; 1224 + 1225 + if (is_mcq_enabled(hba)) { 1245 1226 ufs_mtk_config_mcq(hba, false); 1246 1227 ufshcd_mcq_make_queues_operational(hba); 1247 1228 ufshcd_mcq_config_mac(hba, hba->nutrs); 1248 - /* Enable MCQ mode */ 1249 - ufshcd_writel(hba, ufshcd_readl(hba, REG_UFS_MEM_CFG) | 0x1, 1250 - REG_UFS_MEM_CFG); 1229 + ufshcd_mcq_enable(hba); 1251 1230 } 1252 - 1253 - if (err) 1254 - return err; 1255 1231 1256 1232 return 0; 1257 1233 }
+4 -3
drivers/ufs/host/ufs-mediatek.h
··· 7 7 #define _UFS_MEDIATEK_H 8 8 9 9 #include <linux/bitops.h> 10 - #include <linux/pm_qos.h> 11 10 #include <linux/soc/mediatek/mtk_sip_svc.h> 12 11 13 12 /* ··· 166 167 167 168 struct ufs_mtk_host { 168 169 struct phy *mphy; 169 - struct pm_qos_request pm_qos_req; 170 170 struct regulator *reg_va09; 171 171 struct reset_control *hci_reset; 172 172 struct reset_control *unipro_reset; ··· 176 178 struct ufs_mtk_hw_ver hw_ver; 177 179 enum ufs_mtk_host_caps caps; 178 180 bool mphy_powered_on; 179 - bool pm_qos_init; 180 181 bool unipro_lpm; 181 182 bool ref_clk_enabled; 182 183 u16 ref_clk_ungating_wait_us; ··· 183 186 u32 ip_ver; 184 187 185 188 bool mcq_set_intr; 189 + bool is_mcq_intr_enabled; 186 190 int mcq_nr_intr; 187 191 struct ufs_mtk_mcq_intr_info mcq_intr_info[UFSHCD_MAX_Q_NR]; 188 192 }; 193 + 194 + /* MTK delay of autosuspend: 500 ms */ 195 + #define MTK_RPM_AUTOSUSPEND_DELAY_MS 500 189 196 190 197 /* 191 198 * Multi-VCC by Numbering
+21 -7
drivers/ufs/host/ufs-qcom.c
··· 738 738 * the second init can program the optimal PHY settings. This allows one to start 739 739 * the first init with either the minimum or the maximum support gear. 740 740 */ 741 - if (hba->ufshcd_state == UFSHCD_STATE_RESET) 742 - host->phy_gear = dev_req_params->gear_tx; 741 + if (hba->ufshcd_state == UFSHCD_STATE_RESET) { 742 + /* 743 + * Skip REINIT if the negotiated gear matches with the 744 + * initial phy_gear. Otherwise, update the phy_gear to 745 + * program the optimal gear setting during REINIT. 746 + */ 747 + if (host->phy_gear == dev_req_params->gear_tx) 748 + hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; 749 + else 750 + host->phy_gear = dev_req_params->gear_tx; 751 + } 743 752 744 753 /* enable the device ref clock before changing to HS mode */ 745 754 if (!ufshcd_is_hs_mode(&hba->pwr_info) && ··· 852 843 struct ufs_host_params *host_params = &host->host_params; 853 844 u32 val, dev_major; 854 845 846 + /* 847 + * Default to powering up the PHY to the max gear possible, which is 848 + * backwards compatible with lower gears but not optimal from 849 + * a power usage point of view. After device negotiation, if the 850 + * gear is lower a reinit will be performed to program the PHY 851 + * to the ideal gear for this combo of controller and device. 852 + */ 855 853 host->phy_gear = host_params->hs_tx_gear; 856 854 857 855 if (host->hw_ver.major < 0x4) { 858 856 /* 859 - * For controllers whose major HW version is < 4, power up the 860 - * PHY using minimum supported gear (UFS_HS_G2). Switching to 861 - * max gear will be performed during reinit if supported. 862 - * For newer controllers, whose major HW version is >= 4, power 863 - * up the PHY using max supported gear. 857 + * These controllers only have one PHY init sequence, 858 + * let's power up the PHY using that (the minimum supported 859 + * gear, UFS_HS_G2). 864 860 */ 865 861 host->phy_gear = UFS_HS_G2; 866 862 } else if (host->hw_ver.major >= 0x5) {
+48
include/scsi/scsi_device.h
··· 486 486 extern int scsi_is_target_device(const struct device *); 487 487 extern void scsi_sanitize_inquiry_string(unsigned char *s, int len); 488 488 489 + /* 490 + * scsi_execute_cmd users can set scsi_failure.result to have 491 + * scsi_check_passthrough fail/retry a command. scsi_failure.result can be a 492 + * specific host byte or message code, or SCMD_FAILURE_RESULT_ANY can be used 493 + * to match any host or message code. 494 + */ 495 + #define SCMD_FAILURE_RESULT_ANY 0x7fffffff 496 + /* 497 + * Set scsi_failure.result to SCMD_FAILURE_STAT_ANY to fail/retry any failure 498 + * scsi_status_is_good returns false for. 499 + */ 500 + #define SCMD_FAILURE_STAT_ANY 0xff 501 + /* 502 + * The following can be set to the scsi_failure sense, asc and ascq fields to 503 + * match on any sense, ASC, or ASCQ value. 504 + */ 505 + #define SCMD_FAILURE_SENSE_ANY 0xff 506 + #define SCMD_FAILURE_ASC_ANY 0xff 507 + #define SCMD_FAILURE_ASCQ_ANY 0xff 508 + /* Always retry a matching failure. */ 509 + #define SCMD_FAILURE_NO_LIMIT -1 510 + 511 + struct scsi_failure { 512 + int result; 513 + u8 sense; 514 + u8 asc; 515 + u8 ascq; 516 + /* 517 + * Number of times scsi_execute_cmd will retry the failure. It does 518 + * not count for the total_allowed. 519 + */ 520 + s8 allowed; 521 + /* Number of times the failure has been retried. */ 522 + s8 retries; 523 + }; 524 + 525 + struct scsi_failures { 526 + /* 527 + * If a scsi_failure does not have a retry limit setup this limit will 528 + * be used. 529 + */ 530 + int total_allowed; 531 + int total_retries; 532 + struct scsi_failure *failure_definitions; 533 + }; 534 + 489 535 /* Optional arguments to scsi_execute_cmd */ 490 536 struct scsi_exec_args { 491 537 unsigned char *sense; /* sense buffer */ ··· 540 494 blk_mq_req_flags_t req_flags; /* BLK_MQ_REQ flags */ 541 495 int scmd_flags; /* SCMD flags */ 542 496 int *resid; /* residual length */ 497 + struct scsi_failures *failures; /* failures to retry */ 543 498 }; 544 499 545 500 int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd, 546 501 blk_opf_t opf, void *buffer, unsigned int bufflen, 547 502 int timeout, int retries, 548 503 const struct scsi_exec_args *args); 504 + void scsi_failures_reset_retries(struct scsi_failures *failures); 549 505 550 506 extern void sdev_disable_disk_events(struct scsi_device *sdev); 551 507 extern void sdev_enable_disk_events(struct scsi_device *sdev);
+3 -3
include/scsi/scsi_host.h
··· 497 497 * scsi_netlink.h 498 498 */ 499 499 u64 vendor_id; 500 - 501 - /* Delay for runtime autosuspend */ 502 - int rpm_autosuspend_delay; 503 500 }; 504 501 505 502 /* ··· 709 712 * Needed just in case we have virtual hosts. 710 713 */ 711 714 struct device *dma_dev; 715 + 716 + /* Delay for runtime autosuspend */ 717 + int rpm_autosuspend_delay; 712 718 713 719 /* 714 720 * We should ensure that this is aligned, both for better performance
+7
include/ufs/ufshcd.h
··· 914 914 * @dev_cmd_queue: Queue for issuing device management commands 915 915 * @mcq_opr: MCQ operation and runtime registers 916 916 * @ufs_rtc_update_work: A work for UFS RTC periodic update 917 + * @pm_qos_req: PM QoS request handle 918 + * @pm_qos_enabled: flag to check if pm qos is enabled 917 919 */ 918 920 struct ufs_hba { 919 921 void __iomem *mmio_base; ··· 1082 1080 struct ufshcd_mcq_opr_info_t mcq_opr[OPR_MAX]; 1083 1081 1084 1082 struct delayed_work ufs_rtc_update_work; 1083 + struct pm_qos_request pm_qos_req; 1084 + bool pm_qos_enabled; 1085 1085 }; 1086 1086 1087 1087 /** ··· 1267 1263 struct ufs_hw_queue *hwq); 1268 1264 void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba); 1269 1265 void ufshcd_mcq_enable_esi(struct ufs_hba *hba); 1266 + void ufshcd_mcq_enable(struct ufs_hba *hba); 1270 1267 void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg); 1271 1268 1272 1269 int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table, ··· 1405 1400 int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm); 1406 1401 void ufshcd_resume_complete(struct device *dev); 1407 1402 bool ufshcd_is_hba_active(struct ufs_hba *hba); 1403 + void ufshcd_pm_qos_init(struct ufs_hba *hba); 1404 + void ufshcd_pm_qos_exit(struct ufs_hba *hba); 1408 1405 1409 1406 /* Wrapper functions for safely calling variant operations */ 1410 1407 static inline int ufshcd_vops_init(struct ufs_hba *hba)
+3
include/ufs/ufshci.h
··· 282 282 /* UTMRLRSR - UTP Task Management Request Run-Stop Register 80h */ 283 283 #define UTP_TASK_REQ_LIST_RUN_STOP_BIT 0x1 284 284 285 + /* REG_UFS_MEM_CFG - Global Config Registers 300h */ 286 + #define MCQ_MODE_SELECT BIT(0) 287 + 285 288 /* CQISy - CQ y Interrupt Status Register */ 286 289 #define UFSHCD_MCQ_CQIS_TAIL_ENT_PUSH_STS 0x1 287 290