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 branch 6.18/scsi-fixes into 6.19/scsi-staging

Pull in fixes branch to resolve UFS merge conflict.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+178 -95
+4
Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-ufs-phy.yaml
··· 24 24 - enum: 25 25 - qcom,qcs8300-qmp-ufs-phy 26 26 - const: qcom,sa8775p-qmp-ufs-phy 27 + - items: 28 + - enum: 29 + - qcom,kaanapali-qmp-ufs-phy 30 + - const: qcom,sm8750-qmp-ufs-phy 27 31 - enum: 28 32 - qcom,msm8996-qmp-ufs-phy 29 33 - qcom,msm8998-qmp-ufs-phy
+2
Documentation/devicetree/bindings/ufs/qcom,sm8650-ufshc.yaml
··· 15 15 compatible: 16 16 contains: 17 17 enum: 18 + - qcom,kaanapali-ufshc 18 19 - qcom,sm8650-ufshc 19 20 - qcom,sm8750-ufshc 20 21 required: ··· 25 24 compatible: 26 25 items: 27 26 - enum: 27 + - qcom,kaanapali-ufshc 28 28 - qcom,sm8650-ufshc 29 29 - qcom,sm8750-ufshc 30 30 - const: qcom,ufshc
+3 -2
drivers/scsi/hosts.c
··· 626 626 { 627 627 int cnt = 0; 628 628 629 - blk_mq_tagset_busy_iter(&shost->tag_set, 630 - scsi_host_check_in_flight, &cnt); 629 + if (shost->tag_set.ops) 630 + blk_mq_tagset_busy_iter(&shost->tag_set, 631 + scsi_host_check_in_flight, &cnt); 631 632 return cnt; 632 633 } 633 634 EXPORT_SYMBOL(scsi_host_busy);
+1 -1
drivers/scsi/libfc/fc_fcp.c
··· 503 503 host_bcode = FC_ERROR; 504 504 goto err; 505 505 } 506 - if (offset + len > fsp->data_len) { 506 + if (size_add(offset, len) > fsp->data_len) { 507 507 /* this should never happen */ 508 508 if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && 509 509 fc_frame_crc_check(fp))
+4 -4
drivers/scsi/qla4xxx/ql4_os.c
··· 4104 4104 * The mid-level driver tries to ensure that queuecommand never gets 4105 4105 * invoked concurrently with itself or the interrupt handler (although 4106 4106 * the interrupt handler may call this routine as part of request- 4107 - * completion handling). Unfortunely, it sometimes calls the scheduler 4107 + * completion handling). Unfortunately, it sometimes calls the scheduler 4108 4108 * in interrupt context which is a big NO! NO!. 4109 4109 **/ 4110 4110 static int qla4xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ··· 4647 4647 cmd = scsi_host_find_tag(ha->host, index); 4648 4648 /* 4649 4649 * We cannot just check if the index is valid, 4650 - * becase if we are run from the scsi eh, then 4650 + * because if we are run from the scsi eh, then 4651 4651 * the scsi/block layer is going to prevent 4652 4652 * the tag from being released. 4653 4653 */ ··· 4952 4952 /* Upon successful firmware/chip reset, re-initialize the adapter */ 4953 4953 if (status == QLA_SUCCESS) { 4954 4954 /* For ISP-4xxx, force function 1 to always initialize 4955 - * before function 3 to prevent both funcions from 4955 + * before function 3 to prevent both functions from 4956 4956 * stepping on top of the other */ 4957 4957 if (is_qla40XX(ha) && (ha->mac_index == 3)) 4958 4958 ssleep(6); ··· 6914 6914 struct ddb_entry *ddb_entry = NULL; 6915 6915 6916 6916 /* Create session object, with INVALID_ENTRY, 6917 - * the targer_id would get set when we issue the login 6917 + * the target_id would get set when we issue the login 6918 6918 */ 6919 6919 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, ha->host, 6920 6920 cmds_max, sizeof(struct ddb_entry),
+2 -2
drivers/scsi/scsi_error.c
··· 554 554 * happened, even if someone else gets the sense data. 555 555 */ 556 556 if (sshdr.asc == 0x28) 557 - scmd->device->ua_new_media_ctr++; 557 + atomic_inc(&sdev->ua_new_media_ctr); 558 558 else if (sshdr.asc == 0x29) 559 - scmd->device->ua_por_ctr++; 559 + atomic_inc(&sdev->ua_por_ctr); 560 560 } 561 561 562 562 if (scsi_sense_is_deferred(&sshdr))
+46 -52
drivers/scsi/storvsc_drv.c
··· 1406 1406 } 1407 1407 1408 1408 /* 1409 - * Our channel array is sparsley populated and we 1409 + * Our channel array could be sparsley populated and we 1410 1410 * initiated I/O on a processor/hw-q that does not 1411 1411 * currently have a designated channel. Fix this. 1412 1412 * The strategy is simple: 1413 - * I. Ensure NUMA locality 1414 - * II. Distribute evenly (best effort) 1413 + * I. Prefer the channel associated with the current CPU 1414 + * II. Ensure NUMA locality 1415 + * III. Distribute evenly (best effort) 1415 1416 */ 1417 + 1418 + /* Prefer the channel on the I/O issuing processor/hw-q */ 1419 + if (cpumask_test_cpu(q_num, &stor_device->alloced_cpus)) 1420 + return stor_device->stor_chns[q_num]; 1416 1421 1417 1422 node_mask = cpumask_of_node(cpu_to_node(q_num)); 1418 1423 ··· 1474 1469 /* See storvsc_change_target_cpu(). */ 1475 1470 outgoing_channel = READ_ONCE(stor_device->stor_chns[q_num]); 1476 1471 if (outgoing_channel != NULL) { 1477 - if (outgoing_channel->target_cpu == q_num) { 1478 - /* 1479 - * Ideally, we want to pick a different channel if 1480 - * available on the same NUMA node. 1481 - */ 1482 - node_mask = cpumask_of_node(cpu_to_node(q_num)); 1483 - for_each_cpu_wrap(tgt_cpu, 1484 - &stor_device->alloced_cpus, q_num + 1) { 1485 - if (!cpumask_test_cpu(tgt_cpu, node_mask)) 1486 - continue; 1487 - if (tgt_cpu == q_num) 1488 - continue; 1489 - channel = READ_ONCE( 1490 - stor_device->stor_chns[tgt_cpu]); 1491 - if (channel == NULL) 1492 - continue; 1493 - if (hv_get_avail_to_write_percent( 1494 - &channel->outbound) 1495 - > ring_avail_percent_lowater) { 1496 - outgoing_channel = channel; 1497 - goto found_channel; 1498 - } 1499 - } 1472 + if (hv_get_avail_to_write_percent(&outgoing_channel->outbound) 1473 + > ring_avail_percent_lowater) 1474 + goto found_channel; 1500 1475 1501 - /* 1502 - * All the other channels on the same NUMA node are 1503 - * busy. Try to use the channel on the current CPU 1504 - */ 1505 - if (hv_get_avail_to_write_percent( 1506 - &outgoing_channel->outbound) 1507 - > ring_avail_percent_lowater) 1476 + /* 1477 + * Channel is busy, try to find a channel on the same NUMA node 1478 + */ 1479 + node_mask = cpumask_of_node(cpu_to_node(q_num)); 1480 + for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus, 1481 + q_num + 1) { 1482 + if (!cpumask_test_cpu(tgt_cpu, node_mask)) 1483 + continue; 1484 + channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]); 1485 + if (!channel) 1486 + continue; 1487 + if (hv_get_avail_to_write_percent(&channel->outbound) 1488 + > ring_avail_percent_lowater) { 1489 + outgoing_channel = channel; 1508 1490 goto found_channel; 1509 - 1510 - /* 1511 - * If we reach here, all the channels on the current 1512 - * NUMA node are busy. Try to find a channel in 1513 - * other NUMA nodes 1514 - */ 1515 - for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) { 1516 - if (cpumask_test_cpu(tgt_cpu, node_mask)) 1517 - continue; 1518 - channel = READ_ONCE( 1519 - stor_device->stor_chns[tgt_cpu]); 1520 - if (channel == NULL) 1521 - continue; 1522 - if (hv_get_avail_to_write_percent( 1523 - &channel->outbound) 1524 - > ring_avail_percent_lowater) { 1525 - outgoing_channel = channel; 1526 - goto found_channel; 1527 - } 1528 1491 } 1529 1492 } 1493 + 1494 + /* 1495 + * If we reach here, all the channels on the current 1496 + * NUMA node are busy. Try to find a channel in 1497 + * all NUMA nodes 1498 + */ 1499 + for_each_cpu_wrap(tgt_cpu, &stor_device->alloced_cpus, 1500 + q_num + 1) { 1501 + channel = READ_ONCE(stor_device->stor_chns[tgt_cpu]); 1502 + if (!channel) 1503 + continue; 1504 + if (hv_get_avail_to_write_percent(&channel->outbound) 1505 + > ring_avail_percent_lowater) { 1506 + outgoing_channel = channel; 1507 + goto found_channel; 1508 + } 1509 + } 1510 + /* 1511 + * If we reach here, all the channels are busy. Use the 1512 + * original channel found. 1513 + */ 1530 1514 } else { 1531 1515 spin_lock_irqsave(&stor_device->lock, flags); 1532 1516 outgoing_channel = stor_device->stor_chns[q_num];
+1 -1
drivers/ufs/core/ufs-sysfs.c
··· 1950 1950 return hba->dev_info.hid_sup ? attr->mode : 0; 1951 1951 } 1952 1952 1953 - const struct attribute_group ufs_sysfs_hid_group = { 1953 + static const struct attribute_group ufs_sysfs_hid_group = { 1954 1954 .name = "hid", 1955 1955 .attrs = ufs_sysfs_hid, 1956 1956 .is_visible = ufs_sysfs_hid_is_visible,
-1
drivers/ufs/core/ufs-sysfs.h
··· 14 14 15 15 extern const struct attribute_group ufs_sysfs_unit_descriptor_group; 16 16 extern const struct attribute_group ufs_sysfs_lun_attributes_group; 17 - extern const struct attribute_group ufs_sysfs_hid_group; 18 17 19 18 #endif
+23 -22
drivers/ufs/core/ufshcd.c
··· 4269 4269 get, UIC_GET_ATTR_ID(attr_sel), 4270 4270 UFS_UIC_COMMAND_RETRIES - retries); 4271 4271 4272 - if (mib_val && !ret) 4273 - *mib_val = uic_cmd.argument3; 4272 + if (mib_val) 4273 + *mib_val = ret == 0 ? uic_cmd.argument3 : 0; 4274 4274 4275 4275 if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE) 4276 4276 && pwr_mode_change) ··· 4986 4986 4987 4987 static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) 4988 4988 { 4989 - int tx_lanes = 0, i, err = 0; 4989 + int tx_lanes, i, err = 0; 4990 4990 4991 4991 if (!peer) 4992 4992 ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES), ··· 5053 5053 * If UFS device isn't active then we will have to issue link startup 5054 5054 * 2 times to make sure the device state move to active. 5055 5055 */ 5056 - if (!ufshcd_is_ufs_dev_active(hba)) 5056 + if (!(hba->quirks & UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE) && 5057 + !ufshcd_is_ufs_dev_active(hba)) 5057 5058 link_startup_again = true; 5058 5059 5059 5060 link_startup: ··· 5119 5118 ufshcd_readl(hba, REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER); 5120 5119 ret = ufshcd_make_hba_operational(hba); 5121 5120 out: 5122 - if (ret) { 5121 + if (ret) 5123 5122 dev_err(hba->dev, "link startup failed %d\n", ret); 5124 - ufshcd_print_host_state(hba); 5125 - ufshcd_print_pwr_info(hba); 5126 - ufshcd_print_evt_hist(hba); 5127 - } 5128 5123 return ret; 5129 5124 } 5130 5125 ··· 6676 6679 hba->saved_uic_err, hba->force_reset, 6677 6680 ufshcd_is_link_broken(hba) ? "; link is broken" : ""); 6678 6681 6682 + /* 6683 + * Use ufshcd_rpm_get_noresume() here to safely perform link recovery 6684 + * even if an error occurs during runtime suspend or runtime resume. 6685 + * This avoids potential deadlocks that could happen if we tried to 6686 + * resume the device while a PM operation is already in progress. 6687 + */ 6688 + ufshcd_rpm_get_noresume(hba); 6689 + if (hba->pm_op_in_progress) { 6690 + ufshcd_link_recovery(hba); 6691 + ufshcd_rpm_put(hba); 6692 + return; 6693 + } 6694 + ufshcd_rpm_put(hba); 6695 + 6679 6696 down(&hba->host_sem); 6680 6697 spin_lock_irqsave(hba->host->host_lock, flags); 6681 6698 if (ufshcd_err_handling_should_stop(hba)) { ··· 6700 6689 return; 6701 6690 } 6702 6691 spin_unlock_irqrestore(hba->host->host_lock, flags); 6703 - 6704 - ufshcd_rpm_get_noresume(hba); 6705 - if (hba->pm_op_in_progress) { 6706 - ufshcd_link_recovery(hba); 6707 - ufshcd_rpm_put(hba); 6708 - return; 6709 - } 6710 - ufshcd_rpm_put(hba); 6711 6692 6712 6693 ufshcd_err_handling_prepare(hba); 6713 6694 ··· 8540 8537 dev_info->hid_sup = get_unaligned_be32(desc_buf + 8541 8538 DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) & 8542 8539 UFS_DEV_HID_SUPPORT; 8543 - 8544 - sysfs_update_group(&hba->dev->kobj, &ufs_sysfs_hid_group); 8545 8540 8546 8541 model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME]; 8547 8542 ··· 10701 10700 * @mmio_base: base register address 10702 10701 * @irq: Interrupt line of device 10703 10702 * 10704 - * Return: 0 on success, non-zero value on failure. 10703 + * Return: 0 on success; < 0 on failure. 10705 10704 */ 10706 10705 int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) 10707 10706 { ··· 10940 10939 if (err) 10941 10940 goto out_disable; 10942 10941 10943 - async_schedule(ufshcd_async_scan, hba); 10944 10942 ufs_sysfs_add_nodes(hba->dev); 10943 + async_schedule(ufshcd_async_scan, hba); 10945 10944 10946 10945 device_enable_async_suspend(dev); 10947 10946 ufshcd_pm_qos_init(hba); ··· 10951 10950 hba->is_irq_enabled = false; 10952 10951 ufshcd_hba_exit(hba); 10953 10952 out_error: 10954 - return err; 10953 + return err > 0 ? -EIO : err; 10955 10954 } 10956 10955 EXPORT_SYMBOL_GPL(ufshcd_init); 10957 10956
+14 -1
drivers/ufs/host/ufs-qcom.c
··· 740 740 741 741 742 742 /* reset the connected UFS device during power down */ 743 - if (ufs_qcom_is_link_off(hba) && host->device_reset) 743 + if (ufs_qcom_is_link_off(hba) && host->device_reset) { 744 744 ufs_qcom_device_reset_ctrl(hba, true); 745 + /* 746 + * After sending the SSU command, asserting the rst_n 747 + * line causes the device firmware to wake up and 748 + * execute its reset routine. 749 + * 750 + * During this process, the device may draw current 751 + * beyond the permissible limit for low-power mode (LPM). 752 + * A 10ms delay, based on experimental observations, 753 + * allows the UFS device to complete its hardware reset 754 + * before transitioning the power rail to LPM. 755 + */ 756 + usleep_range(10000, 11000); 757 + } 745 758 746 759 return ufs_qcom_ice_suspend(host); 747 760 }
+67 -3
drivers/ufs/host/ufshcd-pci.c
··· 15 15 #include <linux/pci.h> 16 16 #include <linux/pm_runtime.h> 17 17 #include <linux/pm_qos.h> 18 + #include <linux/suspend.h> 18 19 #include <linux/debugfs.h> 19 20 #include <linux/uuid.h> 20 21 #include <linux/acpi.h> ··· 32 31 u32 dsm_fns; 33 32 u32 active_ltr; 34 33 u32 idle_ltr; 34 + int saved_spm_lvl; 35 35 struct dentry *debugfs_root; 36 36 struct gpio_desc *reset_gpio; 37 37 }; ··· 349 347 host = devm_kzalloc(hba->dev, sizeof(*host), GFP_KERNEL); 350 348 if (!host) 351 349 return -ENOMEM; 350 + host->saved_spm_lvl = -1; 352 351 ufshcd_set_variant(hba, host); 353 352 intel_dsm_init(host, hba->dev); 354 353 if (INTEL_DSM_SUPPORTED(host, RESET)) { ··· 428 425 static int ufs_intel_adl_init(struct ufs_hba *hba) 429 426 { 430 427 hba->nop_out_timeout = 200; 431 - hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8; 428 + hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8 | 429 + UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE; 432 430 hba->caps |= UFSHCD_CAP_WB_EN; 433 431 return ufs_intel_common_init(hba); 434 432 } ··· 542 538 543 539 return ufshcd_system_resume(dev); 544 540 } 541 + 542 + static int ufs_intel_suspend_prepare(struct device *dev) 543 + { 544 + struct ufs_hba *hba = dev_get_drvdata(dev); 545 + struct intel_host *host = ufshcd_get_variant(hba); 546 + int err; 547 + 548 + /* 549 + * Only s2idle (S0ix) retains link state. Force power-off 550 + * (UFS_PM_LVL_5) for any other case. 551 + */ 552 + if (pm_suspend_target_state != PM_SUSPEND_TO_IDLE && hba->spm_lvl < UFS_PM_LVL_5) { 553 + host->saved_spm_lvl = hba->spm_lvl; 554 + hba->spm_lvl = UFS_PM_LVL_5; 555 + } 556 + 557 + err = ufshcd_suspend_prepare(dev); 558 + 559 + if (err < 0 && host->saved_spm_lvl != -1) { 560 + hba->spm_lvl = host->saved_spm_lvl; 561 + host->saved_spm_lvl = -1; 562 + } 563 + 564 + return err; 565 + } 566 + 567 + static void ufs_intel_resume_complete(struct device *dev) 568 + { 569 + struct ufs_hba *hba = dev_get_drvdata(dev); 570 + struct intel_host *host = ufshcd_get_variant(hba); 571 + 572 + ufshcd_resume_complete(dev); 573 + 574 + if (host->saved_spm_lvl != -1) { 575 + hba->spm_lvl = host->saved_spm_lvl; 576 + host->saved_spm_lvl = -1; 577 + } 578 + } 579 + 580 + static int ufshcd_pci_suspend_prepare(struct device *dev) 581 + { 582 + struct ufs_hba *hba = dev_get_drvdata(dev); 583 + 584 + if (!strcmp(hba->vops->name, "intel-pci")) 585 + return ufs_intel_suspend_prepare(dev); 586 + 587 + return ufshcd_suspend_prepare(dev); 588 + } 589 + 590 + static void ufshcd_pci_resume_complete(struct device *dev) 591 + { 592 + struct ufs_hba *hba = dev_get_drvdata(dev); 593 + 594 + if (!strcmp(hba->vops->name, "intel-pci")) { 595 + ufs_intel_resume_complete(dev); 596 + return; 597 + } 598 + 599 + ufshcd_resume_complete(dev); 600 + } 545 601 #endif 546 602 547 603 /** ··· 675 611 .thaw = ufshcd_system_resume, 676 612 .poweroff = ufshcd_system_suspend, 677 613 .restore = ufshcd_pci_restore, 678 - .prepare = ufshcd_suspend_prepare, 679 - .complete = ufshcd_resume_complete, 614 + .prepare = ufshcd_pci_suspend_prepare, 615 + .complete = ufshcd_pci_resume_complete, 680 616 #endif 681 617 }; 682 618
+4 -6
include/scsi/scsi_device.h
··· 258 258 unsigned int queue_stopped; /* request queue is quiesced */ 259 259 bool offline_already; /* Device offline message logged */ 260 260 261 - unsigned int ua_new_media_ctr; /* Counter for New Media UNIT ATTENTIONs */ 262 - unsigned int ua_por_ctr; /* Counter for Power On / Reset UAs */ 261 + atomic_t ua_new_media_ctr; /* Counter for New Media UNIT ATTENTIONs */ 262 + atomic_t ua_por_ctr; /* Counter for Power On / Reset UAs */ 263 263 264 264 atomic_t disk_events_disable_depth; /* disable depth for disk events */ 265 265 ··· 719 719 } 720 720 721 721 /* Macros to access the UNIT ATTENTION counters */ 722 - #define scsi_get_ua_new_media_ctr(sdev) \ 723 - ((const unsigned int)(sdev->ua_new_media_ctr)) 724 - #define scsi_get_ua_por_ctr(sdev) \ 725 - ((const unsigned int)(sdev->ua_por_ctr)) 722 + #define scsi_get_ua_new_media_ctr(sdev) atomic_read(&sdev->ua_new_media_ctr) 723 + #define scsi_get_ua_por_ctr(sdev) atomic_read(&sdev->ua_por_ctr) 726 724 727 725 #define MODULE_ALIAS_SCSI_DEVICE(type) \ 728 726 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
+7
include/ufs/ufshcd.h
··· 683 683 * single doorbell mode. 684 684 */ 685 685 UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25, 686 + 687 + /* 688 + * This quirk indicates that DME_LINKSTARTUP should not be issued a 2nd 689 + * time (refer link_startup_again) after the 1st time was successful, 690 + * because it causes link startup to become unreliable. 691 + */ 692 + UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE = 1 << 26, 686 693 }; 687 694 688 695 enum ufshcd_caps {