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

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

Pull SCSI fixes from James Bottomley:
"Mostly trivial updates and bug fixes (core update is a comment
spelling fix).

The bigger UFS update is the clock scaling and frequency fixes"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: ufs: qcom: Prevent calling phy_exit() before phy_init()
scsi: ufs: qcom: Call ufs_qcom_cfg_timers() in clock scaling path
scsi: ufs: qcom: Map devfreq OPP freq to UniPro Core Clock freq
scsi: ufs: qcom: Check gear against max gear in vop freq_to_gear()
scsi: aacraid: Remove useless code
scsi: core: devinfo: Fix typo in comment
scsi: ufs: core: Don't perform UFS clkscaling during host async scan

+110 -47
-1
drivers/scsi/aacraid/aacraid.h
··· 93 93 94 94 #define AAC_NUM_MGT_FIB 8 95 95 #define AAC_NUM_IO_FIB (1024 - AAC_NUM_MGT_FIB) 96 - #define AAC_NUM_FIB (AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB) 97 96 98 97 #define AAC_MAX_LUN 256 99 98
+1 -9
drivers/scsi/aacraid/commsup.c
··· 48 48 49 49 static int fib_map_alloc(struct aac_dev *dev) 50 50 { 51 - if (dev->max_fib_size > AAC_MAX_NATIVE_SIZE) 52 - dev->max_cmd_size = AAC_MAX_NATIVE_SIZE; 53 - else 54 - dev->max_cmd_size = dev->max_fib_size; 55 - if (dev->max_fib_size < AAC_MAX_NATIVE_SIZE) { 56 - dev->max_cmd_size = AAC_MAX_NATIVE_SIZE; 57 - } else { 58 - dev->max_cmd_size = dev->max_fib_size; 59 - } 51 + dev->max_cmd_size = AAC_MAX_NATIVE_SIZE; 60 52 61 53 dprintk((KERN_INFO 62 54 "allocate hardware fibs dma_alloc_coherent(%p, %d * (%d + %d), %p)\n",
+1 -1
drivers/scsi/scsi_devinfo.c
··· 836 836 goto out; 837 837 838 838 for (i = 0; scsi_static_device_list[i].vendor; i++) { 839 - error = scsi_dev_info_list_add(1 /* compatibile */, 839 + error = scsi_dev_info_list_add(1 /* compatible */, 840 840 scsi_static_device_list[i].vendor, 841 841 scsi_static_device_list[i].model, 842 842 NULL,
+3
drivers/ufs/core/ufshcd.c
··· 1397 1397 * make sure that there are no outstanding requests when 1398 1398 * clock scaling is in progress 1399 1399 */ 1400 + mutex_lock(&hba->host->scan_mutex); 1400 1401 blk_mq_quiesce_tagset(&hba->host->tag_set); 1401 1402 mutex_lock(&hba->wb_mutex); 1402 1403 down_write(&hba->clk_scaling_lock); ··· 1408 1407 up_write(&hba->clk_scaling_lock); 1409 1408 mutex_unlock(&hba->wb_mutex); 1410 1409 blk_mq_unquiesce_tagset(&hba->host->tag_set); 1410 + mutex_unlock(&hba->host->scan_mutex); 1411 1411 goto out; 1412 1412 } 1413 1413 ··· 1430 1428 mutex_unlock(&hba->wb_mutex); 1431 1429 1432 1430 blk_mq_unquiesce_tagset(&hba->host->tag_set); 1431 + mutex_unlock(&hba->host->scan_mutex); 1433 1432 ufshcd_release(hba); 1434 1433 } 1435 1434
+105 -36
drivers/ufs/host/ufs-qcom.c
··· 122 122 }; 123 123 124 124 static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host); 125 - static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq); 125 + static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, 126 + unsigned long freq, char *name); 127 + static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up, unsigned long freq); 126 128 127 129 static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd) 128 130 { ··· 508 506 if (ret) 509 507 return ret; 510 508 511 - if (phy->power_count) { 509 + if (phy->power_count) 512 510 phy_power_off(phy); 513 - phy_exit(phy); 514 - } 511 + 515 512 516 513 /* phy initialization - calibrate the phy */ 517 514 ret = phy_init(phy); ··· 598 597 * 599 598 * @hba: host controller instance 600 599 * @is_pre_scale_up: flag to check if pre scale up condition. 600 + * @freq: target opp freq 601 601 * Return: zero for success and non-zero in case of a failure. 602 602 */ 603 - static int ufs_qcom_cfg_timers(struct ufs_hba *hba, bool is_pre_scale_up) 603 + static int ufs_qcom_cfg_timers(struct ufs_hba *hba, bool is_pre_scale_up, unsigned long freq) 604 604 { 605 605 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 606 606 struct ufs_clk_info *clki; 607 - unsigned long core_clk_rate = 0; 607 + unsigned long clk_freq = 0; 608 608 u32 core_clk_cycles_per_us; 609 609 610 610 /* ··· 617 615 if (host->hw_ver.major < 4 && !ufshcd_is_intr_aggr_allowed(hba)) 618 616 return 0; 619 617 618 + if (hba->use_pm_opp && freq != ULONG_MAX) { 619 + clk_freq = ufs_qcom_opp_freq_to_clk_freq(hba, freq, "core_clk"); 620 + if (clk_freq) 621 + goto cfg_timers; 622 + } 623 + 620 624 list_for_each_entry(clki, &hba->clk_list_head, list) { 621 625 if (!strcmp(clki->name, "core_clk")) { 626 + if (freq == ULONG_MAX) { 627 + clk_freq = clki->max_freq; 628 + break; 629 + } 630 + 622 631 if (is_pre_scale_up) 623 - core_clk_rate = clki->max_freq; 632 + clk_freq = clki->max_freq; 624 633 else 625 - core_clk_rate = clk_get_rate(clki->clk); 634 + clk_freq = clk_get_rate(clki->clk); 626 635 break; 627 636 } 628 637 629 638 } 630 639 640 + cfg_timers: 631 641 /* If frequency is smaller than 1MHz, set to 1MHz */ 632 - if (core_clk_rate < DEFAULT_CLK_RATE_HZ) 633 - core_clk_rate = DEFAULT_CLK_RATE_HZ; 642 + if (clk_freq < DEFAULT_CLK_RATE_HZ) 643 + clk_freq = DEFAULT_CLK_RATE_HZ; 634 644 635 - core_clk_cycles_per_us = core_clk_rate / USEC_PER_SEC; 645 + core_clk_cycles_per_us = clk_freq / USEC_PER_SEC; 636 646 if (ufshcd_readl(hba, REG_UFS_SYS1CLK_1US) != core_clk_cycles_per_us) { 637 647 ufshcd_writel(hba, core_clk_cycles_per_us, REG_UFS_SYS1CLK_1US); 638 648 /* ··· 664 650 665 651 switch (status) { 666 652 case PRE_CHANGE: 667 - if (ufs_qcom_cfg_timers(hba, false)) { 653 + if (ufs_qcom_cfg_timers(hba, false, ULONG_MAX)) { 668 654 dev_err(hba->dev, "%s: ufs_qcom_cfg_timers() failed\n", 669 655 __func__); 670 656 return -EINVAL; 671 657 } 672 658 673 - err = ufs_qcom_set_core_clk_ctrl(hba, ULONG_MAX); 659 + err = ufs_qcom_set_core_clk_ctrl(hba, true, ULONG_MAX); 674 660 if (err) 675 661 dev_err(hba->dev, "cfg core clk ctrl failed\n"); 676 662 /* ··· 942 928 943 929 break; 944 930 case POST_CHANGE: 945 - if (ufs_qcom_cfg_timers(hba, false)) { 946 - dev_err(hba->dev, "%s: ufs_qcom_cfg_timers() failed\n", 947 - __func__); 948 - /* 949 - * we return error code at the end of the routine, 950 - * but continue to configure UFS_PHY_TX_LANE_ENABLE 951 - * and bus voting as usual 952 - */ 953 - ret = -EINVAL; 954 - } 955 - 956 931 /* cache the power mode parameters to use internally */ 957 932 memcpy(&host->dev_req_params, 958 933 dev_req_params, sizeof(*dev_req_params)); ··· 1417 1414 return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_VS_CORE_CLK_40NS_CYCLES), reg); 1418 1415 } 1419 1416 1420 - static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq) 1417 + static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up, unsigned long freq) 1421 1418 { 1422 1419 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1423 1420 struct list_head *head = &hba->clk_list_head; 1424 1421 struct ufs_clk_info *clki; 1425 1422 u32 cycles_in_1us = 0; 1426 1423 u32 core_clk_ctrl_reg; 1424 + unsigned long clk_freq; 1427 1425 int err; 1426 + 1427 + if (hba->use_pm_opp && freq != ULONG_MAX) { 1428 + clk_freq = ufs_qcom_opp_freq_to_clk_freq(hba, freq, "core_clk_unipro"); 1429 + if (clk_freq) { 1430 + cycles_in_1us = ceil(clk_freq, HZ_PER_MHZ); 1431 + goto set_core_clk_ctrl; 1432 + } 1433 + } 1428 1434 1429 1435 list_for_each_entry(clki, head, list) { 1430 1436 if (!IS_ERR_OR_NULL(clki->clk) && 1431 1437 !strcmp(clki->name, "core_clk_unipro")) { 1432 - if (!clki->max_freq) 1438 + if (!clki->max_freq) { 1433 1439 cycles_in_1us = 150; /* default for backwards compatibility */ 1434 - else if (freq == ULONG_MAX) 1440 + break; 1441 + } 1442 + 1443 + if (freq == ULONG_MAX) { 1444 + cycles_in_1us = ceil(clki->max_freq, HZ_PER_MHZ); 1445 + break; 1446 + } 1447 + 1448 + if (is_scale_up) 1435 1449 cycles_in_1us = ceil(clki->max_freq, HZ_PER_MHZ); 1436 1450 else 1437 - cycles_in_1us = ceil(freq, HZ_PER_MHZ); 1438 - 1451 + cycles_in_1us = ceil(clk_get_rate(clki->clk), HZ_PER_MHZ); 1439 1452 break; 1440 1453 } 1441 1454 } 1442 1455 1456 + set_core_clk_ctrl: 1443 1457 err = ufshcd_dme_get(hba, 1444 1458 UIC_ARG_MIB(DME_VS_CORE_CLK_CTRL), 1445 1459 &core_clk_ctrl_reg); ··· 1493 1473 { 1494 1474 int ret; 1495 1475 1496 - ret = ufs_qcom_cfg_timers(hba, true); 1476 + ret = ufs_qcom_cfg_timers(hba, true, freq); 1497 1477 if (ret) { 1498 1478 dev_err(hba->dev, "%s ufs cfg timer failed\n", __func__); 1499 1479 return ret; 1500 1480 } 1501 1481 /* set unipro core clock attributes and clear clock divider */ 1502 - return ufs_qcom_set_core_clk_ctrl(hba, freq); 1482 + return ufs_qcom_set_core_clk_ctrl(hba, true, freq); 1503 1483 } 1504 1484 1505 1485 static int ufs_qcom_clk_scale_up_post_change(struct ufs_hba *hba) ··· 1530 1510 1531 1511 static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba, unsigned long freq) 1532 1512 { 1513 + int ret; 1514 + 1515 + ret = ufs_qcom_cfg_timers(hba, false, freq); 1516 + if (ret) { 1517 + dev_err(hba->dev, "%s: ufs_qcom_cfg_timers() failed\n", __func__); 1518 + return ret; 1519 + } 1533 1520 /* set unipro core clock attributes and clear clock divider */ 1534 - return ufs_qcom_set_core_clk_ctrl(hba, freq); 1521 + return ufs_qcom_set_core_clk_ctrl(hba, false, freq); 1535 1522 } 1536 1523 1537 1524 static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up, ··· 2119 2092 return 0; 2120 2093 } 2121 2094 2095 + static unsigned long ufs_qcom_opp_freq_to_clk_freq(struct ufs_hba *hba, 2096 + unsigned long freq, char *name) 2097 + { 2098 + struct ufs_clk_info *clki; 2099 + struct dev_pm_opp *opp; 2100 + unsigned long clk_freq; 2101 + int idx = 0; 2102 + bool found = false; 2103 + 2104 + opp = dev_pm_opp_find_freq_exact_indexed(hba->dev, freq, 0, true); 2105 + if (IS_ERR(opp)) { 2106 + dev_err(hba->dev, "Failed to find OPP for exact frequency %lu\n", freq); 2107 + return 0; 2108 + } 2109 + 2110 + list_for_each_entry(clki, &hba->clk_list_head, list) { 2111 + if (!strcmp(clki->name, name)) { 2112 + found = true; 2113 + break; 2114 + } 2115 + 2116 + idx++; 2117 + } 2118 + 2119 + if (!found) { 2120 + dev_err(hba->dev, "Failed to find clock '%s' in clk list\n", name); 2121 + dev_pm_opp_put(opp); 2122 + return 0; 2123 + } 2124 + 2125 + clk_freq = dev_pm_opp_get_freq_indexed(opp, idx); 2126 + 2127 + dev_pm_opp_put(opp); 2128 + 2129 + return clk_freq; 2130 + } 2131 + 2122 2132 static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq) 2123 2133 { 2124 - u32 gear = 0; 2134 + u32 gear = UFS_HS_DONT_CHANGE; 2135 + unsigned long unipro_freq; 2125 2136 2126 - switch (freq) { 2137 + if (!hba->use_pm_opp) 2138 + return gear; 2139 + 2140 + unipro_freq = ufs_qcom_opp_freq_to_clk_freq(hba, freq, "core_clk_unipro"); 2141 + switch (unipro_freq) { 2127 2142 case 403000000: 2128 2143 gear = UFS_HS_G5; 2129 2144 break; ··· 2185 2116 break; 2186 2117 default: 2187 2118 dev_err(hba->dev, "%s: Unsupported clock freq : %lu\n", __func__, freq); 2188 - break; 2119 + return UFS_HS_DONT_CHANGE; 2189 2120 } 2190 2121 2191 - return gear; 2122 + return min_t(u32, gear, hba->max_pwr_info.info.gear_rx); 2192 2123 } 2193 2124 2194 2125 /*