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

Merge branch '6.15/scsi-fixes' into 6.16/scsi-staging

Pull in fixes from 6.15 and resolve a few conflicts so we can have a
clean base for UFS patches.

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

+414 -76
+32
Documentation/ABI/testing/sysfs-driver-ufs
··· 1605 1605 1606 1606 The attribute is read/write. 1607 1607 1608 + What: /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_count 1609 + What: /sys/bus/platform/devices/*.ufs/device_lvl_exception_count 1610 + Date: March 2025 1611 + Contact: Bao D. Nguyen <quic_nguyenb@quicinc.com> 1612 + Description: 1613 + This attribute is applicable to ufs devices compliant to the 1614 + JEDEC specifications version 4.1 or later. The 1615 + device_lvl_exception_count is a counter indicating the number of 1616 + times the device level exceptions have occurred since the last 1617 + time this variable is reset. Writing a 0 value to this 1618 + attribute will reset the device_lvl_exception_count. If the 1619 + device_lvl_exception_count reads a positive value, the user 1620 + application should read the device_lvl_exception_id attribute to 1621 + know more information about the exception. 1622 + 1623 + The attribute is read/write. 1624 + 1625 + What: /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_id 1626 + What: /sys/bus/platform/devices/*.ufs/device_lvl_exception_id 1627 + Date: March 2025 1628 + Contact: Bao D. Nguyen <quic_nguyenb@quicinc.com> 1629 + Description: 1630 + Reading the device_lvl_exception_id returns the 1631 + qDeviceLevelExceptionID attribute of the ufs device JEDEC 1632 + specification version 4.1. The definition of the 1633 + qDeviceLevelExceptionID is the ufs device vendor specific 1634 + implementation. Refer to the device manufacturer datasheet for 1635 + more information on the meaning of the qDeviceLevelExceptionID 1636 + attribute value. 1637 + 1638 + The attribute is read only. 1639 + 1608 1640 What: /sys/bus/platform/drivers/ufshcd/*/wb_resize_enable 1609 1641 What: /sys/bus/platform/devices/*.ufs/wb_resize_enable 1610 1642 Date: April 2025
+20
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 943 943 container_of(work, typeof(*phy), works[event]); 944 944 struct hisi_hba *hisi_hba = phy->hisi_hba; 945 945 struct asd_sas_phy *sas_phy = &phy->sas_phy; 946 + struct asd_sas_port *sas_port = sas_phy->port; 947 + struct hisi_sas_port *port = phy->port; 948 + struct device *dev = hisi_hba->dev; 949 + struct domain_device *port_dev; 946 950 int phy_no = sas_phy->id; 951 + 952 + if (!test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags) && 953 + sas_port && port && (port->id != phy->port_id)) { 954 + dev_info(dev, "phy%d's hw port id changed from %d to %llu\n", 955 + phy_no, port->id, phy->port_id); 956 + port_dev = sas_port->port_dev; 957 + if (port_dev && !dev_is_expander(port_dev->dev_type)) { 958 + /* 959 + * Set the device state to gone to block 960 + * sending IO to the device. 961 + */ 962 + set_bit(SAS_DEV_GONE, &port_dev->state); 963 + hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET); 964 + return; 965 + } 966 + } 947 967 948 968 phy->wait_phyup_cnt = 0; 949 969 if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP)
+7 -2
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 2501 2501 struct hisi_sas_port *port = to_hisi_sas_port(sas_port); 2502 2502 struct sas_ata_task *ata_task = &task->ata_task; 2503 2503 struct sas_tmf_task *tmf = slot->tmf; 2504 + int phy_id; 2504 2505 u8 *buf_cmd; 2505 2506 int has_data = 0, hdr_tag = 0; 2506 2507 u32 dw0, dw1 = 0, dw2 = 0; ··· 2509 2508 /* create header */ 2510 2509 /* dw0 */ 2511 2510 dw0 = port->id << CMD_HDR_PORT_OFF; 2512 - if (parent_dev && dev_is_expander(parent_dev->dev_type)) 2511 + if (parent_dev && dev_is_expander(parent_dev->dev_type)) { 2513 2512 dw0 |= 3 << CMD_HDR_CMD_OFF; 2514 - else 2513 + } else { 2514 + phy_id = device->phy->identify.phy_identifier; 2515 + dw0 |= (1U << phy_id) << CMD_HDR_PHY_ID_OFF; 2516 + dw0 |= CMD_HDR_FORCE_PHY_MSK; 2515 2517 dw0 |= 4 << CMD_HDR_CMD_OFF; 2518 + } 2516 2519 2517 2520 if (tmf && ata_task->force_phy) { 2518 2521 dw0 |= CMD_HDR_FORCE_PHY_MSK;
+12 -2
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 359 359 #define CMD_HDR_RESP_REPORT_MSK (0x1 << CMD_HDR_RESP_REPORT_OFF) 360 360 #define CMD_HDR_TLR_CTRL_OFF 6 361 361 #define CMD_HDR_TLR_CTRL_MSK (0x3 << CMD_HDR_TLR_CTRL_OFF) 362 + #define CMD_HDR_PHY_ID_OFF 8 363 + #define CMD_HDR_PHY_ID_MSK (0x1ff << CMD_HDR_PHY_ID_OFF) 364 + #define CMD_HDR_FORCE_PHY_OFF 17 365 + #define CMD_HDR_FORCE_PHY_MSK (0x1U << CMD_HDR_FORCE_PHY_OFF) 362 366 #define CMD_HDR_PORT_OFF 18 363 367 #define CMD_HDR_PORT_MSK (0xf << CMD_HDR_PORT_OFF) 364 368 #define CMD_HDR_PRIORITY_OFF 27 ··· 1481 1477 struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; 1482 1478 struct asd_sas_port *sas_port = device->port; 1483 1479 struct hisi_sas_port *port = to_hisi_sas_port(sas_port); 1480 + int phy_id; 1484 1481 u8 *buf_cmd; 1485 1482 int has_data = 0, hdr_tag = 0; 1486 1483 u32 dw1 = 0, dw2 = 0; 1487 1484 1488 1485 hdr->dw0 = cpu_to_le32(port->id << CMD_HDR_PORT_OFF); 1489 - if (parent_dev && dev_is_expander(parent_dev->dev_type)) 1486 + if (parent_dev && dev_is_expander(parent_dev->dev_type)) { 1490 1487 hdr->dw0 |= cpu_to_le32(3 << CMD_HDR_CMD_OFF); 1491 - else 1488 + } else { 1489 + phy_id = device->phy->identify.phy_identifier; 1490 + hdr->dw0 |= cpu_to_le32((1U << phy_id) 1491 + << CMD_HDR_PHY_ID_OFF); 1492 + hdr->dw0 |= CMD_HDR_FORCE_PHY_MSK; 1492 1493 hdr->dw0 |= cpu_to_le32(4U << CMD_HDR_CMD_OFF); 1494 + } 1493 1495 1494 1496 switch (task->data_dir) { 1495 1497 case DMA_TO_DEVICE:
+2 -2
drivers/scsi/megaraid/megaraid_sas.h
··· 23 23 /* 24 24 * MegaRAID SAS Driver meta data 25 25 */ 26 - #define MEGASAS_VERSION "07.727.03.00-rc1" 27 - #define MEGASAS_RELDATE "Oct 03, 2023" 26 + #define MEGASAS_VERSION "07.734.00.00-rc1" 27 + #define MEGASAS_RELDATE "Apr 03, 2025" 28 28 29 29 #define MEGASAS_MSIX_NAME_LEN 32 30 30
+7 -2
drivers/scsi/megaraid/megaraid_sas_base.c
··· 2103 2103 /* This sdev property may change post OCR */ 2104 2104 megasas_set_dynamic_target_properties(sdev, lim, is_target_prop); 2105 2105 2106 + if (!MEGASAS_IS_LOGICAL(sdev)) 2107 + sdev->no_vpd_size = 1; 2108 + 2106 2109 mutex_unlock(&instance->reset_mutex); 2107 2110 2108 2111 return 0; ··· 3665 3662 3666 3663 case MFI_STAT_SCSI_IO_FAILED: 3667 3664 case MFI_STAT_LD_INIT_IN_PROGRESS: 3668 - cmd->scmd->result = 3669 - (DID_ERROR << 16) | hdr->scsi_status; 3665 + if (hdr->scsi_status == 0xf0) 3666 + cmd->scmd->result = (DID_ERROR << 16) | SAM_STAT_CHECK_CONDITION; 3667 + else 3668 + cmd->scmd->result = (DID_ERROR << 16) | hdr->scsi_status; 3670 3669 break; 3671 3670 3672 3671 case MFI_STAT_SCSI_DONE_WITH_ERROR:
+4 -1
drivers/scsi/megaraid/megaraid_sas_fusion.c
··· 2043 2043 2044 2044 case MFI_STAT_SCSI_IO_FAILED: 2045 2045 case MFI_STAT_LD_INIT_IN_PROGRESS: 2046 - scmd->result = (DID_ERROR << 16) | ext_status; 2046 + if (ext_status == 0xf0) 2047 + scmd->result = (DID_ERROR << 16) | SAM_STAT_CHECK_CONDITION; 2048 + else 2049 + scmd->result = (DID_ERROR << 16) | ext_status; 2047 2050 break; 2048 2051 2049 2052 case MFI_STAT_SCSI_DONE_WITH_ERROR:
+7 -1
drivers/scsi/mpi3mr/mpi3mr_fw.c
··· 174 174 char *desc = NULL; 175 175 u16 event; 176 176 177 + if (!(mrioc->logging_level & MPI3_DEBUG_EVENT)) 178 + return; 179 + 177 180 event = event_reply->event; 178 181 179 182 switch (event) { ··· 454 451 return 0; 455 452 } 456 453 454 + atomic_set(&mrioc->admin_pend_isr, 0); 457 455 reply_desc = (struct mpi3_default_reply_descriptor *)mrioc->admin_reply_base + 458 456 admin_reply_ci; 459 457 ··· 569 565 WRITE_ONCE(op_req_q->ci, le16_to_cpu(reply_desc->request_queue_ci)); 570 566 mpi3mr_process_op_reply_desc(mrioc, reply_desc, &reply_dma, 571 567 reply_qidx); 572 - atomic_dec(&op_reply_q->pend_ios); 568 + 573 569 if (reply_dma) 574 570 mpi3mr_repost_reply_buf(mrioc, reply_dma); 575 571 num_op_reply++; ··· 2929 2925 mrioc->admin_reply_ci = 0; 2930 2926 mrioc->admin_reply_ephase = 1; 2931 2927 atomic_set(&mrioc->admin_reply_q_in_use, 0); 2928 + atomic_set(&mrioc->admin_pend_isr, 0); 2932 2929 2933 2930 if (!mrioc->admin_req_base) { 2934 2931 mrioc->admin_req_base = dma_alloc_coherent(&mrioc->pdev->dev, ··· 4658 4653 if (mrioc->admin_reply_base) 4659 4654 memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz); 4660 4655 atomic_set(&mrioc->admin_reply_q_in_use, 0); 4656 + atomic_set(&mrioc->admin_pend_isr, 0); 4661 4657 4662 4658 if (mrioc->init_cmds.reply) { 4663 4659 memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
+1
drivers/scsi/pm8001/pm8001_sas.c
··· 766 766 spin_lock_irqsave(&pm8001_ha->lock, flags); 767 767 } 768 768 PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id); 769 + pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached = 0; 769 770 pm8001_free_dev(pm8001_dev); 770 771 } else { 771 772 pm8001_dbg(pm8001_ha, DISC, "Found dev has gone.\n");
+5 -1
drivers/scsi/scsi_lib.c
··· 1253 1253 */ 1254 1254 static void scsi_cleanup_rq(struct request *rq) 1255 1255 { 1256 + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); 1257 + 1258 + cmd->flags = 0; 1259 + 1256 1260 if (rq->rq_flags & RQF_DONTPREP) { 1257 - scsi_mq_uninit_cmd(blk_mq_rq_to_pdu(rq)); 1261 + scsi_mq_uninit_cmd(cmd); 1258 1262 rq->rq_flags &= ~RQF_DONTPREP; 1259 1263 } 1260 1264 }
+5 -2
drivers/scsi/scsi_transport_iscsi.c
··· 3182 3182 } 3183 3183 3184 3184 /* see similar check in iscsi_if_set_param() */ 3185 - if (strlen(data) > ev->u.set_host_param.len) 3186 - return -EINVAL; 3185 + if (strlen(data) > ev->u.set_host_param.len) { 3186 + err = -EINVAL; 3187 + goto out; 3188 + } 3187 3189 3188 3190 err = transport->set_host_param(shost, ev->u.set_host_param.param, 3189 3191 data, ev->u.set_host_param.len); 3192 + out: 3190 3193 scsi_host_put(shost); 3191 3194 return err; 3192 3195 }
+1 -1
drivers/scsi/scsi_transport_srp.c
··· 388 388 "reconnect attempt %d failed (%d)\n", 389 389 ++rport->failed_reconnects, res); 390 390 delay = rport->reconnect_delay * 391 - min(100, max(1, rport->failed_reconnects - 10)); 391 + clamp(rport->failed_reconnects - 10, 1, 100); 392 392 if (delay > 0) 393 393 queue_delayed_work(system_long_wq, 394 394 &rport->reconnect_work, delay * HZ);
+7 -6
drivers/scsi/smartpqi/smartpqi_init.c
··· 19 19 #include <linux/bcd.h> 20 20 #include <linux/reboot.h> 21 21 #include <linux/cciss_ioctl.h> 22 + #include <linux/crash_dump.h> 22 23 #include <scsi/scsi_host.h> 23 24 #include <scsi/scsi_cmnd.h> 24 25 #include <scsi/scsi_device.h> ··· 5247 5246 ctrl_info->error_buffer_length = 5248 5247 ctrl_info->max_io_slots * PQI_ERROR_BUFFER_ELEMENT_LENGTH; 5249 5248 5250 - if (reset_devices) 5249 + if (is_kdump_kernel()) 5251 5250 max_transfer_size = min(ctrl_info->max_transfer_size, 5252 5251 PQI_MAX_TRANSFER_SIZE_KDUMP); 5253 5252 else ··· 5276 5275 u16 num_elements_per_iq; 5277 5276 u16 num_elements_per_oq; 5278 5277 5279 - if (reset_devices) { 5278 + if (is_kdump_kernel()) { 5280 5279 num_queue_groups = 1; 5281 5280 } else { 5282 5281 int num_cpus; ··· 8289 8288 u32 product_id; 8290 8289 8291 8290 if (reset_devices) { 8292 - if (pqi_is_fw_triage_supported(ctrl_info)) { 8291 + if (is_kdump_kernel() && pqi_is_fw_triage_supported(ctrl_info)) { 8293 8292 rc = sis_wait_for_fw_triage_completion(ctrl_info); 8294 8293 if (rc) 8295 8294 return rc; 8296 8295 } 8297 - if (sis_is_ctrl_logging_supported(ctrl_info)) { 8296 + if (is_kdump_kernel() && sis_is_ctrl_logging_supported(ctrl_info)) { 8298 8297 sis_notify_kdump(ctrl_info); 8299 8298 rc = sis_wait_for_ctrl_logging_completion(ctrl_info); 8300 8299 if (rc) ··· 8345 8344 ctrl_info->product_id = (u8)product_id; 8346 8345 ctrl_info->product_revision = (u8)(product_id >> 8); 8347 8346 8348 - if (reset_devices) { 8347 + if (is_kdump_kernel()) { 8349 8348 if (ctrl_info->max_outstanding_requests > 8350 8349 PQI_MAX_OUTSTANDING_REQUESTS_KDUMP) 8351 8350 ctrl_info->max_outstanding_requests = ··· 8481 8480 if (rc) 8482 8481 return rc; 8483 8482 8484 - if (ctrl_info->ctrl_logging_supported && !reset_devices) { 8483 + if (ctrl_info->ctrl_logging_supported && !is_kdump_kernel()) { 8485 8484 pqi_host_setup_buffer(ctrl_info, &ctrl_info->ctrl_log_memory, PQI_CTRL_LOG_TOTAL_SIZE, PQI_CTRL_LOG_MIN_SIZE); 8486 8485 pqi_host_memory_update(ctrl_info, &ctrl_info->ctrl_log_memory, PQI_VENDOR_GENERAL_CTRL_LOG_MEMORY_UPDATE); 8487 8486 }
+1 -1
drivers/target/iscsi/iscsi_target.c
··· 4263 4263 spin_unlock(&iscsit_global->ts_bitmap_lock); 4264 4264 4265 4265 iscsit_stop_timers_for_cmds(conn); 4266 - iscsit_stop_nopin_response_timer(conn); 4267 4266 iscsit_stop_nopin_timer(conn); 4267 + iscsit_stop_nopin_response_timer(conn); 4268 4268 4269 4269 if (conn->conn_transport->iscsit_wait_conn) 4270 4270 conn->conn_transport->iscsit_wait_conn(conn);
+5 -7
drivers/ufs/core/ufs-mcq.c
··· 677 677 unsigned long flags; 678 678 int err; 679 679 680 - if (!ufshcd_cmd_inflight(lrbp->cmd)) { 681 - dev_err(hba->dev, 682 - "%s: skip abort. cmd at tag %d already completed.\n", 683 - __func__, tag); 684 - return FAILED; 685 - } 686 - 687 680 /* Skip task abort in case previous aborts failed and report failure */ 688 681 if (lrbp->req_abort_skip) { 689 682 dev_err(hba->dev, "%s: skip abort. tag %d failed earlier\n", ··· 685 692 } 686 693 687 694 hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); 695 + if (!hwq) { 696 + dev_err(hba->dev, "%s: skip abort. cmd at tag %d already completed.\n", 697 + __func__, tag); 698 + return FAILED; 699 + } 688 700 689 701 if (ufshcd_mcq_sqe_search(hba, hwq, tag)) { 690 702 /*
+54
drivers/ufs/core/ufs-sysfs.c
··· 534 534 return sysfs_emit(buf, "%d\n", hba->critical_health_count); 535 535 } 536 536 537 + static ssize_t device_lvl_exception_count_show(struct device *dev, 538 + struct device_attribute *attr, 539 + char *buf) 540 + { 541 + struct ufs_hba *hba = dev_get_drvdata(dev); 542 + 543 + if (hba->dev_info.wspecversion < 0x410) 544 + return -EOPNOTSUPP; 545 + 546 + return sysfs_emit(buf, "%u\n", atomic_read(&hba->dev_lvl_exception_count)); 547 + } 548 + 549 + static ssize_t device_lvl_exception_count_store(struct device *dev, 550 + struct device_attribute *attr, 551 + const char *buf, size_t count) 552 + { 553 + struct ufs_hba *hba = dev_get_drvdata(dev); 554 + unsigned int value; 555 + 556 + if (kstrtouint(buf, 0, &value)) 557 + return -EINVAL; 558 + 559 + /* the only supported usecase is to reset the dev_lvl_exception_count */ 560 + if (value) 561 + return -EINVAL; 562 + 563 + atomic_set(&hba->dev_lvl_exception_count, 0); 564 + 565 + return count; 566 + } 567 + 568 + static ssize_t device_lvl_exception_id_show(struct device *dev, 569 + struct device_attribute *attr, 570 + char *buf) 571 + { 572 + struct ufs_hba *hba = dev_get_drvdata(dev); 573 + u64 exception_id; 574 + int err; 575 + 576 + ufshcd_rpm_get_sync(hba); 577 + err = ufshcd_read_device_lvl_exception_id(hba, &exception_id); 578 + ufshcd_rpm_put_sync(hba); 579 + 580 + if (err) 581 + return err; 582 + 583 + hba->dev_lvl_exception_id = exception_id; 584 + return sysfs_emit(buf, "%llu\n", exception_id); 585 + } 586 + 537 587 static DEVICE_ATTR_RW(rpm_lvl); 538 588 static DEVICE_ATTR_RO(rpm_target_dev_state); 539 589 static DEVICE_ATTR_RO(rpm_target_link_state); ··· 598 548 static DEVICE_ATTR_RW(rtc_update_ms); 599 549 static DEVICE_ATTR_RW(pm_qos_enable); 600 550 static DEVICE_ATTR_RO(critical_health); 551 + static DEVICE_ATTR_RW(device_lvl_exception_count); 552 + static DEVICE_ATTR_RO(device_lvl_exception_id); 601 553 602 554 static struct attribute *ufs_sysfs_ufshcd_attrs[] = { 603 555 &dev_attr_rpm_lvl.attr, ··· 616 564 &dev_attr_rtc_update_ms.attr, 617 565 &dev_attr_pm_qos_enable.attr, 618 566 &dev_attr_critical_health.attr, 567 + &dev_attr_device_lvl_exception_count.attr, 568 + &dev_attr_device_lvl_exception_id.attr, 619 569 NULL 620 570 }; 621 571
+1
drivers/ufs/core/ufshcd-priv.h
··· 94 94 enum query_opcode desc_op); 95 95 96 96 int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); 97 + int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id); 97 98 98 99 /* Wrapper functions for safely calling variant operations */ 99 100 static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
+99 -24
drivers/ufs/core/ufshcd.c
··· 278 278 .model = UFS_ANY_MODEL, 279 279 .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | 280 280 UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE | 281 + UFS_DEVICE_QUIRK_PA_HIBER8TIME | 281 282 UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS }, 282 283 { .wmanufacturerid = UFS_VENDOR_SKHYNIX, 283 284 .model = UFS_ANY_MODEL, ··· 3174 3173 int err; 3175 3174 3176 3175 retry: 3177 - time_left = wait_for_completion_timeout(hba->dev_cmd.complete, 3176 + time_left = wait_for_completion_timeout(&hba->dev_cmd.complete, 3178 3177 time_left); 3179 3178 3180 3179 if (likely(time_left)) { 3181 - /* 3182 - * The completion handler called complete() and the caller of 3183 - * this function still owns the @lrbp tag so the code below does 3184 - * not trigger any race conditions. 3185 - */ 3186 - hba->dev_cmd.complete = NULL; 3187 3180 err = ufshcd_get_tr_ocs(lrbp, NULL); 3188 3181 if (!err) 3189 3182 err = ufshcd_dev_cmd_completion(hba, lrbp); ··· 3191 3196 /* successfully cleared the command, retry if needed */ 3192 3197 if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) 3193 3198 err = -EAGAIN; 3194 - hba->dev_cmd.complete = NULL; 3195 3199 return err; 3196 3200 } 3197 3201 ··· 3206 3212 spin_lock_irqsave(&hba->outstanding_lock, flags); 3207 3213 pending = test_bit(lrbp->task_tag, 3208 3214 &hba->outstanding_reqs); 3209 - if (pending) { 3210 - hba->dev_cmd.complete = NULL; 3215 + if (pending) 3211 3216 __clear_bit(lrbp->task_tag, 3212 3217 &hba->outstanding_reqs); 3213 - } 3214 3218 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 3215 3219 3216 3220 if (!pending) { ··· 3226 3234 spin_lock_irqsave(&hba->outstanding_lock, flags); 3227 3235 pending = test_bit(lrbp->task_tag, 3228 3236 &hba->outstanding_reqs); 3229 - if (pending) 3230 - hba->dev_cmd.complete = NULL; 3231 3237 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 3232 3238 3233 3239 if (!pending) { ··· 3259 3269 static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, 3260 3270 const u32 tag, int timeout) 3261 3271 { 3262 - DECLARE_COMPLETION_ONSTACK(wait); 3263 3272 int err; 3264 3273 3265 - hba->dev_cmd.complete = &wait; 3266 - 3267 3274 ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr); 3268 - 3269 3275 ufshcd_send_command(hba, tag, hba->dev_cmd_queue); 3270 3276 err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout); 3271 3277 ··· 5568 5582 ufshcd_release_scsi_cmd(hba, lrbp); 5569 5583 /* Do not touch lrbp after scsi done */ 5570 5584 scsi_done(cmd); 5571 - } else if (hba->dev_cmd.complete) { 5585 + } else { 5572 5586 if (cqe) { 5573 5587 ocs = le32_to_cpu(cqe->status) & MASK_OCS; 5574 5588 lrbp->utr_descriptor_ptr->header.ocs = ocs; 5575 5589 } 5576 - complete(hba->dev_cmd.complete); 5590 + complete(&hba->dev_cmd.complete); 5577 5591 } 5578 5592 } 5579 5593 ··· 5675 5689 continue; 5676 5690 5677 5691 hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); 5692 + if (!hwq) 5693 + continue; 5678 5694 5679 5695 if (force_compl) { 5680 5696 ufshcd_mcq_compl_all_cqes_lock(hba, hwq); ··· 5998 6010 __func__, err); 5999 6011 } 6000 6012 6013 + int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id) 6014 + { 6015 + struct utp_upiu_query_v4_0 *upiu_resp; 6016 + struct ufs_query_req *request = NULL; 6017 + struct ufs_query_res *response = NULL; 6018 + int err; 6019 + 6020 + if (hba->dev_info.wspecversion < 0x410) 6021 + return -EOPNOTSUPP; 6022 + 6023 + ufshcd_hold(hba); 6024 + mutex_lock(&hba->dev_cmd.lock); 6025 + 6026 + ufshcd_init_query(hba, &request, &response, 6027 + UPIU_QUERY_OPCODE_READ_ATTR, 6028 + QUERY_ATTR_IDN_DEV_LVL_EXCEPTION_ID, 0, 0); 6029 + 6030 + request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST; 6031 + 6032 + err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, QUERY_REQ_TIMEOUT); 6033 + 6034 + if (err) { 6035 + dev_err(hba->dev, "%s: failed to read device level exception %d\n", 6036 + __func__, err); 6037 + goto out; 6038 + } 6039 + 6040 + upiu_resp = (struct utp_upiu_query_v4_0 *)response; 6041 + *exception_id = get_unaligned_be64(&upiu_resp->osf3); 6042 + out: 6043 + mutex_unlock(&hba->dev_cmd.lock); 6044 + ufshcd_release(hba); 6045 + 6046 + return err; 6047 + } 6048 + 6001 6049 static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn) 6002 6050 { 6003 6051 u8 index; ··· 6119 6095 return ret; 6120 6096 } 6121 6097 6122 - static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, 6098 + static bool ufshcd_wb_curr_buff_threshold_check(struct ufs_hba *hba, 6123 6099 u32 avail_buf) 6124 6100 { 6125 6101 u32 cur_buf; ··· 6201 6177 } 6202 6178 6203 6179 /* 6204 - * The ufs device needs the vcc to be ON to flush. 6205 6180 * With user-space reduction enabled, it's enough to enable flush 6206 6181 * by checking only the available buffer. The threshold 6207 6182 * defined here is > 90% full. 6208 6183 * With user-space preserved enabled, the current-buffer 6209 6184 * should be checked too because the wb buffer size can reduce 6210 6185 * when disk tends to be full. This info is provided by current 6211 - * buffer (dCurrentWriteBoosterBufferSize). There's no point in 6212 - * keeping vcc on when current buffer is empty. 6186 + * buffer (dCurrentWriteBoosterBufferSize). 6213 6187 */ 6214 6188 index = ufshcd_wb_get_query_index(hba); 6215 6189 ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, ··· 6222 6200 if (!hba->dev_info.b_presrv_uspc_en) 6223 6201 return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10); 6224 6202 6225 - return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf); 6203 + return ufshcd_wb_curr_buff_threshold_check(hba, avail_buf); 6226 6204 } 6227 6205 6228 6206 static void ufshcd_rpm_dev_flush_recheck_work(struct work_struct *work) ··· 6272 6250 if (status & hba->ee_drv_mask & MASK_EE_HEALTH_CRITICAL) { 6273 6251 hba->critical_health_count++; 6274 6252 sysfs_notify(&hba->dev->kobj, NULL, "critical_health"); 6253 + } 6254 + 6255 + if (status & hba->ee_drv_mask & MASK_EE_DEV_LVL_EXCEPTION) { 6256 + atomic_inc(&hba->dev_lvl_exception_count); 6257 + sysfs_notify(&hba->dev->kobj, NULL, "device_lvl_exception_count"); 6275 6258 } 6276 6259 6277 6260 ufs_debugfs_exception_event(hba, status); ··· 8202 8175 } 8203 8176 } 8204 8177 8178 + static void ufshcd_device_lvl_exception_probe(struct ufs_hba *hba, u8 *desc_buf) 8179 + { 8180 + u32 ext_ufs_feature; 8181 + 8182 + if (hba->dev_info.wspecversion < 0x410) 8183 + return; 8184 + 8185 + ext_ufs_feature = get_unaligned_be32(desc_buf + 8186 + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); 8187 + if (!(ext_ufs_feature & UFS_DEV_LVL_EXCEPTION_SUP)) 8188 + return; 8189 + 8190 + atomic_set(&hba->dev_lvl_exception_count, 0); 8191 + ufshcd_enable_ee(hba, MASK_EE_DEV_LVL_EXCEPTION); 8192 + } 8193 + 8205 8194 static void ufshcd_set_rtt(struct ufs_hba *hba) 8206 8195 { 8207 8196 struct ufs_dev_info *dev_info = &hba->dev_info; ··· 8418 8375 8419 8376 ufs_init_rtc(hba, desc_buf); 8420 8377 8378 + ufshcd_device_lvl_exception_probe(hba, desc_buf); 8379 + 8421 8380 /* 8422 8381 * ufshcd_read_string_desc returns size of the string 8423 8382 * reset the error value ··· 8509 8464 return ret; 8510 8465 } 8511 8466 8467 + /** 8468 + * ufshcd_quirk_override_pa_h8time - Ensures proper adjustment of PA_HIBERN8TIME. 8469 + * @hba: per-adapter instance 8470 + * 8471 + * Some UFS devices require specific adjustments to the PA_HIBERN8TIME parameter 8472 + * to ensure proper hibernation timing. This function retrieves the current 8473 + * PA_HIBERN8TIME value and increments it by 100us. 8474 + */ 8475 + static void ufshcd_quirk_override_pa_h8time(struct ufs_hba *hba) 8476 + { 8477 + u32 pa_h8time; 8478 + int ret; 8479 + 8480 + ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_HIBERN8TIME), &pa_h8time); 8481 + if (ret) { 8482 + dev_err(hba->dev, "Failed to get PA_HIBERN8TIME: %d\n", ret); 8483 + return; 8484 + } 8485 + 8486 + /* Increment by 1 to increase hibernation time by 100 µs */ 8487 + ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), pa_h8time + 1); 8488 + if (ret) 8489 + dev_err(hba->dev, "Failed updating PA_HIBERN8TIME: %d\n", ret); 8490 + } 8491 + 8512 8492 static void ufshcd_tune_unipro_params(struct ufs_hba *hba) 8513 8493 { 8514 8494 ufshcd_vops_apply_dev_quirks(hba); ··· 8544 8474 8545 8475 if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE) 8546 8476 ufshcd_quirk_tune_host_pa_tactivate(hba); 8477 + 8478 + if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_HIBER8TIME) 8479 + ufshcd_quirk_override_pa_h8time(hba); 8547 8480 } 8548 8481 8549 8482 static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba) ··· 10599 10526 hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state( 10600 10527 UFS_SLEEP_PWR_MODE, 10601 10528 UIC_LINK_HIBERN8_STATE); 10529 + 10530 + init_completion(&hba->dev_cmd.complete); 10602 10531 10603 10532 err = ufshcd_hba_init(hba); 10604 10533 if (err)
+63 -22
drivers/ufs/host/ufs-exynos.c
··· 34 34 * Exynos's Vendor specific registers for UFSHCI 35 35 */ 36 36 #define HCI_TXPRDT_ENTRY_SIZE 0x00 37 - #define PRDT_PREFECT_EN BIT(31) 37 + #define PRDT_PREFETCH_EN BIT(31) 38 38 #define HCI_RXPRDT_ENTRY_SIZE 0x04 39 39 #define HCI_1US_TO_CNT_VAL 0x0C 40 40 #define CNT_VAL_1US_MASK 0x3FF ··· 92 92 UIC_TRANSPORT_NO_CONNECTION_RX |\ 93 93 UIC_TRANSPORT_BAD_TC) 94 94 95 - /* FSYS UFS Shareability */ 96 - #define UFS_WR_SHARABLE BIT(2) 97 - #define UFS_RD_SHARABLE BIT(1) 98 - #define UFS_SHARABLE (UFS_WR_SHARABLE | UFS_RD_SHARABLE) 99 - #define UFS_SHAREABILITY_OFFSET 0x710 95 + /* UFS Shareability */ 96 + #define UFS_EXYNOSAUTO_WR_SHARABLE BIT(2) 97 + #define UFS_EXYNOSAUTO_RD_SHARABLE BIT(1) 98 + #define UFS_EXYNOSAUTO_SHARABLE (UFS_EXYNOSAUTO_WR_SHARABLE | \ 99 + UFS_EXYNOSAUTO_RD_SHARABLE) 100 + #define UFS_GS101_WR_SHARABLE BIT(1) 101 + #define UFS_GS101_RD_SHARABLE BIT(0) 102 + #define UFS_GS101_SHARABLE (UFS_GS101_WR_SHARABLE | \ 103 + UFS_GS101_RD_SHARABLE) 104 + #define UFS_SHAREABILITY_OFFSET 0x710 100 105 101 106 /* Multi-host registers */ 102 107 #define MHCTRL 0xC4 ··· 214 209 /* IO Coherency setting */ 215 210 if (ufs->sysreg) { 216 211 return regmap_update_bits(ufs->sysreg, 217 - ufs->shareability_reg_offset, 218 - UFS_SHARABLE, UFS_SHARABLE); 212 + ufs->iocc_offset, 213 + ufs->iocc_mask, ufs->iocc_val); 219 214 } 220 215 221 216 return 0; ··· 962 957 } 963 958 964 959 phy_set_bus_width(generic_phy, ufs->avail_ln_rx); 960 + 961 + if (generic_phy->power_count) { 962 + phy_power_off(generic_phy); 963 + phy_exit(generic_phy); 964 + } 965 + 965 966 ret = phy_init(generic_phy); 966 967 if (ret) { 967 968 dev_err(hba->dev, "%s: phy init failed, ret = %d\n", ··· 1060 1049 exynos_ufs_config_intr(ufs, DFES_DEF_L4_ERRS, UNIPRO_L4); 1061 1050 exynos_ufs_set_unipro_pclk_div(ufs); 1062 1051 1052 + exynos_ufs_setup_clocks(hba, true, PRE_CHANGE); 1053 + 1063 1054 /* unipro */ 1064 1055 exynos_ufs_config_unipro(ufs); 1056 + 1057 + if (ufs->drv_data->pre_link) 1058 + ufs->drv_data->pre_link(ufs); 1065 1059 1066 1060 /* m-phy */ 1067 1061 exynos_ufs_phy_init(ufs); ··· 1074 1058 exynos_ufs_config_phy_time_attr(ufs); 1075 1059 exynos_ufs_config_phy_cap_attr(ufs); 1076 1060 } 1077 - 1078 - exynos_ufs_setup_clocks(hba, true, PRE_CHANGE); 1079 - 1080 - if (ufs->drv_data->pre_link) 1081 - ufs->drv_data->pre_link(ufs); 1082 1061 1083 1062 return 0; 1084 1063 } ··· 1098 1087 struct exynos_ufs *ufs = ufshcd_get_variant(hba); 1099 1088 struct phy *generic_phy = ufs->phy; 1100 1089 struct exynos_ufs_uic_attr *attr = ufs->drv_data->uic_attr; 1090 + u32 val = ilog2(DATA_UNIT_SIZE); 1101 1091 1102 1092 exynos_ufs_establish_connt(ufs); 1103 1093 exynos_ufs_fit_aggr_timeout(ufs); 1104 1094 1105 1095 hci_writel(ufs, 0xa, HCI_DATA_REORDER); 1106 - hci_writel(ufs, ilog2(DATA_UNIT_SIZE), HCI_TXPRDT_ENTRY_SIZE); 1096 + 1097 + if (hba->caps & UFSHCD_CAP_CRYPTO) 1098 + val |= PRDT_PREFETCH_EN; 1099 + hci_writel(ufs, val, HCI_TXPRDT_ENTRY_SIZE); 1100 + 1107 1101 hci_writel(ufs, ilog2(DATA_UNIT_SIZE), HCI_RXPRDT_ENTRY_SIZE); 1108 1102 hci_writel(ufs, (1 << hba->nutrs) - 1, HCI_UTRL_NEXUS_TYPE); 1109 1103 hci_writel(ufs, (1 << hba->nutmrs) - 1, HCI_UTMRL_NEXUS_TYPE); ··· 1184 1168 ufs->sysreg = NULL; 1185 1169 else { 1186 1170 if (of_property_read_u32_index(np, "samsung,sysreg", 1, 1187 - &ufs->shareability_reg_offset)) { 1171 + &ufs->iocc_offset)) { 1188 1172 dev_warn(dev, "can't get an offset from sysreg. Set to default value\n"); 1189 - ufs->shareability_reg_offset = UFS_SHAREABILITY_OFFSET; 1173 + ufs->iocc_offset = UFS_SHAREABILITY_OFFSET; 1190 1174 } 1191 1175 } 1176 + 1177 + ufs->iocc_mask = ufs->drv_data->iocc_mask; 1178 + /* 1179 + * no 'dma-coherent' property means the descriptors are 1180 + * non-cacheable so iocc shareability should be disabled. 1181 + */ 1182 + if (of_dma_is_coherent(dev->of_node)) 1183 + ufs->iocc_val = ufs->iocc_mask; 1184 + else 1185 + ufs->iocc_val = 0; 1192 1186 1193 1187 ufs->pclk_avail_min = PCLK_AVAIL_MIN; 1194 1188 ufs->pclk_avail_max = PCLK_AVAIL_MAX; ··· 1523 1497 return ret; 1524 1498 } 1525 1499 1500 + static void exynos_ufs_exit(struct ufs_hba *hba) 1501 + { 1502 + struct exynos_ufs *ufs = ufshcd_get_variant(hba); 1503 + 1504 + phy_power_off(ufs->phy); 1505 + phy_exit(ufs->phy); 1506 + } 1507 + 1526 1508 static int exynos_ufs_host_reset(struct ufs_hba *hba) 1527 1509 { 1528 1510 struct exynos_ufs *ufs = ufshcd_get_variant(hba); ··· 1701 1667 } 1702 1668 } 1703 1669 1670 + static int gs101_ufs_suspend(struct exynos_ufs *ufs) 1671 + { 1672 + hci_writel(ufs, 0 << 0, HCI_GPIO_OUT); 1673 + return 0; 1674 + } 1675 + 1704 1676 static int exynos_ufs_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op, 1705 1677 enum ufs_notify_change_status status) 1706 1678 { ··· 1714 1674 1715 1675 if (status == PRE_CHANGE) 1716 1676 return 0; 1677 + 1678 + if (ufs->drv_data->suspend) 1679 + ufs->drv_data->suspend(ufs); 1717 1680 1718 1681 if (!ufshcd_is_link_active(hba)) 1719 1682 phy_power_off(ufs->phy); ··· 1995 1952 static const struct ufs_hba_variant_ops ufs_hba_exynos_ops = { 1996 1953 .name = "exynos_ufs", 1997 1954 .init = exynos_ufs_init, 1955 + .exit = exynos_ufs_exit, 1998 1956 .hce_enable_notify = exynos_ufs_hce_enable_notify, 1999 1957 .link_startup_notify = exynos_ufs_link_startup_notify, 2000 1958 .pwr_change_notify = exynos_ufs_pwr_change_notify, ··· 2034 1990 2035 1991 static void exynos_ufs_remove(struct platform_device *pdev) 2036 1992 { 2037 - struct ufs_hba *hba = platform_get_drvdata(pdev); 2038 - struct exynos_ufs *ufs = ufshcd_get_variant(hba); 2039 - 2040 1993 ufshcd_pltfrm_remove(pdev); 2041 - 2042 - phy_power_off(ufs->phy); 2043 - phy_exit(ufs->phy); 2044 1994 } 2045 1995 2046 1996 static struct exynos_ufs_uic_attr exynos7_uic_attr = { ··· 2073 2035 .opts = EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL | 2074 2036 EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR | 2075 2037 EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX, 2038 + .iocc_mask = UFS_EXYNOSAUTO_SHARABLE, 2076 2039 .drv_init = exynosauto_ufs_drv_init, 2077 2040 .post_hce_enable = exynosauto_ufs_post_hce_enable, 2078 2041 .pre_link = exynosauto_ufs_pre_link, ··· 2175 2136 .opts = EXYNOS_UFS_OPT_SKIP_CONFIG_PHY_ATTR | 2176 2137 EXYNOS_UFS_OPT_UFSPR_SECURE | 2177 2138 EXYNOS_UFS_OPT_TIMER_TICK_SELECT, 2139 + .iocc_mask = UFS_GS101_SHARABLE, 2178 2140 .drv_init = gs101_ufs_drv_init, 2179 2141 .pre_link = gs101_ufs_pre_link, 2180 2142 .post_link = gs101_ufs_post_link, 2181 2143 .pre_pwr_change = gs101_ufs_pre_pwr_change, 2144 + .suspend = gs101_ufs_suspend, 2182 2145 }; 2183 2146 2184 2147 static const struct of_device_id exynos_ufs_of_match[] = {
+5 -1
drivers/ufs/host/ufs-exynos.h
··· 181 181 struct exynos_ufs_uic_attr *uic_attr; 182 182 unsigned int quirks; 183 183 unsigned int opts; 184 + u32 iocc_mask; 184 185 /* SoC's specific operations */ 185 186 int (*drv_init)(struct exynos_ufs *ufs); 186 187 int (*pre_link)(struct exynos_ufs *ufs); ··· 192 191 const struct ufs_pa_layer_attr *pwr); 193 192 int (*pre_hce_enable)(struct exynos_ufs *ufs); 194 193 int (*post_hce_enable)(struct exynos_ufs *ufs); 194 + int (*suspend)(struct exynos_ufs *ufs); 195 195 }; 196 196 197 197 struct ufs_phy_time_cfg { ··· 232 230 ktime_t entry_hibern8_t; 233 231 const struct exynos_ufs_drv_data *drv_data; 234 232 struct regmap *sysreg; 235 - u32 shareability_reg_offset; 233 + u32 iocc_offset; 234 + u32 iocc_mask; 235 + u32 iocc_val; 236 236 237 237 u32 opts; 238 238 #define EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL BIT(0)
+43
drivers/ufs/host/ufs-qcom.c
··· 33 33 ((((c) >> 16) & MCQ_QCFGPTR_MASK) * MCQ_QCFGPTR_UNIT) 34 34 #define MCQ_QCFG_SIZE 0x40 35 35 36 + /* De-emphasis for gear-5 */ 37 + #define DEEMPHASIS_3_5_dB 0x04 38 + #define NO_DEEMPHASIS 0x0 39 + 36 40 enum { 37 41 TSTBUS_UAWM, 38 42 TSTBUS_UARM, ··· 834 830 return ufs_qcom_icc_set_bw(host, bw_table.mem_bw, bw_table.cfg_bw); 835 831 } 836 832 833 + static void ufs_qcom_set_tx_hs_equalizer(struct ufs_hba *hba, u32 gear, u32 tx_lanes) 834 + { 835 + u32 equalizer_val; 836 + int ret, i; 837 + 838 + /* Determine the equalizer value based on the gear */ 839 + equalizer_val = (gear == 5) ? DEEMPHASIS_3_5_dB : NO_DEEMPHASIS; 840 + 841 + for (i = 0; i < tx_lanes; i++) { 842 + ret = ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(TX_HS_EQUALIZER, i), 843 + equalizer_val); 844 + if (ret) 845 + dev_err(hba->dev, "%s: failed equalizer lane %d\n", 846 + __func__, i); 847 + } 848 + } 849 + 837 850 static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, 838 851 enum ufs_notify_change_status status, 839 852 const struct ufs_pa_layer_attr *dev_max_params, ··· 902 881 dev_req_params->gear_tx, 903 882 PA_INITIAL_ADAPT); 904 883 } 884 + 885 + if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING) 886 + ufs_qcom_set_tx_hs_equalizer(hba, 887 + dev_req_params->gear_tx, dev_req_params->lane_tx); 888 + 905 889 break; 906 890 case POST_CHANGE: 907 891 if (ufs_qcom_cfg_timers(hba, false)) { ··· 954 928 (pa_vs_config_reg1 | (1 << 12))); 955 929 } 956 930 931 + static void ufs_qcom_override_pa_tx_hsg1_sync_len(struct ufs_hba *hba) 932 + { 933 + int err; 934 + 935 + err = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(PA_TX_HSG1_SYNC_LENGTH), 936 + PA_TX_HSG1_SYNC_LENGTH_VAL); 937 + if (err) 938 + dev_err(hba->dev, "Failed (%d) set PA_TX_HSG1_SYNC_LENGTH\n", err); 939 + } 940 + 957 941 static int ufs_qcom_apply_dev_quirks(struct ufs_hba *hba) 958 942 { 959 943 int err = 0; 960 944 961 945 if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME) 962 946 err = ufs_qcom_quirk_host_pa_saveconfigtime(hba); 947 + 948 + if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH) 949 + ufs_qcom_override_pa_tx_hsg1_sync_len(hba); 963 950 964 951 return err; 965 952 } ··· 988 949 { .wmanufacturerid = UFS_VENDOR_WDC, 989 950 .model = UFS_ANY_MODEL, 990 951 .quirk = UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE }, 952 + { .wmanufacturerid = UFS_VENDOR_SAMSUNG, 953 + .model = UFS_ANY_MODEL, 954 + .quirk = UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH | 955 + UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING }, 991 956 {} 992 957 }; 993 958
+18
drivers/ufs/host/ufs-qcom.h
··· 122 122 TMRLUT_HW_CGC_EN | OCSC_HW_CGC_EN) 123 123 124 124 /* QUniPro Vendor specific attributes */ 125 + #define PA_TX_HSG1_SYNC_LENGTH 0x1552 125 126 #define PA_VS_CONFIG_REG1 0x9000 126 127 #define DME_VS_CORE_CLK_CTRL 0xD002 128 + #define TX_HS_EQUALIZER 0x0037 129 + 127 130 /* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */ 128 131 #define CLK_1US_CYCLES_MASK_V4 GENMASK(27, 16) 129 132 #define CLK_1US_CYCLES_MASK GENMASK(7, 0) ··· 143 140 #define UNIPRO_CORE_CLK_FREQ_300_MHZ 300 144 141 #define UNIPRO_CORE_CLK_FREQ_201_5_MHZ 202 145 142 #define UNIPRO_CORE_CLK_FREQ_403_MHZ 403 143 + 144 + /* TX_HSG1_SYNC_LENGTH attr value */ 145 + #define PA_TX_HSG1_SYNC_LENGTH_VAL 0x4A 146 + 147 + /* 148 + * Some ufs device vendors need a different TSync length. 149 + * Enable this quirk to give an additional TX_HS_SYNC_LENGTH. 150 + */ 151 + #define UFS_DEVICE_QUIRK_PA_TX_HSG1_SYNC_LENGTH BIT(16) 152 + 153 + /* 154 + * Some ufs device vendors need a different Deemphasis setting. 155 + * Enable this quirk to tune TX Deemphasis parameters. 156 + */ 157 + #define UFS_DEVICE_QUIRK_PA_TX_DEEMPHASIS_TUNING BIT(17) 146 158 147 159 /* ICE allocator type to share AES engines among TX stream and RX stream */ 148 160 #define ICE_ALLOCATOR_TYPE 2
+3
include/ufs/ufs.h
··· 181 181 QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, 182 182 QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, 183 183 QUERY_ATTR_IDN_TIMESTAMP = 0x30, 184 + QUERY_ATTR_IDN_DEV_LVL_EXCEPTION_ID = 0x34, 184 185 QUERY_ATTR_IDN_WB_BUF_RESIZE_HINT = 0x3C, 185 186 QUERY_ATTR_IDN_WB_BUF_RESIZE_EN = 0x3D, 186 187 QUERY_ATTR_IDN_WB_BUF_RESIZE_STATUS = 0x3E, ··· 400 399 UFS_DEV_EXT_TEMP_NOTIF = BIT(6), 401 400 UFS_DEV_HPB_SUPPORT = BIT(7), 402 401 UFS_DEV_WRITE_BOOSTER_SUP = BIT(8), 402 + UFS_DEV_LVL_EXCEPTION_SUP = BIT(12), 403 403 }; 404 404 #define UFS_DEV_HPB_SUPPORT_VERSION 0x310 405 405 ··· 430 428 MASK_EE_TOO_LOW_TEMP = BIT(4), 431 429 MASK_EE_WRITEBOOSTER_EVENT = BIT(5), 432 430 MASK_EE_PERFORMANCE_THROTTLING = BIT(6), 431 + MASK_EE_DEV_LVL_EXCEPTION = BIT(7), 433 432 MASK_EE_HEALTH_CRITICAL = BIT(9), 434 433 }; 435 434 #define MASK_EE_URGENT_TEMP (MASK_EE_TOO_HIGH_TEMP | MASK_EE_TOO_LOW_TEMP)
+6
include/ufs/ufs_quirks.h
··· 107 107 */ 108 108 #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11) 109 109 110 + /* 111 + * Some ufs devices may need more time to be in hibern8 before exiting. 112 + * Enable this quirk to give it an additional 100us. 113 + */ 114 + #define UFS_DEVICE_QUIRK_PA_HIBER8TIME (1 << 12) 115 + 110 116 #endif /* UFS_QUIRKS_H_ */
+6 -1
include/ufs/ufshcd.h
··· 246 246 struct ufs_dev_cmd { 247 247 enum dev_cmd_type type; 248 248 struct mutex lock; 249 - struct completion *complete; 249 + struct completion complete; 250 250 struct ufs_query query; 251 251 }; 252 252 ··· 964 964 * @pm_qos_req: PM QoS request handle 965 965 * @pm_qos_enabled: flag to check if pm qos is enabled 966 966 * @critical_health_count: count of critical health exceptions 967 + * @dev_lvl_exception_count: count of device level exceptions since last reset 968 + * @dev_lvl_exception_id: vendor specific information about the 969 + * device level exception event. 967 970 */ 968 971 struct ufs_hba { 969 972 void __iomem *mmio_base; ··· 1138 1135 bool pm_qos_enabled; 1139 1136 1140 1137 int critical_health_count; 1138 + atomic_t dev_lvl_exception_count; 1139 + u64 dev_lvl_exception_id; 1141 1140 }; 1142 1141 1143 1142 /**