···626626{627627 int cnt = 0;628628629629- blk_mq_tagset_busy_iter(&shost->tag_set,630630- scsi_host_check_in_flight, &cnt);629629+ if (shost->tag_set.ops)630630+ blk_mq_tagset_busy_iter(&shost->tag_set,631631+ scsi_host_check_in_flight, &cnt);631632 return cnt;632633}633634EXPORT_SYMBOL(scsi_host_busy);
+1-1
drivers/scsi/libfc/fc_fcp.c
···503503 host_bcode = FC_ERROR;504504 goto err;505505 }506506- if (offset + len > fsp->data_len) {506506+ if (size_add(offset, len) > fsp->data_len) {507507 /* this should never happen */508508 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) &&509509 fc_frame_crc_check(fp))
+4-4
drivers/scsi/qla4xxx/ql4_os.c
···41044104 * The mid-level driver tries to ensure that queuecommand never gets41054105 * invoked concurrently with itself or the interrupt handler (although41064106 * the interrupt handler may call this routine as part of request-41074107- * completion handling). Unfortunely, it sometimes calls the scheduler41074107+ * completion handling). Unfortunately, it sometimes calls the scheduler41084108 * in interrupt context which is a big NO! NO!.41094109 **/41104110static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)···46474647 cmd = scsi_host_find_tag(ha->host, index);46484648 /*46494649 * We cannot just check if the index is valid,46504650- * becase if we are run from the scsi eh, then46504650+ * because if we are run from the scsi eh, then46514651 * the scsi/block layer is going to prevent46524652 * the tag from being released.46534653 */···49524952 /* Upon successful firmware/chip reset, re-initialize the adapter */49534953 if (status == QLA_SUCCESS) {49544954 /* For ISP-4xxx, force function 1 to always initialize49554955- * before function 3 to prevent both funcions from49554955+ * before function 3 to prevent both functions from49564956 * stepping on top of the other */49574957 if (is_qla40XX(ha) && (ha->mac_index == 3))49584958 ssleep(6);···69146914 struct ddb_entry *ddb_entry = NULL;6915691569166916 /* Create session object, with INVALID_ENTRY,69176917- * the targer_id would get set when we issue the login69176917+ * the target_id would get set when we issue the login69186918 */69196919 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, ha->host,69206920 cmds_max, sizeof(struct ddb_entry),
+2-2
drivers/scsi/scsi_error.c
···554554 * happened, even if someone else gets the sense data.555555 */556556 if (sshdr.asc == 0x28)557557- scmd->device->ua_new_media_ctr++;557557+ atomic_inc(&sdev->ua_new_media_ctr);558558 else if (sshdr.asc == 0x29)559559- scmd->device->ua_por_ctr++;559559+ atomic_inc(&sdev->ua_por_ctr);560560 }561561562562 if (scsi_sense_is_deferred(&sshdr))
+46-52
drivers/scsi/storvsc_drv.c
···14061406 }1407140714081408 /*14091409- * Our channel array is sparsley populated and we14091409+ * Our channel array could be sparsley populated and we14101410 * initiated I/O on a processor/hw-q that does not14111411 * currently have a designated channel. Fix this.14121412 * The strategy is simple:14131413- * I. Ensure NUMA locality14141414- * II. Distribute evenly (best effort)14131413+ * I. Prefer the channel associated with the current CPU14141414+ * II. Ensure NUMA locality14151415+ * III. Distribute evenly (best effort)14151416 */14171417+14181418+ /* Prefer the channel on the I/O issuing processor/hw-q */14191419+ if (cpumask_test_cpu(q_num, &stor_device->alloced_cpus))14201420+ return stor_device->stor_chns[q_num];1416142114171422 node_mask = cpumask_of_node(cpu_to_node(q_num));14181423···14741469 /* See storvsc_change_target_cpu(). */14751470 outgoing_channel = READ_ONCE(stor_device->stor_chns[q_num]);14761471 if (outgoing_channel != NULL) {14771477- if (outgoing_channel->target_cpu == q_num) {14781478- /*14791479- * Ideally, we want to pick a different channel if14801480- * available on the same NUMA node.14811481- */14821482- node_mask = cpumask_of_node(cpu_to_node(q_num));14831483- for_each_cpu_wrap(tgt_cpu,14841484- &stor_device->alloced_cpus, q_num + 1) {14851485- if (!cpumask_test_cpu(tgt_cpu, node_mask))14861486- continue;14871487- if (tgt_cpu == q_num)14881488- continue;14891489- channel = READ_ONCE(14901490- stor_device->stor_chns[tgt_cpu]);14911491- if (channel == NULL)14921492- continue;14931493- if (hv_get_avail_to_write_percent(14941494- &channel->outbound)14951495- > ring_avail_percent_lowater) {14961496- outgoing_channel = channel;14971497- goto found_channel;14981498- }14991499- }14721472+ if (hv_get_avail_to_write_percent(&outgoing_channel->outbound)14731473+ > ring_avail_percent_lowater)14741474+ goto found_channel;1500147515011501- /*15021502- * All the other channels on the same NUMA node are15031503- * busy. Try to use the channel on the current CPU15041504- */15051505- if (hv_get_avail_to_write_percent(15061506- &outgoing_channel->outbound)15071507- > ring_avail_percent_lowater)14761476+ /*14771477+ * Channel is busy, try to find a channel on the same NUMA node14781478+ */14791479+ node_mask = cpumask_of_node(cpu_to_node(q_num));14801480+ for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus,14811481+ q_num + 1) {14821482+ if (!cpumask_test_cpu(tgt_cpu, node_mask))14831483+ continue;14841484+ channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]);14851485+ if (!channel)14861486+ continue;14871487+ if (hv_get_avail_to_write_percent(&channel->outbound)14881488+ > ring_avail_percent_lowater) {14891489+ outgoing_channel = channel;15081490 goto found_channel;15091509-15101510- /*15111511- * If we reach here, all the channels on the current15121512- * NUMA node are busy. Try to find a channel in15131513- * other NUMA nodes15141514- */15151515- for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) {15161516- if (cpumask_test_cpu(tgt_cpu, node_mask))15171517- continue;15181518- channel = READ_ONCE(15191519- stor_device->stor_chns[tgt_cpu]);15201520- if (channel == NULL)15211521- continue;15221522- if (hv_get_avail_to_write_percent(15231523- &channel->outbound)15241524- > ring_avail_percent_lowater) {15251525- outgoing_channel = channel;15261526- goto found_channel;15271527- }15281491 }15291492 }14931493+14941494+ /*14951495+ * If we reach here, all the channels on the current14961496+ * NUMA node are busy. Try to find a channel in14971497+ * all NUMA nodes14981498+ */14991499+ for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus,15001500+ q_num + 1) {15011501+ channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]);15021502+ if (!channel)15031503+ continue;15041504+ if (hv_get_avail_to_write_percent(&channel->outbound)15051505+ > ring_avail_percent_lowater) {15061506+ outgoing_channel = channel;15071507+ goto found_channel;15081508+ }15091509+ }15101510+ /*15111511+ * If we reach here, all the channels are busy. Use the15121512+ * original channel found.15131513+ */15301514 } else {15311515 spin_lock_irqsave(&stor_device->lock, flags);15321516 outgoing_channel = stor_device->stor_chns[q_num];
···42694269 get, UIC_GET_ATTR_ID(attr_sel),42704270 UFS_UIC_COMMAND_RETRIES - retries);4271427142724272- if (mib_val && !ret)42734273- *mib_val = uic_cmd.argument3;42724272+ if (mib_val)42734273+ *mib_val = ret == 0 ? uic_cmd.argument3 : 0;4274427442754275 if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)42764276 && pwr_mode_change)···4986498649874987static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)49884988{49894989- int tx_lanes = 0, i, err = 0;49894989+ int tx_lanes, i, err = 0;4990499049914991 if (!peer)49924992 ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),···50535053 * If UFS device isn't active then we will have to issue link startup50545054 * 2 times to make sure the device state move to active.50555055 */50565056- if (!ufshcd_is_ufs_dev_active(hba))50565056+ if (!(hba->quirks & UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE) &&50575057+ !ufshcd_is_ufs_dev_active(hba))50575058 link_startup_again = true;5058505950595060link_startup:···51195118 ufshcd_readl(hba, REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER);51205119 ret = ufshcd_make_hba_operational(hba);51215120out:51225122- if (ret) {51215121+ if (ret)51235122 dev_err(hba->dev, "link startup failed %d\n", ret);51245124- ufshcd_print_host_state(hba);51255125- ufshcd_print_pwr_info(hba);51265126- ufshcd_print_evt_hist(hba);51275127- }51285123 return ret;51295124}51305125···66766679 hba->saved_uic_err, hba->force_reset,66776680 ufshcd_is_link_broken(hba) ? "; link is broken" : "");6678668166826682+ /*66836683+ * Use ufshcd_rpm_get_noresume() here to safely perform link recovery66846684+ * even if an error occurs during runtime suspend or runtime resume.66856685+ * This avoids potential deadlocks that could happen if we tried to66866686+ * resume the device while a PM operation is already in progress.66876687+ */66886688+ ufshcd_rpm_get_noresume(hba);66896689+ if (hba->pm_op_in_progress) {66906690+ ufshcd_link_recovery(hba);66916691+ ufshcd_rpm_put(hba);66926692+ return;66936693+ }66946694+ ufshcd_rpm_put(hba);66956695+66796696 down(&hba->host_sem);66806697 spin_lock_irqsave(hba->host->host_lock, flags);66816698 if (ufshcd_err_handling_should_stop(hba)) {···67006689 return;67016690 }67026691 spin_unlock_irqrestore(hba->host->host_lock, flags);67036703-67046704- ufshcd_rpm_get_noresume(hba);67056705- if (hba->pm_op_in_progress) {67066706- ufshcd_link_recovery(hba);67076707- ufshcd_rpm_put(hba);67086708- return;67096709- }67106710- ufshcd_rpm_put(hba);6711669267126693 ufshcd_err_handling_prepare(hba);67136694···85408537 dev_info->hid_sup = get_unaligned_be32(desc_buf +85418538 DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) &85428539 UFS_DEV_HID_SUPPORT;85438543-85448544- sysfs_update_group(&hba->dev->kobj, &ufs_sysfs_hid_group);8545854085468541 model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];85478542···1070110700 * @mmio_base: base register address1070210701 * @irq: Interrupt line of device1070310702 *1070410704- * Return: 0 on success, non-zero value on failure.1070310703+ * Return: 0 on success; < 0 on failure.1070510704 */1070610705int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)1070710706{···1094010939 if (err)1094110940 goto out_disable;10942109411094310943- async_schedule(ufshcd_async_scan, hba);1094410942 ufs_sysfs_add_nodes(hba->dev);1094310943+ async_schedule(ufshcd_async_scan, hba);10945109441094610945 device_enable_async_suspend(dev);1094710946 ufshcd_pm_qos_init(hba);···1095110950 hba->is_irq_enabled = false;1095210951 ufshcd_hba_exit(hba);1095310952out_error:1095410954- return err;1095310953+ return err > 0 ? -EIO : err;1095510954}1095610955EXPORT_SYMBOL_GPL(ufshcd_init);1095710956
+14-1
drivers/ufs/host/ufs-qcom.c
···740740741741742742 /* reset the connected UFS device during power down */743743- if (ufs_qcom_is_link_off(hba) && host->device_reset)743743+ if (ufs_qcom_is_link_off(hba) && host->device_reset) {744744 ufs_qcom_device_reset_ctrl(hba, true);745745+ /*746746+ * After sending the SSU command, asserting the rst_n747747+ * line causes the device firmware to wake up and748748+ * execute its reset routine.749749+ *750750+ * During this process, the device may draw current751751+ * beyond the permissible limit for low-power mode (LPM).752752+ * A 10ms delay, based on experimental observations,753753+ * allows the UFS device to complete its hardware reset754754+ * before transitioning the power rail to LPM.755755+ */756756+ usleep_range(10000, 11000);757757+ }745758746759 return ufs_qcom_ice_suspend(host);747760}
···258258 unsigned int queue_stopped; /* request queue is quiesced */259259 bool offline_already; /* Device offline message logged */260260261261- unsigned int ua_new_media_ctr; /* Counter for New Media UNIT ATTENTIONs */262262- unsigned int ua_por_ctr; /* Counter for Power On / Reset UAs */261261+ atomic_t ua_new_media_ctr; /* Counter for New Media UNIT ATTENTIONs */262262+ atomic_t ua_por_ctr; /* Counter for Power On / Reset UAs */263263264264 atomic_t disk_events_disable_depth; /* disable depth for disk events */265265···719719}720720721721/* Macros to access the UNIT ATTENTION counters */722722-#define scsi_get_ua_new_media_ctr(sdev) \723723- ((const unsigned int)(sdev->ua_new_media_ctr))724724-#define scsi_get_ua_por_ctr(sdev) \725725- ((const unsigned int)(sdev->ua_por_ctr))722722+#define scsi_get_ua_new_media_ctr(sdev) atomic_read(&sdev->ua_new_media_ctr)723723+#define scsi_get_ua_por_ctr(sdev) atomic_read(&sdev->ua_por_ctr)726724727725#define MODULE_ALIAS_SCSI_DEVICE(type) \728726 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
+7
include/ufs/ufshcd.h
···683683 * single doorbell mode.684684 */685685 UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25,686686+687687+ /*688688+ * This quirk indicates that DME_LINKSTARTUP should not be issued a 2nd689689+ * time (refer link_startup_again) after the 1st time was successful,690690+ * because it causes link startup to become unreliable.691691+ */692692+ UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE = 1 << 26,686693};687694688695enum ufshcd_caps {