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:
"Updates to the usual drivers (ufs, mpi3mr, mpt3sas, lpfc, fnic,
hisi_sas, arcmsr, ) plus the usual assorted minor fixes and updates.

This time around there's only a single line update to the core, so
nothing major and barely anything minor"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (135 commits)
scsi: ufs: core: Simplify ufshcd_auto_hibern8_update()
scsi: ufs: core: Rename ufshcd_auto_hibern8_enable() and make it static
scsi: ufs: qcom: Fix ESI vector mask
scsi: ufs: host: Fix kernel-doc warning
scsi: hisi_sas: Correct the number of global debugfs registers
scsi: hisi_sas: Rollback some operations if FLR failed
scsi: hisi_sas: Check before using pointer variables
scsi: hisi_sas: Replace with standard error code return value
scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM
scsi: ufs: core: Add sysfs node for UFS RTC update
scsi: ufs: core: Add UFS RTC support
scsi: ufs: core: Add ufshcd_is_ufs_dev_busy()
scsi: ufs: qcom: Remove unused definitions
scsi: ufs: qcom: Use ufshcd_rmwl() where applicable
scsi: ufs: qcom: Remove support for host controllers older than v2.0
scsi: ufs: qcom: Simplify ufs_qcom_{assert/deassert}_reset
scsi: ufs: qcom: Initialize cycles_in_1us variable in ufs_qcom_set_core_clk_ctrl()
scsi: ufs: qcom: Sort includes alphabetically
scsi: ufs: qcom: Remove unused ufs_qcom_hosts struct array
scsi: ufs: qcom: Use dev_err_probe() to simplify error handling of devm_gpiod_get_optional()
...

+2578 -1741
+56
Documentation/ABI/testing/sysfs-driver-ufs
··· 1223 1223 1224 1224 The file is read only. 1225 1225 1226 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/lane 1227 + What: /sys/bus/platform/devices/*.ufs/power_info/lane 1228 + Date: September 2023 1229 + Contact: Can Guo <quic_cang@quicinc.com> 1230 + Description: This file shows how many lanes are enabled on the UFS link, 1231 + i.e., an output 2 means UFS link is operating with 2 lanes. 1232 + 1233 + The file is read only. 1234 + 1235 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/mode 1236 + What: /sys/bus/platform/devices/*.ufs/power_info/mode 1237 + Date: September 2023 1238 + Contact: Can Guo <quic_cang@quicinc.com> 1239 + Description: This file shows the PA power mode of UFS. 1240 + 1241 + The file is read only. 1242 + 1243 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/rate 1244 + What: /sys/bus/platform/devices/*.ufs/power_info/rate 1245 + Date: September 2023 1246 + Contact: Can Guo <quic_cang@quicinc.com> 1247 + Description: This file shows the speed rate of UFS link. 1248 + 1249 + The file is read only. 1250 + 1251 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/gear 1252 + What: /sys/bus/platform/devices/*.ufs/power_info/gear 1253 + Date: September 2023 1254 + Contact: Can Guo <quic_cang@quicinc.com> 1255 + Description: This file shows the gear of UFS link. 1256 + 1257 + The file is read only. 1258 + 1259 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/dev_pm 1260 + What: /sys/bus/platform/devices/*.ufs/power_info/dev_pm 1261 + Date: September 2023 1262 + Contact: Can Guo <quic_cang@quicinc.com> 1263 + Description: This file shows the UFS device power mode. 1264 + 1265 + The file is read only. 1266 + 1267 + What: /sys/bus/platform/drivers/ufshcd/*/power_info/link_state 1268 + What: /sys/bus/platform/devices/*.ufs/power_info/link_state 1269 + Date: September 2023 1270 + Contact: Can Guo <quic_cang@quicinc.com> 1271 + Description: This file shows the state of UFS link. 1272 + 1273 + The file is read only. 1274 + 1226 1275 What: /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_presv_us_en 1227 1276 What: /sys/bus/platform/devices/*.ufs/device_descriptor/wb_presv_us_en 1228 1277 Date: June 2020 ··· 1523 1474 1524 1475 The file is read only. 1525 1476 1477 + What: /sys/bus/platform/drivers/ufshcd/*/rtc_update_ms 1478 + What: /sys/bus/platform/devices/*.ufs/rtc_update_ms 1479 + Date: November 2023 1480 + Contact: Bean Huo <beanhuo@micron.com> 1481 + Description: 1482 + rtc_update_ms indicates how often the host should synchronize or update the 1483 + UFS RTC. If set to 0, this will disable UFS RTC periodic update.
+2
Documentation/devicetree/bindings/ufs/qcom,ufs.yaml
··· 27 27 - qcom,msm8996-ufshc 28 28 - qcom,msm8998-ufshc 29 29 - qcom,sa8775p-ufshc 30 + - qcom,sc7280-ufshc 30 31 - qcom,sc8280xp-ufshc 31 32 - qcom,sdm845-ufshc 32 33 - qcom,sm6115-ufshc ··· 119 118 enum: 120 119 - qcom,msm8998-ufshc 121 120 - qcom,sa8775p-ufshc 121 + - qcom,sc7280-ufshc 122 122 - qcom,sc8280xp-ufshc 123 123 - qcom,sm8250-ufshc 124 124 - qcom,sm8350-ufshc
+2
Documentation/devicetree/bindings/ufs/ufs-common.yaml
··· 87 87 description: 88 88 Specifies max. load that can be drawn from VCCQ2 supply. 89 89 90 + msi-parent: true 91 + 90 92 dependencies: 91 93 freq-table-hz: [ clocks ] 92 94 operating-points-v2: [ clocks, clock-names ]
+2 -1
MAINTAINERS
··· 22320 22320 F: drivers/ufs/host/ufs-exynos* 22321 22321 22322 22322 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER MEDIATEK HOOKS 22323 - M: Stanley Chu <stanley.chu@mediatek.com> 22323 + M: Peter Wang <peter.wang@mediatek.com> 22324 + R: Stanley Jhu <chu.stanley@gmail.com> 22324 22325 L: linux-scsi@vger.kernel.org 22325 22326 L: linux-mediatek@lists.infradead.org (moderated for non-subscribers) 22326 22327 S: Maintained
+13 -2
drivers/s390/scsi/zfcp_fc.c
··· 900 900 zfcp_fc_ct_ns_init(&rspn_req->ct_hdr, FC_NS_RSPN_ID, 901 901 FC_SYMBOLIC_NAME_SIZE); 902 902 hton24(rspn_req->rspn.fr_fid.fp_fid, fc_host_port_id(shost)); 903 - len = strlcpy(rspn_req->rspn.fr_name, fc_host_symbolic_name(shost), 904 - FC_SYMBOLIC_NAME_SIZE); 903 + 904 + BUILD_BUG_ON(sizeof(rspn_req->name) != 905 + sizeof(fc_host_symbolic_name(shost))); 906 + BUILD_BUG_ON(sizeof(rspn_req->name) != 907 + type_max(typeof(rspn_req->rspn.fr_name_len)) + 1); 908 + len = strscpy(rspn_req->name, fc_host_symbolic_name(shost), 909 + sizeof(rspn_req->name)); 910 + /* 911 + * It should be impossible for this to truncate (see BUILD_BUG_ON() 912 + * above), but be robust anyway. 913 + */ 914 + if (WARN_ON(len < 0)) 915 + len = sizeof(rspn_req->name) - 1; 905 916 rspn_req->rspn.fr_name_len = len; 906 917 907 918 sg_init_one(&fc_req->sg_req, rspn_req, sizeof(*rspn_req));
+2 -1
drivers/scsi/3w-sas.c
··· 1326 1326 } 1327 1327 1328 1328 /* Load rest of compatibility struct */ 1329 - strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); 1329 + strscpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, 1330 + sizeof(tw_dev->tw_compat_info.driver_version)); 1330 1331 tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; 1331 1332 tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; 1332 1333 tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
+2 -3
drivers/scsi/a3000.c
··· 282 282 return error; 283 283 } 284 284 285 - static int __exit amiga_a3000_scsi_remove(struct platform_device *pdev) 285 + static void __exit amiga_a3000_scsi_remove(struct platform_device *pdev) 286 286 { 287 287 struct Scsi_Host *instance = platform_get_drvdata(pdev); 288 288 struct a3000_hostdata *hdata = shost_priv(instance); ··· 293 293 free_irq(IRQ_AMIGA_PORTS, instance); 294 294 scsi_host_put(instance); 295 295 release_mem_region(res->start, resource_size(res)); 296 - return 0; 297 296 } 298 297 299 298 static struct platform_driver amiga_a3000_scsi_driver = { 300 - .remove = __exit_p(amiga_a3000_scsi_remove), 299 + .remove_new = __exit_p(amiga_a3000_scsi_remove), 301 300 .driver = { 302 301 .name = "amiga-a3000-scsi", 303 302 },
+2 -3
drivers/scsi/a4000t.c
··· 95 95 return -ENODEV; 96 96 } 97 97 98 - static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev) 98 + static void __exit amiga_a4000t_scsi_remove(struct platform_device *pdev) 99 99 { 100 100 struct Scsi_Host *host = platform_get_drvdata(pdev); 101 101 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); ··· 106 106 kfree(hostdata); 107 107 free_irq(host->irq, host); 108 108 release_mem_region(res->start, resource_size(res)); 109 - return 0; 110 109 } 111 110 112 111 static struct platform_driver amiga_a4000t_scsi_driver = { 113 - .remove = __exit_p(amiga_a4000t_scsi_remove), 112 + .remove_new = __exit_p(amiga_a4000t_scsi_remove), 114 113 .driver = { 115 114 .name = "amiga-a4000t-scsi", 116 115 },
+3 -3
drivers/scsi/aic7xxx/aic7770_osm.c
··· 87 87 sprintf(buf, "ahc_eisa:%d", eisaBase >> 12); 88 88 name = kstrdup(buf, GFP_ATOMIC); 89 89 if (name == NULL) 90 - return (ENOMEM); 90 + return -ENOMEM; 91 91 ahc = ahc_alloc(&aic7xxx_driver_template, name); 92 92 if (ahc == NULL) 93 - return (ENOMEM); 93 + return -ENOMEM; 94 94 ahc->dev = dev; 95 95 error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data, 96 96 eisaBase); 97 97 if (error != 0) { 98 98 ahc->bsh.ioport = 0; 99 99 ahc_free(ahc); 100 - return (error); 100 + return error < 0 ? error : -error; 101 101 } 102 102 103 103 dev_set_drvdata(dev, ahc);
+1 -1
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 1085 1085 template->name = ahc->description; 1086 1086 host = scsi_host_alloc(template, sizeof(struct ahc_softc *)); 1087 1087 if (host == NULL) 1088 - return (ENOMEM); 1088 + return -ENOMEM; 1089 1089 1090 1090 *((struct ahc_softc **)host->hostdata) = ahc; 1091 1091 ahc->platform_data->host = host;
+1 -2
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
··· 241 241 ahc_linux_pci_inherit_flags(ahc); 242 242 243 243 pci_set_drvdata(pdev, ahc); 244 - ahc_linux_register_host(ahc, &aic7xxx_driver_template); 245 - return (0); 244 + return ahc_linux_register_host(ahc, &aic7xxx_driver_template); 246 245 } 247 246 248 247 /******************************* PCI Routines *********************************/
+28 -1
drivers/scsi/arcmsr/arcmsr.h
··· 50 50 #define ARCMSR_MAX_OUTSTANDING_CMD 1024 51 51 #define ARCMSR_DEFAULT_OUTSTANDING_CMD 128 52 52 #define ARCMSR_MIN_OUTSTANDING_CMD 32 53 - #define ARCMSR_DRIVER_VERSION "v1.50.00.13-20230206" 53 + #define ARCMSR_DRIVER_VERSION "v1.51.00.14-20230915" 54 54 #define ARCMSR_SCSI_INITIATOR_ID 255 55 55 #define ARCMSR_MAX_XFER_SECTORS 512 56 56 #define ARCMSR_MAX_XFER_SECTORS_B 4096 ··· 78 78 #ifndef PCI_DEVICE_ID_ARECA_1203 79 79 #define PCI_DEVICE_ID_ARECA_1203 0x1203 80 80 #endif 81 + #ifndef PCI_DEVICE_ID_ARECA_1883 82 + #define PCI_DEVICE_ID_ARECA_1883 0x1883 83 + #endif 81 84 #ifndef PCI_DEVICE_ID_ARECA_1884 82 85 #define PCI_DEVICE_ID_ARECA_1884 0x1884 83 86 #endif 87 + #define PCI_DEVICE_ID_ARECA_1886_0 0x1886 84 88 #define PCI_DEVICE_ID_ARECA_1886 0x188A 85 89 #define ARCMSR_HOURS (1000 * 60 * 60 * 4) 86 90 #define ARCMSR_MINUTES (1000 * 60 * 60) ··· 822 818 uint16_t cmdLMID; // reserved (0) 823 819 uint16_t cmdFlag2; // reserved (0) 824 820 } DeliverQ, CompletionQ, *pDeliver_Q, *pCompletion_Q; 821 + 822 + #define ARCMSR_XOR_SEG_SIZE (1024 * 1024) 823 + struct HostRamBuf { 824 + uint32_t hrbSignature; // must be "HRBS" 825 + uint32_t hrbSize; // total sg size, be multiples of MB 826 + uint32_t hrbRes[2]; // reserved, must be set to 0 827 + }; 828 + struct Xor_sg { 829 + dma_addr_t xorPhys; 830 + uint64_t xorBufLen; 831 + }; 832 + struct XorHandle { 833 + dma_addr_t xorPhys; 834 + uint64_t xorBufLen; 835 + void *xorVirt; 836 + }; 837 + 825 838 /* 826 839 ******************************************************************************* 827 840 ** Adapter Control Block ··· 950 929 char firm_model[12]; 951 930 char firm_version[20]; 952 931 char device_map[20]; /*21,84-99*/ 932 + uint32_t firm_PicStatus; 953 933 struct work_struct arcmsr_do_message_isr_bh; 954 934 struct timer_list eternal_timer; 955 935 unsigned short fw_flag; ··· 959 937 #define FW_DEADLOCK 0x0010 960 938 uint32_t maxOutstanding; 961 939 int vector_count; 940 + int xor_mega; 962 941 uint32_t maxFreeCCB; 963 942 struct timer_list refresh_timer; 964 943 uint32_t doneq_index; ··· 969 946 uint32_t completionQ_entry; 970 947 pCompletion_Q pCompletionQ; 971 948 uint32_t completeQ_size; 949 + void *xorVirt; 950 + dma_addr_t xorPhys; 951 + unsigned int init2cfg_size; 952 + unsigned int xorVirtOffset; 972 953 };/* HW_DEVICE_EXTENSION */ 973 954 /* 974 955 *******************************************************************************
+95 -1
drivers/scsi/arcmsr/arcmsr_hba.c
··· 214 214 .driver_data = ACB_ADAPTER_TYPE_A}, 215 215 {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1880), 216 216 .driver_data = ACB_ADAPTER_TYPE_C}, 217 + {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1883), 218 + .driver_data = ACB_ADAPTER_TYPE_C}, 217 219 {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1884), 218 220 .driver_data = ACB_ADAPTER_TYPE_E}, 221 + {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1886_0), 222 + .driver_data = ACB_ADAPTER_TYPE_F}, 219 223 {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1886), 220 224 .driver_data = ACB_ADAPTER_TYPE_F}, 221 225 {0, 0}, /* Terminating entry */ ··· 751 747 return rtn; 752 748 } 753 749 750 + static int arcmsr_alloc_xor_buffer(struct AdapterControlBlock *acb) 751 + { 752 + int rc = 0; 753 + struct pci_dev *pdev = acb->pdev; 754 + void *dma_coherent; 755 + dma_addr_t dma_coherent_handle; 756 + int i, xor_ram; 757 + struct Xor_sg *pXorPhys; 758 + void **pXorVirt; 759 + struct HostRamBuf *pRamBuf; 760 + 761 + // allocate 1 MB * N physically continuous memory for XOR engine. 762 + xor_ram = (acb->firm_PicStatus >> 24) & 0x0f; 763 + acb->xor_mega = (xor_ram - 1) * 32 + 128 + 3; 764 + acb->init2cfg_size = sizeof(struct HostRamBuf) + 765 + (sizeof(struct XorHandle) * acb->xor_mega); 766 + dma_coherent = dma_alloc_coherent(&pdev->dev, acb->init2cfg_size, 767 + &dma_coherent_handle, GFP_KERNEL); 768 + acb->xorVirt = dma_coherent; 769 + acb->xorPhys = dma_coherent_handle; 770 + pXorPhys = (struct Xor_sg *)((unsigned long)dma_coherent + 771 + sizeof(struct HostRamBuf)); 772 + acb->xorVirtOffset = sizeof(struct HostRamBuf) + 773 + (sizeof(struct Xor_sg) * acb->xor_mega); 774 + pXorVirt = (void **)((unsigned long)dma_coherent + 775 + (unsigned long)acb->xorVirtOffset); 776 + for (i = 0; i < acb->xor_mega; i++) { 777 + dma_coherent = dma_alloc_coherent(&pdev->dev, 778 + ARCMSR_XOR_SEG_SIZE, 779 + &dma_coherent_handle, GFP_KERNEL); 780 + if (dma_coherent) { 781 + pXorPhys->xorPhys = dma_coherent_handle; 782 + pXorPhys->xorBufLen = ARCMSR_XOR_SEG_SIZE; 783 + *pXorVirt = dma_coherent; 784 + pXorPhys++; 785 + pXorVirt++; 786 + } else { 787 + pr_info("arcmsr%d: alloc max XOR buffer = 0x%x MB\n", 788 + acb->host->host_no, i); 789 + rc = -ENOMEM; 790 + break; 791 + } 792 + } 793 + pRamBuf = (struct HostRamBuf *)acb->xorVirt; 794 + pRamBuf->hrbSignature = 0x53425248; //HRBS 795 + pRamBuf->hrbSize = i * ARCMSR_XOR_SEG_SIZE; 796 + pRamBuf->hrbRes[0] = 0; 797 + pRamBuf->hrbRes[1] = 0; 798 + return rc; 799 + } 800 + 754 801 static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) 755 802 { 756 803 struct pci_dev *pdev = acb->pdev; ··· 891 836 acb->completionQ_entry = acb->ioqueue_size / sizeof(struct deliver_completeQ); 892 837 acb->doneq_index = 0; 893 838 break; 894 - } 839 + } 840 + if ((acb->firm_PicStatus >> 24) & 0x0f) { 841 + if (arcmsr_alloc_xor_buffer(acb)) 842 + return -ENOMEM; 843 + } 895 844 return 0; 896 845 } 897 846 ··· 2081 2022 2082 2023 static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb) 2083 2024 { 2025 + if (acb->xor_mega) { 2026 + struct Xor_sg *pXorPhys; 2027 + void **pXorVirt; 2028 + int i; 2029 + 2030 + pXorPhys = (struct Xor_sg *)(acb->xorVirt + 2031 + sizeof(struct HostRamBuf)); 2032 + pXorVirt = (void **)((unsigned long)acb->xorVirt + 2033 + (unsigned long)acb->xorVirtOffset); 2034 + for (i = 0; i < acb->xor_mega; i++) { 2035 + if (pXorPhys->xorPhys) { 2036 + dma_free_coherent(&acb->pdev->dev, 2037 + ARCMSR_XOR_SEG_SIZE, 2038 + *pXorVirt, pXorPhys->xorPhys); 2039 + pXorPhys->xorPhys = 0; 2040 + *pXorVirt = NULL; 2041 + } 2042 + pXorPhys++; 2043 + pXorVirt++; 2044 + } 2045 + dma_free_coherent(&acb->pdev->dev, acb->init2cfg_size, 2046 + acb->xorVirt, acb->xorPhys); 2047 + } 2084 2048 dma_free_coherent(&acb->pdev->dev, acb->uncache_size, acb->dma_coherent, acb->dma_coherent_handle); 2085 2049 } 2086 2050 ··· 3391 3309 pACB->firm_sdram_size = readl(&rwbuffer[3]); 3392 3310 pACB->firm_hd_channels = readl(&rwbuffer[4]); 3393 3311 pACB->firm_cfg_version = readl(&rwbuffer[25]); 3312 + if (pACB->adapter_type == ACB_ADAPTER_TYPE_F) 3313 + pACB->firm_PicStatus = readl(&rwbuffer[30]); 3314 + else 3315 + pACB->firm_PicStatus = 0; 3394 3316 pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", 3395 3317 pACB->host->host_no, 3396 3318 pACB->firm_model, ··· 4182 4096 acb->msgcode_rwbuffer[5] = lower_32_bits(acb->dma_coherent_handle2); 4183 4097 acb->msgcode_rwbuffer[6] = upper_32_bits(acb->dma_coherent_handle2); 4184 4098 acb->msgcode_rwbuffer[7] = acb->completeQ_size; 4099 + if (acb->xor_mega) { 4100 + acb->msgcode_rwbuffer[8] = 0x455AA; //Linux init 2 4101 + acb->msgcode_rwbuffer[9] = 0; 4102 + acb->msgcode_rwbuffer[10] = lower_32_bits(acb->xorPhys); 4103 + acb->msgcode_rwbuffer[11] = upper_32_bits(acb->xorPhys); 4104 + } 4185 4105 writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, &reg->inbound_msgaddr0); 4186 4106 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; 4187 4107 writel(acb->out_doorbell, &reg->iobound_doorbell); ··· 4798 4706 case PCI_DEVICE_ID_ARECA_1680: 4799 4707 case PCI_DEVICE_ID_ARECA_1681: 4800 4708 case PCI_DEVICE_ID_ARECA_1880: 4709 + case PCI_DEVICE_ID_ARECA_1883: 4801 4710 case PCI_DEVICE_ID_ARECA_1884: 4802 4711 type = "SAS/SATA"; 4803 4712 break; 4713 + case PCI_DEVICE_ID_ARECA_1886_0: 4804 4714 case PCI_DEVICE_ID_ARECA_1886: 4805 4715 type = "NVMe/SAS/SATA"; 4806 4716 break;
+2 -3
drivers/scsi/atari_scsi.c
··· 865 865 return error; 866 866 } 867 867 868 - static int __exit atari_scsi_remove(struct platform_device *pdev) 868 + static void __exit atari_scsi_remove(struct platform_device *pdev) 869 869 { 870 870 struct Scsi_Host *instance = platform_get_drvdata(pdev); 871 871 ··· 876 876 scsi_host_put(instance); 877 877 if (atari_dma_buffer) 878 878 atari_stram_free(atari_dma_buffer); 879 - return 0; 880 879 } 881 880 882 881 static struct platform_driver atari_scsi_driver = { 883 - .remove = __exit_p(atari_scsi_remove), 882 + .remove_new = __exit_p(atari_scsi_remove), 884 883 .driver = { 885 884 .name = DRV_MODULE_NAME, 886 885 },
+1 -1
drivers/scsi/bfa/bfad_bsg.c
··· 2550 2550 static void bfad_reset_sdev_bflags(struct bfad_im_port_s *im_port, 2551 2551 int lunmask_cfg) 2552 2552 { 2553 - const u32 scan_flags = BLIST_NOREPORTLUN | BLIST_SPARSELUN; 2553 + const blist_flags_t scan_flags = BLIST_NOREPORTLUN | BLIST_SPARSELUN; 2554 2554 struct bfad_itnim_s *itnim; 2555 2555 struct scsi_device *sdev; 2556 2556 unsigned long flags;
+7 -7
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 1734 1734 1735 1735 switch (pdev->device) { 1736 1736 case PCI_DEVICE_ID_NX2_57710: 1737 - strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN); 1737 + strscpy(hba->chip_num, "BCM57710", sizeof(hba->chip_num)); 1738 1738 break; 1739 1739 case PCI_DEVICE_ID_NX2_57711: 1740 - strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN); 1740 + strscpy(hba->chip_num, "BCM57711", sizeof(hba->chip_num)); 1741 1741 break; 1742 1742 case PCI_DEVICE_ID_NX2_57712: 1743 1743 case PCI_DEVICE_ID_NX2_57712_MF: 1744 1744 case PCI_DEVICE_ID_NX2_57712_VF: 1745 - strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN); 1745 + strscpy(hba->chip_num, "BCM57712", sizeof(hba->chip_num)); 1746 1746 break; 1747 1747 case PCI_DEVICE_ID_NX2_57800: 1748 1748 case PCI_DEVICE_ID_NX2_57800_MF: 1749 1749 case PCI_DEVICE_ID_NX2_57800_VF: 1750 - strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN); 1750 + strscpy(hba->chip_num, "BCM57800", sizeof(hba->chip_num)); 1751 1751 break; 1752 1752 case PCI_DEVICE_ID_NX2_57810: 1753 1753 case PCI_DEVICE_ID_NX2_57810_MF: 1754 1754 case PCI_DEVICE_ID_NX2_57810_VF: 1755 - strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN); 1755 + strscpy(hba->chip_num, "BCM57810", sizeof(hba->chip_num)); 1756 1756 break; 1757 1757 case PCI_DEVICE_ID_NX2_57840: 1758 1758 case PCI_DEVICE_ID_NX2_57840_MF: 1759 1759 case PCI_DEVICE_ID_NX2_57840_VF: 1760 1760 case PCI_DEVICE_ID_NX2_57840_2_20: 1761 1761 case PCI_DEVICE_ID_NX2_57840_4_10: 1762 - strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN); 1762 + strscpy(hba->chip_num, "BCM57840", sizeof(hba->chip_num)); 1763 1763 break; 1764 1764 default: 1765 1765 pr_err(PFX "Unknown device id 0x%x\n", pdev->device); ··· 1797 1797 if (!stats_addr) 1798 1798 return -EINVAL; 1799 1799 1800 - strncpy(stats_addr->version, BNX2FC_VERSION, 1800 + strscpy(stats_addr->version, BNX2FC_VERSION, 1801 1801 sizeof(stats_addr->version)); 1802 1802 stats_addr->txq_size = BNX2FC_SQ_WQES_MAX; 1803 1803 stats_addr->rxq_size = BNX2FC_CQ_WQES_MAX;
+2 -4
drivers/scsi/bvme6000_scsi.c
··· 89 89 return -ENODEV; 90 90 } 91 91 92 - static int 92 + static void 93 93 bvme6000_device_remove(struct platform_device *dev) 94 94 { 95 95 struct Scsi_Host *host = platform_get_drvdata(dev); ··· 99 99 NCR_700_release(host); 100 100 kfree(hostdata); 101 101 free_irq(host->irq, host); 102 - 103 - return 0; 104 102 } 105 103 106 104 static struct platform_driver bvme6000_scsi_driver = { ··· 106 108 .name = "bvme6000-scsi", 107 109 }, 108 110 .probe = bvme6000_probe, 109 - .remove = bvme6000_device_remove, 111 + .remove_new = bvme6000_device_remove, 110 112 }; 111 113 112 114 static int __init bvme6000_scsi_init(void)
+8 -4
drivers/scsi/ch.c
··· 659 659 memset(&vparams,0,sizeof(vparams)); 660 660 if (ch->counts[CHET_V1]) { 661 661 vparams.cvp_n1 = ch->counts[CHET_V1]; 662 - strncpy(vparams.cvp_label1,vendor_labels[0],16); 662 + strscpy(vparams.cvp_label1, vendor_labels[0], 663 + sizeof(vparams.cvp_label1)); 663 664 } 664 665 if (ch->counts[CHET_V2]) { 665 666 vparams.cvp_n2 = ch->counts[CHET_V2]; 666 - strncpy(vparams.cvp_label2,vendor_labels[1],16); 667 + strscpy(vparams.cvp_label2, vendor_labels[1], 668 + sizeof(vparams.cvp_label2)); 667 669 } 668 670 if (ch->counts[CHET_V3]) { 669 671 vparams.cvp_n3 = ch->counts[CHET_V3]; 670 - strncpy(vparams.cvp_label3,vendor_labels[2],16); 672 + strscpy(vparams.cvp_label3, vendor_labels[2], 673 + sizeof(vparams.cvp_label3)); 671 674 } 672 675 if (ch->counts[CHET_V4]) { 673 676 vparams.cvp_n4 = ch->counts[CHET_V4]; 674 - strncpy(vparams.cvp_label4,vendor_labels[3],16); 677 + strscpy(vparams.cvp_label4, vendor_labels[3], 678 + sizeof(vparams.cvp_label4)); 675 679 } 676 680 if (copy_to_user(argp, &vparams, sizeof(vparams))) 677 681 return -EFAULT;
+2 -1
drivers/scsi/csiostor/csio_init.c
··· 521 521 goto err; 522 522 523 523 hw->pdev = pdev; 524 - strncpy(hw->drv_version, CSIO_DRV_VERSION, 32); 524 + strscpy(hw->drv_version, CSIO_DRV_VERSION, 525 + sizeof(hw->drv_version)); 525 526 526 527 /* memory pool/DMA pool allocation */ 527 528 if (csio_resource_alloc(hw))
+1 -1
drivers/scsi/dc395x.c
··· 1366 1366 "command while another command (0x%p) is active.", 1367 1367 srb->cmd, 1368 1368 acb->active_dcb->active_srb ? 1369 - acb->active_dcb->active_srb->cmd : 0); 1369 + acb->active_dcb->active_srb->cmd : NULL); 1370 1370 return 1; 1371 1371 } 1372 1372 if (DC395x_read16(acb, TRM_S1040_SCSI_STATUS) & SCSIINTERRUPT) {
+6 -6
drivers/scsi/elx/libefc/efc_node.h
··· 26 26 struct efc_node *node = ctx->app; 27 27 28 28 if (evt == EFC_EVT_ENTER) { 29 - strncpy(node->current_state_name, handler, 30 - sizeof(node->current_state_name)); 29 + strscpy_pad(node->current_state_name, handler, 30 + sizeof(node->current_state_name)); 31 31 } else if (evt == EFC_EVT_EXIT) { 32 - strncpy(node->prev_state_name, node->current_state_name, 33 - sizeof(node->prev_state_name)); 34 - strncpy(node->current_state_name, "invalid", 35 - sizeof(node->current_state_name)); 32 + memcpy(node->prev_state_name, node->current_state_name, 33 + sizeof(node->prev_state_name)); 34 + strscpy_pad(node->current_state_name, "invalid", 35 + sizeof(node->current_state_name)); 36 36 } 37 37 node->prev_evt = node->current_evt; 38 38 node->current_evt = evt;
+4 -22
drivers/scsi/fcoe/fcoe_sysfs.c
··· 10 10 #include <linux/kernel.h> 11 11 #include <linux/etherdevice.h> 12 12 #include <linux/ctype.h> 13 + #include <linux/string.h> 13 14 14 15 #include <scsi/fcoe_sysfs.h> 15 16 #include <scsi/libfcoe.h> ··· 215 214 return table[table_key]; \ 216 215 } 217 216 218 - static char *fip_conn_type_names[] = { 217 + static const char * const fip_conn_type_names[] = { 219 218 [ FIP_CONN_TYPE_UNKNOWN ] = "Unknown", 220 219 [ FIP_CONN_TYPE_FABRIC ] = "Fabric", 221 220 [ FIP_CONN_TYPE_VN2VN ] = "VN2VN", 222 221 }; 223 222 fcoe_enum_name_search(ctlr_mode, fip_conn_type, fip_conn_type_names) 224 - 225 - static enum fip_conn_type fcoe_parse_mode(const char *buf) 226 - { 227 - int i; 228 - 229 - for (i = 0; i < ARRAY_SIZE(fip_conn_type_names); i++) { 230 - if (strcasecmp(buf, fip_conn_type_names[i]) == 0) 231 - return i; 232 - } 233 - 234 - return FIP_CONN_TYPE_UNKNOWN; 235 - } 236 223 237 224 static char *fcf_state_names[] = { 238 225 [ FCOE_FCF_STATE_UNKNOWN ] = "Unknown", ··· 263 274 const char *buf, size_t count) 264 275 { 265 276 struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); 266 - char mode[FCOE_MAX_MODENAME_LEN + 1]; 267 277 268 278 if (count > FCOE_MAX_MODENAME_LEN) 269 279 return -EINVAL; 270 280 271 - strncpy(mode, buf, count); 272 - 273 - if (mode[count - 1] == '\n') 274 - mode[count - 1] = '\0'; 275 - else 276 - mode[count] = '\0'; 277 281 278 282 switch (ctlr->enabled) { 279 283 case FCOE_CTLR_ENABLED: ··· 279 297 return -ENOTSUPP; 280 298 } 281 299 282 - ctlr->mode = fcoe_parse_mode(mode); 283 - if (ctlr->mode == FIP_CONN_TYPE_UNKNOWN) { 300 + ctlr->mode = sysfs_match_string(fip_conn_type_names, buf); 301 + if (ctlr->mode < 0 || ctlr->mode == FIP_CONN_TYPE_UNKNOWN) { 284 302 LIBFCOE_SYSFS_DBG(ctlr, "Unknown mode %s provided.\n", 285 303 buf); 286 304 return -EINVAL;
+45 -23
drivers/scsi/fnic/fnic.h
··· 27 27 28 28 #define DRV_NAME "fnic" 29 29 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver" 30 - #define DRV_VERSION "1.6.0.57" 30 + #define DRV_VERSION "1.7.0.0" 31 31 #define PFX DRV_NAME ": " 32 32 #define DFX DRV_NAME "%d: " 33 33 ··· 36 36 #define FNIC_MIN_IO_REQ 256 /* Min IO throttle count */ 37 37 #define FNIC_MAX_IO_REQ 1024 /* scsi_cmnd tag map entries */ 38 38 #define FNIC_DFLT_IO_REQ 256 /* Default scsi_cmnd tag map entries */ 39 - #define FNIC_IO_LOCKS 64 /* IO locks: power of 2 */ 40 39 #define FNIC_DFLT_QUEUE_DEPTH 256 41 40 #define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */ 42 41 ··· 108 109 #define FNIC_ABT_TERM_DELAY_TIMEOUT 500 /* mSec */ 109 110 110 111 #define FNIC_MAX_FCP_TARGET 256 111 - 112 + #define FNIC_PCI_OFFSET 2 112 113 /** 113 114 * state_flags to identify host state along along with fnic's state 114 115 **/ ··· 143 144 } while (0); \ 144 145 } while (0) 145 146 146 - #define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \ 147 + #define FNIC_MAIN_DBG(kern_level, host, fnic_num, fmt, args...) \ 147 148 FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \ 148 - shost_printk(kern_level, host, fmt, ##args);) 149 + shost_printk(kern_level, host, \ 150 + "fnic<%d>: %s: %d: " fmt, fnic_num,\ 151 + __func__, __LINE__, ##args);) 149 152 150 - #define FNIC_FCS_DBG(kern_level, host, fmt, args...) \ 153 + #define FNIC_FCS_DBG(kern_level, host, fnic_num, fmt, args...) \ 151 154 FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \ 152 - shost_printk(kern_level, host, fmt, ##args);) 155 + shost_printk(kern_level, host, \ 156 + "fnic<%d>: %s: %d: " fmt, fnic_num,\ 157 + __func__, __LINE__, ##args);) 153 158 154 - #define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \ 159 + #define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...) \ 155 160 FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \ 156 - shost_printk(kern_level, host, fmt, ##args);) 161 + shost_printk(kern_level, host, \ 162 + "fnic<%d>: %s: %d: " fmt, fnic_num,\ 163 + __func__, __LINE__, ##args);) 157 164 158 - #define FNIC_ISR_DBG(kern_level, host, fmt, args...) \ 165 + #define FNIC_ISR_DBG(kern_level, host, fnic_num, fmt, args...) \ 159 166 FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \ 160 - shost_printk(kern_level, host, fmt, ##args);) 167 + shost_printk(kern_level, host, \ 168 + "fnic<%d>: %s: %d: " fmt, fnic_num,\ 169 + __func__, __LINE__, ##args);) 161 170 162 171 #define FNIC_MAIN_NOTE(kern_level, host, fmt, args...) \ 163 172 shost_printk(kern_level, host, fmt, ##args) 173 + 174 + #define FNIC_WQ_COPY_MAX 64 175 + #define FNIC_WQ_MAX 1 176 + #define FNIC_RQ_MAX 1 177 + #define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX) 178 + #define FNIC_DFLT_IO_COMPLETIONS 256 179 + 180 + #define FNIC_MQ_CQ_INDEX 2 164 181 165 182 extern const char *fnic_state_str[]; 166 183 167 184 enum fnic_intx_intr_index { 168 185 FNIC_INTX_WQ_RQ_COPYWQ, 169 - FNIC_INTX_ERR, 186 + FNIC_INTX_DUMMY, 170 187 FNIC_INTX_NOTIFY, 188 + FNIC_INTX_ERR, 171 189 FNIC_INTX_INTR_MAX, 172 190 }; 173 191 ··· 192 176 FNIC_MSIX_RQ, 193 177 FNIC_MSIX_WQ, 194 178 FNIC_MSIX_WQ_COPY, 195 - FNIC_MSIX_ERR_NOTIFY, 179 + FNIC_MSIX_ERR_NOTIFY = FNIC_MSIX_WQ_COPY + FNIC_WQ_COPY_MAX, 196 180 FNIC_MSIX_INTR_MAX, 197 181 }; 198 182 ··· 201 185 char devname[IFNAMSIZ + 11]; 202 186 irqreturn_t (*isr)(int, void *); 203 187 void *devid; 188 + int irq_num; 204 189 }; 205 190 206 191 enum fnic_state { ··· 210 193 FNIC_IN_ETH_MODE, 211 194 FNIC_IN_ETH_TRANS_FC_MODE, 212 195 }; 213 - 214 - #define FNIC_WQ_COPY_MAX 1 215 - #define FNIC_WQ_MAX 1 216 - #define FNIC_RQ_MAX 1 217 - #define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX) 218 - #define FNIC_DFLT_IO_COMPLETIONS 256 219 196 220 197 struct mempool; 221 198 ··· 225 214 enum fnic_evt event; 226 215 }; 227 216 217 + struct fnic_cpy_wq { 218 + unsigned long hw_lock_flags; 219 + u16 active_ioreq_count; 220 + u16 ioreq_table_size; 221 + ____cacheline_aligned struct fnic_io_req **io_req_table; 222 + }; 223 + 228 224 /* Per-instance private data structure */ 229 225 struct fnic { 226 + int fnic_num; 230 227 struct fc_lport *lport; 231 228 struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */ 232 229 struct vnic_dev_bar bar0; ··· 301 282 struct fnic_host_tag *tags; 302 283 mempool_t *io_req_pool; 303 284 mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES]; 304 - spinlock_t io_req_lock[FNIC_IO_LOCKS]; /* locks for scsi cmnds */ 305 285 286 + unsigned int copy_wq_base; 306 287 struct work_struct link_work; 307 288 struct work_struct frame_work; 308 289 struct sk_buff_head frame_queue; ··· 321 302 /*** FIP related data members -- end ***/ 322 303 323 304 /* copy work queue cache line section */ 324 - ____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX]; 305 + ____cacheline_aligned struct vnic_wq_copy hw_copy_wq[FNIC_WQ_COPY_MAX]; 306 + ____cacheline_aligned struct fnic_cpy_wq sw_copy_wq[FNIC_WQ_COPY_MAX]; 307 + 325 308 /* completion queue cache line section */ 326 309 ____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX]; 327 310 ··· 351 330 352 331 void fnic_clear_intr_mode(struct fnic *fnic); 353 332 int fnic_set_intr_mode(struct fnic *fnic); 333 + int fnic_set_intr_mode_msix(struct fnic *fnic); 354 334 void fnic_free_intr(struct fnic *fnic); 355 335 int fnic_request_intr(struct fnic *fnic); 356 336 ··· 378 356 void fnic_scsi_abort_io(struct fc_lport *); 379 357 void fnic_empty_scsi_cleanup(struct fc_lport *); 380 358 void fnic_exch_mgr_reset(struct fc_lport *, u32, u32); 381 - int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int); 359 + int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index); 382 360 int fnic_wq_cmpl_handler(struct fnic *fnic, int); 383 361 int fnic_flogi_reg_handler(struct fnic *fnic, u32); 384 362 void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, ··· 386 364 int fnic_fw_reset_handler(struct fnic *fnic); 387 365 void fnic_terminate_rport_io(struct fc_rport *); 388 366 const char *fnic_state_to_str(unsigned int state); 389 - 367 + void fnic_mq_map_queues_cpus(struct Scsi_Host *host); 390 368 void fnic_log_q_error(struct fnic *fnic); 391 369 void fnic_handle_link_event(struct fnic *fnic); 392 370
+2 -1
drivers/scsi/fnic/fnic_debugfs.c
··· 52 52 fc_trc_flag->fnic_trace = 2; 53 53 fc_trc_flag->fc_trace = 3; 54 54 fc_trc_flag->fc_clear = 4; 55 + return 0; 55 56 } 56 57 57 - return 0; 58 + return -ENOMEM; 58 59 } 59 60 60 61 /*
+35 -28
drivers/scsi/fnic/fnic_fcs.c
··· 63 63 atomic64_set(&fnic->fnic_stats.misc_stats.current_port_speed, 64 64 new_port_speed); 65 65 if (old_port_speed != new_port_speed) 66 - FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, 67 - "Current vnic speed set to : %llu\n", 66 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 67 + "Current vnic speed set to: %llu\n", 68 68 new_port_speed); 69 69 70 70 switch (vnic_dev_port_speed(fnic->vdev)) { ··· 102 102 fnic_fc_trace_set_data(fnic->lport->host->host_no, 103 103 FNIC_FC_LE, "Link Status: DOWN->DOWN", 104 104 strlen("Link Status: DOWN->DOWN")); 105 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 106 + "down->down\n"); 105 107 } else { 106 108 if (old_link_down_cnt != fnic->link_down_cnt) { 107 109 /* UP -> DOWN -> UP */ ··· 115 113 "Link Status:UP_DOWN_UP", 116 114 strlen("Link_Status:UP_DOWN_UP") 117 115 ); 118 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 116 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 119 117 "link down\n"); 120 118 fcoe_ctlr_link_down(&fnic->ctlr); 121 119 if (fnic->config.flags & VFCF_FIP_CAPABLE) { ··· 130 128 fnic_fcoe_send_vlan_req(fnic); 131 129 return; 132 130 } 133 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 134 - "link up\n"); 131 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 132 + "up->down->up: Link up\n"); 135 133 fcoe_ctlr_link_up(&fnic->ctlr); 136 134 } else { 137 135 /* UP -> UP */ ··· 140 138 fnic->lport->host->host_no, FNIC_FC_LE, 141 139 "Link Status: UP_UP", 142 140 strlen("Link Status: UP_UP")); 141 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 142 + "up->up\n"); 143 143 } 144 144 } 145 145 } else if (fnic->link_status) { ··· 157 153 return; 158 154 } 159 155 160 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n"); 156 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 157 + "down->up: Link up\n"); 161 158 fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_LE, 162 159 "Link Status: DOWN_UP", strlen("Link Status: DOWN_UP")); 163 160 fcoe_ctlr_link_up(&fnic->ctlr); ··· 166 161 /* UP -> DOWN */ 167 162 fnic->lport->host_stats.link_failure_count++; 168 163 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 169 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link down\n"); 164 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 165 + "up->down: Link down\n"); 170 166 fnic_fc_trace_set_data( 171 167 fnic->lport->host->host_no, FNIC_FC_LE, 172 168 "Link Status: UP_DOWN", 173 169 strlen("Link Status: UP_DOWN")); 174 170 if (fnic->config.flags & VFCF_FIP_CAPABLE) { 175 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 171 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 176 172 "deleting fip-timer during link-down\n"); 177 173 del_timer_sync(&fnic->fip_timer); 178 174 } ··· 276 270 spin_lock_irqsave(&fnic->fnic_lock, flags); 277 271 break; 278 272 case FNIC_EVT_START_FCF_DISC: 279 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 273 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 280 274 "Start FCF Discovery\n"); 281 275 fnic_fcoe_start_fcf_disc(fnic); 282 276 break; 283 277 default: 284 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 278 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 285 279 "Unknown event 0x%x\n", fevt->event); 286 280 break; 287 281 } ··· 376 370 fnic->set_vlan(fnic, 0); 377 371 378 372 if (printk_ratelimit()) 379 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 373 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 380 374 "Sending VLAN request...\n"); 381 375 382 376 skb = dev_alloc_skb(sizeof(struct fip_vlan)); ··· 429 423 u64 sol_time; 430 424 unsigned long flags; 431 425 432 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 426 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 433 427 "Received VLAN response...\n"); 434 428 435 429 fiph = (struct fip_header *) skb->data; 436 430 437 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 431 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 438 432 "Received VLAN response... OP 0x%x SUB_OP 0x%x\n", 439 433 ntohs(fiph->fip_op), fiph->fip_subcode); 440 434 ··· 469 463 if (list_empty(&fnic->vlans)) { 470 464 /* retry from timer */ 471 465 atomic64_inc(&fnic_stats->vlan_stats.resp_withno_vlanID); 472 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 466 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 473 467 "No VLAN descriptors in FIP VLAN response\n"); 474 468 spin_unlock_irqrestore(&fnic->vlans_lock, flags); 475 469 goto out; ··· 727 721 new = ctl; 728 722 if (ether_addr_equal(data, new)) 729 723 return; 730 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "update_mac %pM\n", new); 724 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 725 + "update_mac %pM\n", new); 731 726 if (!is_zero_ether_addr(data) && !ether_addr_equal(data, ctl)) 732 727 vnic_dev_del_addr(fnic->vdev, data); 733 728 memcpy(data, new, ETH_ALEN); ··· 770 763 u8 *mac; 771 764 int ret; 772 765 773 - FNIC_FCS_DBG(KERN_DEBUG, lport->host, "set port_id %x fp %p\n", 774 - port_id, fp); 766 + FNIC_FCS_DBG(KERN_DEBUG, lport->host, fnic->fnic_num, 767 + "set port_id 0x%x fp 0x%p\n", 768 + port_id, fp); 775 769 776 770 /* 777 771 * If we're clearing the FC_ID, change to use the ctl_src_addr. ··· 798 790 if (fnic->state == FNIC_IN_ETH_MODE || fnic->state == FNIC_IN_FC_MODE) 799 791 fnic->state = FNIC_IN_ETH_TRANS_FC_MODE; 800 792 else { 801 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 802 - "Unexpected fnic state %s while" 803 - " processing flogi resp\n", 804 - fnic_state_to_str(fnic->state)); 793 + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 794 + "Unexpected fnic state: %s processing FLOGI response", 795 + fnic_state_to_str(fnic->state)); 805 796 spin_unlock_irq(&fnic->fnic_lock); 806 797 return; 807 798 } ··· 877 870 skb_trim(skb, bytes_written); 878 871 if (!fcs_ok) { 879 872 atomic64_inc(&fnic_stats->misc_stats.frame_errors); 880 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 873 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 881 874 "fcs error. dropping packet.\n"); 882 875 goto drop; 883 876 } ··· 893 886 894 887 if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) { 895 888 atomic64_inc(&fnic_stats->misc_stats.frame_errors); 896 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 889 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 897 890 "fnic rq_cmpl fcoe x%x fcsok x%x" 898 891 " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err" 899 892 " x%x\n", ··· 974 967 len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM; 975 968 skb = dev_alloc_skb(len); 976 969 if (!skb) { 977 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 970 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 978 971 "Unable to allocate RQ sk_buff\n"); 979 972 return -ENOMEM; 980 973 } ··· 1348 1341 } 1349 1342 1350 1343 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list); 1351 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 1344 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1352 1345 "fip_timer: vlan %d state %d sol_count %d\n", 1353 1346 vlan->vid, vlan->state, vlan->sol_count); 1354 1347 switch (vlan->state) { 1355 1348 case FIP_VLAN_USED: 1356 - FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 1349 + FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1357 1350 "FIP VLAN is selected for FC transaction\n"); 1358 1351 spin_unlock_irqrestore(&fnic->vlans_lock, flags); 1359 1352 break; ··· 1372 1365 * no response on this vlan, remove from the list. 1373 1366 * Try the next vlan 1374 1367 */ 1375 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 1368 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 1376 1369 "Dequeue this VLAN ID %d from list\n", 1377 1370 vlan->vid); 1378 1371 list_del(&vlan->list); ··· 1382 1375 /* we exhausted all vlans, restart vlan disc */ 1383 1376 spin_unlock_irqrestore(&fnic->vlans_lock, 1384 1377 flags); 1385 - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, 1378 + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 1386 1379 "fip_timer: vlan list empty, " 1387 1380 "trigger vlan disc\n"); 1388 1381 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
+124 -50
drivers/scsi/fnic/fnic_isr.c
··· 38 38 fnic_log_q_error(fnic); 39 39 } 40 40 41 + if (pba & (1 << FNIC_INTX_DUMMY)) { 42 + atomic64_inc(&fnic->fnic_stats.misc_stats.intx_dummy); 43 + vnic_intr_return_all_credits(&fnic->intr[FNIC_INTX_DUMMY]); 44 + } 45 + 41 46 if (pba & (1 << FNIC_INTX_WQ_RQ_COPYWQ)) { 42 - work_done += fnic_wq_copy_cmpl_handler(fnic, io_completions); 47 + work_done += fnic_wq_copy_cmpl_handler(fnic, io_completions, FNIC_MQ_CQ_INDEX); 43 48 work_done += fnic_wq_cmpl_handler(fnic, -1); 44 49 work_done += fnic_rq_cmpl_handler(fnic, -1); 45 50 ··· 65 60 fnic->fnic_stats.misc_stats.last_isr_time = jiffies; 66 61 atomic64_inc(&fnic->fnic_stats.misc_stats.isr_count); 67 62 68 - work_done += fnic_wq_copy_cmpl_handler(fnic, io_completions); 63 + work_done += fnic_wq_copy_cmpl_handler(fnic, io_completions, FNIC_MQ_CQ_INDEX); 69 64 work_done += fnic_wq_cmpl_handler(fnic, -1); 70 65 work_done += fnic_rq_cmpl_handler(fnic, -1); 71 66 ··· 114 109 { 115 110 struct fnic *fnic = data; 116 111 unsigned long wq_copy_work_done = 0; 112 + int i; 117 113 118 114 fnic->fnic_stats.misc_stats.last_isr_time = jiffies; 119 115 atomic64_inc(&fnic->fnic_stats.misc_stats.isr_count); 120 116 121 - wq_copy_work_done = fnic_wq_copy_cmpl_handler(fnic, io_completions); 122 - vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_WQ_COPY], 117 + i = irq - fnic->msix[0].irq_num; 118 + if (i >= fnic->wq_copy_count + fnic->copy_wq_base || 119 + i < 0 || fnic->msix[i].irq_num != irq) { 120 + for (i = fnic->copy_wq_base; i < fnic->wq_copy_count + fnic->copy_wq_base ; i++) { 121 + if (fnic->msix[i].irq_num == irq) 122 + break; 123 + } 124 + } 125 + 126 + wq_copy_work_done = fnic_wq_copy_cmpl_handler(fnic, io_completions, i); 127 + vnic_intr_return_credits(&fnic->intr[i], 123 128 wq_copy_work_done, 124 129 1 /* unmask intr */, 125 130 1 /* reset intr timer */); ··· 143 128 fnic->fnic_stats.misc_stats.last_isr_time = jiffies; 144 129 atomic64_inc(&fnic->fnic_stats.misc_stats.isr_count); 145 130 146 - vnic_intr_return_all_credits(&fnic->intr[FNIC_MSIX_ERR_NOTIFY]); 131 + vnic_intr_return_all_credits(&fnic->intr[fnic->err_intr_offset]); 147 132 fnic_log_q_error(fnic); 148 133 fnic_handle_link_event(fnic); 149 134 ··· 201 186 fnic->msix[FNIC_MSIX_WQ].isr = fnic_isr_msix_wq; 202 187 fnic->msix[FNIC_MSIX_WQ].devid = fnic; 203 188 204 - sprintf(fnic->msix[FNIC_MSIX_WQ_COPY].devname, 205 - "%.11s-scsi-wq", fnic->name); 206 - fnic->msix[FNIC_MSIX_WQ_COPY].isr = fnic_isr_msix_wq_copy; 207 - fnic->msix[FNIC_MSIX_WQ_COPY].devid = fnic; 189 + for (i = fnic->copy_wq_base; i < fnic->wq_copy_count + fnic->copy_wq_base; i++) { 190 + sprintf(fnic->msix[i].devname, 191 + "%.11s-scsi-wq-%d", fnic->name, i-FNIC_MSIX_WQ_COPY); 192 + fnic->msix[i].isr = fnic_isr_msix_wq_copy; 193 + fnic->msix[i].devid = fnic; 194 + } 208 195 209 - sprintf(fnic->msix[FNIC_MSIX_ERR_NOTIFY].devname, 196 + sprintf(fnic->msix[fnic->err_intr_offset].devname, 210 197 "%.11s-err-notify", fnic->name); 211 - fnic->msix[FNIC_MSIX_ERR_NOTIFY].isr = 198 + fnic->msix[fnic->err_intr_offset].isr = 212 199 fnic_isr_msix_err_notify; 213 - fnic->msix[FNIC_MSIX_ERR_NOTIFY].devid = fnic; 200 + fnic->msix[fnic->err_intr_offset].devid = fnic; 214 201 215 - for (i = 0; i < ARRAY_SIZE(fnic->msix); i++) { 216 - err = request_irq(pci_irq_vector(fnic->pdev, i), 217 - fnic->msix[i].isr, 0, 218 - fnic->msix[i].devname, 219 - fnic->msix[i].devid); 202 + for (i = 0; i < fnic->intr_count; i++) { 203 + fnic->msix[i].irq_num = pci_irq_vector(fnic->pdev, i); 204 + 205 + err = request_irq(fnic->msix[i].irq_num, 206 + fnic->msix[i].isr, 0, 207 + fnic->msix[i].devname, 208 + fnic->msix[i].devid); 220 209 if (err) { 221 - shost_printk(KERN_ERR, fnic->lport->host, 222 - "MSIX: request_irq" 223 - " failed %d\n", err); 210 + FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 211 + "request_irq failed with error: %d\n", 212 + err); 224 213 fnic_free_intr(fnic); 225 214 break; 226 215 } ··· 239 220 return err; 240 221 } 241 222 242 - int fnic_set_intr_mode(struct fnic *fnic) 223 + int fnic_set_intr_mode_msix(struct fnic *fnic) 243 224 { 244 225 unsigned int n = ARRAY_SIZE(fnic->rq); 245 226 unsigned int m = ARRAY_SIZE(fnic->wq); 246 - unsigned int o = ARRAY_SIZE(fnic->wq_copy); 227 + unsigned int o = ARRAY_SIZE(fnic->hw_copy_wq); 228 + unsigned int min_irqs = n + m + 1 + 1; /*rq, raw wq, wq, err*/ 229 + 230 + /* 231 + * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs 232 + * (last INTR is used for WQ/RQ errors and notification area) 233 + */ 234 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 235 + "rq-array size: %d wq-array size: %d copy-wq array size: %d\n", 236 + n, m, o); 237 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 238 + "rq_count: %d raw_wq_count: %d wq_copy_count: %d cq_count: %d\n", 239 + fnic->rq_count, fnic->raw_wq_count, 240 + fnic->wq_copy_count, fnic->cq_count); 241 + 242 + if (fnic->rq_count <= n && fnic->raw_wq_count <= m && 243 + fnic->wq_copy_count <= o) { 244 + int vec_count = 0; 245 + int vecs = fnic->rq_count + fnic->raw_wq_count + fnic->wq_copy_count + 1; 246 + 247 + vec_count = pci_alloc_irq_vectors(fnic->pdev, min_irqs, vecs, 248 + PCI_IRQ_MSIX | PCI_IRQ_AFFINITY); 249 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 250 + "allocated %d MSI-X vectors\n", 251 + vec_count); 252 + 253 + if (vec_count > 0) { 254 + if (vec_count < vecs) { 255 + FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 256 + "interrupts number mismatch: vec_count: %d vecs: %d\n", 257 + vec_count, vecs); 258 + if (vec_count < min_irqs) { 259 + FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 260 + "no interrupts for copy wq\n"); 261 + return 1; 262 + } 263 + } 264 + 265 + fnic->rq_count = n; 266 + fnic->raw_wq_count = m; 267 + fnic->copy_wq_base = fnic->rq_count + fnic->raw_wq_count; 268 + fnic->wq_copy_count = vec_count - n - m - 1; 269 + fnic->wq_count = fnic->raw_wq_count + fnic->wq_copy_count; 270 + if (fnic->cq_count != vec_count - 1) { 271 + FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 272 + "CQ count: %d does not match MSI-X vector count: %d\n", 273 + fnic->cq_count, vec_count); 274 + fnic->cq_count = vec_count - 1; 275 + } 276 + fnic->intr_count = vec_count; 277 + fnic->err_intr_offset = fnic->rq_count + fnic->wq_count; 278 + 279 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 280 + "rq_count: %d raw_wq_count: %d copy_wq_base: %d\n", 281 + fnic->rq_count, 282 + fnic->raw_wq_count, fnic->copy_wq_base); 283 + 284 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 285 + "wq_copy_count: %d wq_count: %d cq_count: %d\n", 286 + fnic->wq_copy_count, 287 + fnic->wq_count, fnic->cq_count); 288 + 289 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 290 + "intr_count: %d err_intr_offset: %u", 291 + fnic->intr_count, 292 + fnic->err_intr_offset); 293 + 294 + vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSIX); 295 + FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 296 + "fnic using MSI-X\n"); 297 + return 0; 298 + } 299 + } 300 + return 1; 301 + } 302 + 303 + int fnic_set_intr_mode(struct fnic *fnic) 304 + { 305 + int ret_status = 0; 247 306 248 307 /* 249 308 * Set interrupt mode (INTx, MSI, MSI-X) depending 250 309 * system capabilities. 251 310 * 252 311 * Try MSI-X first 253 - * 254 - * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs 255 - * (last INTR is used for WQ/RQ errors and notification area) 256 312 */ 257 - if (fnic->rq_count >= n && 258 - fnic->raw_wq_count >= m && 259 - fnic->wq_copy_count >= o && 260 - fnic->cq_count >= n + m + o) { 261 - int vecs = n + m + o + 1; 262 - 263 - if (pci_alloc_irq_vectors(fnic->pdev, vecs, vecs, 264 - PCI_IRQ_MSIX) == vecs) { 265 - fnic->rq_count = n; 266 - fnic->raw_wq_count = m; 267 - fnic->wq_copy_count = o; 268 - fnic->wq_count = m + o; 269 - fnic->cq_count = n + m + o; 270 - fnic->intr_count = vecs; 271 - fnic->err_intr_offset = FNIC_MSIX_ERR_NOTIFY; 272 - 273 - FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, 274 - "Using MSI-X Interrupts\n"); 275 - vnic_dev_set_intr_mode(fnic->vdev, 276 - VNIC_DEV_INTR_MODE_MSIX); 277 - return 0; 278 - } 279 - } 313 + ret_status = fnic_set_intr_mode_msix(fnic); 314 + if (ret_status == 0) 315 + return ret_status; 280 316 281 317 /* 282 318 * Next try MSI ··· 351 277 fnic->intr_count = 1; 352 278 fnic->err_intr_offset = 0; 353 279 354 - FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, 280 + FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 355 281 "Using MSI Interrupts\n"); 356 282 vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSI); 357 283 ··· 377 303 fnic->cq_count = 3; 378 304 fnic->intr_count = 3; 379 305 380 - FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, 306 + FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 381 307 "Using Legacy Interrupts\n"); 382 308 vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX); 383 309
+99 -45
drivers/scsi/fnic/fnic_main.c
··· 12 12 #include <linux/pci.h> 13 13 #include <linux/skbuff.h> 14 14 #include <linux/interrupt.h> 15 + #include <linux/irq.h> 15 16 #include <linux/spinlock.h> 16 17 #include <linux/workqueue.h> 17 18 #include <linux/if_ether.h> 19 + #include <linux/blk-mq-pci.h> 18 20 #include <scsi/fc/fc_fip.h> 19 21 #include <scsi/scsi_host.h> 20 22 #include <scsi/scsi_transport.h> ··· 41 39 static struct kmem_cache *fnic_io_req_cache; 42 40 static LIST_HEAD(fnic_list); 43 41 static DEFINE_SPINLOCK(fnic_list_lock); 42 + static DEFINE_IDA(fnic_ida); 44 43 45 44 /* Supported devices by fnic module */ 46 45 static struct pci_device_id fnic_id_table[] = { ··· 116 113 .shost_groups = fnic_host_groups, 117 114 .track_queue_depth = 1, 118 115 .cmd_size = sizeof(struct fnic_cmd_priv), 116 + .map_queues = fnic_mq_map_queues_cpus, 119 117 }; 120 118 121 119 static void ··· 213 209 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 214 210 215 211 if (ret) { 216 - FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, 212 + FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 217 213 "fnic: Get vnic stats failed" 218 214 " 0x%x", ret); 219 215 return stats; ··· 325 321 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 326 322 327 323 if (ret) { 328 - FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, 324 + FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 329 325 "fnic: Reset vnic stats failed" 330 326 " 0x%x", ret); 331 327 return; ··· 358 354 } 359 355 360 356 for (i = 0; i < fnic->wq_copy_count; i++) { 361 - error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status); 357 + error_status = ioread32(&fnic->hw_copy_wq[i].ctrl->error_status); 362 358 if (error_status) 363 359 shost_printk(KERN_ERR, fnic->lport->host, 364 360 "CWQ[%d] error_status" ··· 393 389 err = vnic_dev_notify_set(fnic->vdev, -1); 394 390 break; 395 391 case VNIC_DEV_INTR_MODE_MSIX: 396 - err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY); 392 + err = vnic_dev_notify_set(fnic->vdev, fnic->wq_copy_count + fnic->copy_wq_base); 397 393 break; 398 394 default: 399 395 shost_printk(KERN_ERR, fnic->lport->host, ··· 479 475 { 480 476 unsigned int i; 481 477 int err; 478 + int raw_wq_rq_counts; 482 479 483 480 vnic_dev_disable(fnic->vdev); 484 481 for (i = 0; i < fnic->intr_count; i++) ··· 496 491 return err; 497 492 } 498 493 for (i = 0; i < fnic->wq_copy_count; i++) { 499 - err = vnic_wq_copy_disable(&fnic->wq_copy[i]); 494 + err = vnic_wq_copy_disable(&fnic->hw_copy_wq[i]); 500 495 if (err) 501 496 return err; 497 + raw_wq_rq_counts = fnic->raw_wq_count + fnic->rq_count; 498 + fnic_wq_copy_cmpl_handler(fnic, -1, i + raw_wq_rq_counts); 502 499 } 503 500 504 501 /* Clean up completed IOs and FCS frames */ 505 - fnic_wq_copy_cmpl_handler(fnic, io_completions); 506 502 fnic_wq_cmpl_handler(fnic, -1); 507 503 fnic_rq_cmpl_handler(fnic, -1); 508 504 ··· 513 507 for (i = 0; i < fnic->rq_count; i++) 514 508 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); 515 509 for (i = 0; i < fnic->wq_copy_count; i++) 516 - vnic_wq_copy_clean(&fnic->wq_copy[i], 510 + vnic_wq_copy_clean(&fnic->hw_copy_wq[i], 517 511 fnic_wq_copy_cleanup_handler); 518 512 519 513 for (i = 0; i < fnic->cq_count; i++) ··· 566 560 host->max_cmd_len = FCOE_MAX_CMD_LEN; 567 561 568 562 host->nr_hw_queues = fnic->wq_copy_count; 569 - if (host->nr_hw_queues > 1) 570 - shost_printk(KERN_ERR, host, 571 - "fnic: blk-mq is not supported"); 572 - 573 - host->nr_hw_queues = fnic->wq_copy_count = 1; 574 563 575 564 shost_printk(KERN_INFO, host, 576 565 "fnic: can_queue: %d max_lun: %llu", ··· 578 577 return 0; 579 578 } 580 579 580 + void fnic_mq_map_queues_cpus(struct Scsi_Host *host) 581 + { 582 + struct fc_lport *lp = shost_priv(host); 583 + struct fnic *fnic = lport_priv(lp); 584 + struct pci_dev *l_pdev = fnic->pdev; 585 + int intr_mode = fnic->config.intr_mode; 586 + struct blk_mq_queue_map *qmap = &host->tag_set.map[HCTX_TYPE_DEFAULT]; 587 + 588 + if (intr_mode == VNIC_DEV_INTR_MODE_MSI || intr_mode == VNIC_DEV_INTR_MODE_INTX) { 589 + FNIC_MAIN_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 590 + "intr_mode is not msix\n"); 591 + return; 592 + } 593 + 594 + FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 595 + "qmap->nr_queues: %d\n", qmap->nr_queues); 596 + 597 + if (l_pdev == NULL) { 598 + FNIC_MAIN_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 599 + "l_pdev is null\n"); 600 + return; 601 + } 602 + 603 + blk_mq_pci_map_queues(qmap, l_pdev, FNIC_PCI_OFFSET); 604 + } 605 + 581 606 static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 582 607 { 583 608 struct Scsi_Host *host; 584 609 struct fc_lport *lp; 585 610 struct fnic *fnic; 586 611 mempool_t *pool; 587 - int err; 612 + int err = 0; 613 + int fnic_id = 0; 588 614 int i; 589 615 unsigned long flags; 616 + int hwq; 590 617 591 618 /* 592 619 * Allocate SCSI Host and set up association between host, ··· 626 597 err = -ENOMEM; 627 598 goto err_out; 628 599 } 600 + 629 601 host = lp->host; 630 602 fnic = lport_priv(lp); 603 + 604 + fnic_id = ida_alloc(&fnic_ida, GFP_KERNEL); 605 + if (fnic_id < 0) { 606 + pr_err("Unable to alloc fnic ID\n"); 607 + err = fnic_id; 608 + goto err_out_ida_alloc; 609 + } 631 610 fnic->lport = lp; 632 611 fnic->ctlr.lp = lp; 633 - 634 612 fnic->link_events = 0; 613 + fnic->pdev = pdev; 635 614 636 615 snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, 637 616 host->host_no); 638 617 639 618 host->transportt = fnic_fc_transport; 640 - 619 + fnic->fnic_num = fnic_id; 641 620 fnic_stats_debugfs_init(fnic); 642 - 643 - /* Setup PCI resources */ 644 - pci_set_drvdata(pdev, fnic); 645 - 646 - fnic->pdev = pdev; 647 621 648 622 err = pci_enable_device(pdev); 649 623 if (err) { ··· 749 717 goto err_out_dev_close; 750 718 } 751 719 752 - fnic_scsi_drv_init(fnic); 720 + /* Setup PCI resources */ 721 + pci_set_drvdata(pdev, fnic); 753 722 754 723 fnic_get_res_counts(fnic); 755 724 ··· 770 737 goto err_out_clear_intr; 771 738 } 772 739 740 + fnic_scsi_drv_init(fnic); 741 + 742 + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) { 743 + fnic->sw_copy_wq[hwq].ioreq_table_size = fnic->fnic_max_tag_id; 744 + fnic->sw_copy_wq[hwq].io_req_table = 745 + kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) * 746 + sizeof(struct fnic_io_req *), GFP_KERNEL); 747 + } 748 + shost_printk(KERN_INFO, fnic->lport->host, "fnic copy wqs: %d, Q0 ioreq table size: %d\n", 749 + fnic->wq_copy_count, fnic->sw_copy_wq[0].ioreq_table_size); 773 750 774 751 /* initialize all fnic locks */ 775 752 spin_lock_init(&fnic->fnic_lock); ··· 793 750 fnic->fw_ack_recd[i] = 0; 794 751 fnic->fw_ack_index[i] = -1; 795 752 } 796 - 797 - for (i = 0; i < FNIC_IO_LOCKS; i++) 798 - spin_lock_init(&fnic->io_req_lock[i]); 799 - 800 - spin_lock_init(&fnic->sgreset_lock); 801 753 802 754 err = -ENOMEM; 803 755 fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); ··· 861 823 862 824 /* allocate RQ buffers and post them to RQ*/ 863 825 for (i = 0; i < fnic->rq_count; i++) { 864 - vnic_rq_enable(&fnic->rq[i]); 865 826 err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); 866 827 if (err) { 867 828 shost_printk(KERN_ERR, fnic->lport->host, 868 829 "fnic_alloc_rq_frame can't alloc " 869 830 "frame\n"); 870 - goto err_out_free_rq_buf; 831 + goto err_out_rq_buf; 871 832 } 833 + } 834 + 835 + /* Enable all queues */ 836 + for (i = 0; i < fnic->raw_wq_count; i++) 837 + vnic_wq_enable(&fnic->wq[i]); 838 + for (i = 0; i < fnic->rq_count; i++) { 839 + if (!ioread32(&fnic->rq[i].ctrl->enable)) 840 + vnic_rq_enable(&fnic->rq[i]); 841 + } 842 + for (i = 0; i < fnic->wq_copy_count; i++) 843 + vnic_wq_copy_enable(&fnic->hw_copy_wq[i]); 844 + 845 + err = fnic_request_intr(fnic); 846 + if (err) { 847 + shost_printk(KERN_ERR, fnic->lport->host, 848 + "Unable to request irq.\n"); 849 + goto err_out_request_intr; 872 850 } 873 851 874 852 /* ··· 895 841 if (err) { 896 842 shost_printk(KERN_ERR, fnic->lport->host, 897 843 "fnic: scsi_add_host failed...exiting\n"); 898 - goto err_out_free_rq_buf; 844 + goto err_out_scsi_add_host; 899 845 } 846 + 900 847 901 848 /* Start local port initiatialization */ 902 849 ··· 922 867 if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, FCPIO_HOST_EXCH_RANGE_START, 923 868 FCPIO_HOST_EXCH_RANGE_END, NULL)) { 924 869 err = -ENOMEM; 925 - goto err_out_remove_scsi_host; 870 + goto err_out_fc_exch_mgr_alloc; 926 871 } 927 872 928 873 fc_lport_init_stats(lp); ··· 950 895 skb_queue_head_init(&fnic->frame_queue); 951 896 skb_queue_head_init(&fnic->tx_queue); 952 897 953 - /* Enable all queues */ 954 - for (i = 0; i < fnic->raw_wq_count; i++) 955 - vnic_wq_enable(&fnic->wq[i]); 956 - for (i = 0; i < fnic->wq_copy_count; i++) 957 - vnic_wq_copy_enable(&fnic->wq_copy[i]); 958 - 959 898 fc_fabric_login(lp); 960 - 961 - err = fnic_request_intr(fnic); 962 - if (err) { 963 - shost_printk(KERN_ERR, fnic->lport->host, 964 - "Unable to request irq.\n"); 965 - goto err_out_free_exch_mgr; 966 - } 967 899 968 900 vnic_dev_enable(fnic->vdev); 969 901 ··· 963 921 964 922 err_out_free_exch_mgr: 965 923 fc_exch_mgr_free(lp); 966 - err_out_remove_scsi_host: 924 + err_out_fc_exch_mgr_alloc: 967 925 fc_remove_host(lp->host); 968 926 scsi_remove_host(lp->host); 969 - err_out_free_rq_buf: 927 + err_out_scsi_add_host: 928 + fnic_free_intr(fnic); 929 + err_out_request_intr: 970 930 for (i = 0; i < fnic->rq_count; i++) 971 931 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); 932 + err_out_rq_buf: 972 933 vnic_dev_notify_unset(fnic->vdev); 973 934 err_out_free_max_pool: 974 935 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); ··· 980 935 err_out_free_ioreq_pool: 981 936 mempool_destroy(fnic->io_req_pool); 982 937 err_out_free_resources: 938 + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) 939 + kfree(fnic->sw_copy_wq[hwq].io_req_table); 983 940 fnic_free_vnic_resources(fnic); 984 941 err_out_clear_intr: 985 942 fnic_clear_intr_mode(fnic); ··· 998 951 pci_disable_device(pdev); 999 952 err_out_free_hba: 1000 953 fnic_stats_debugfs_remove(fnic); 954 + ida_free(&fnic_ida, fnic->fnic_num); 955 + err_out_ida_alloc: 1001 956 scsi_host_put(lp->host); 1002 957 err_out: 1003 958 return err; ··· 1010 961 struct fnic *fnic = pci_get_drvdata(pdev); 1011 962 struct fc_lport *lp = fnic->lport; 1012 963 unsigned long flags; 964 + int hwq; 1013 965 1014 966 /* 1015 967 * Mark state so that the workqueue thread stops forwarding ··· 1071 1021 1072 1022 fc_remove_host(fnic->lport->host); 1073 1023 scsi_remove_host(fnic->lport->host); 1024 + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) 1025 + kfree(fnic->sw_copy_wq[hwq].io_req_table); 1074 1026 fc_exch_mgr_free(fnic->lport); 1075 1027 vnic_dev_notify_unset(fnic->vdev); 1076 1028 fnic_free_intr(fnic); ··· 1083 1031 fnic_iounmap(fnic); 1084 1032 pci_release_regions(pdev); 1085 1033 pci_disable_device(pdev); 1034 + ida_free(&fnic_ida, fnic->fnic_num); 1086 1035 scsi_host_put(lp->host); 1087 1036 } 1088 1037 ··· 1221 1168 fnic_trace_free(); 1222 1169 fnic_fc_trace_free(); 1223 1170 fnic_debugfs_terminate(); 1171 + ida_destroy(&fnic_ida); 1224 1172 } 1225 1173 1226 1174 module_init(fnic_init_module);
+39 -9
drivers/scsi/fnic/fnic_res.c
··· 57 57 GET_CONFIG(port_down_timeout); 58 58 GET_CONFIG(port_down_io_retries); 59 59 GET_CONFIG(luns_per_tgt); 60 + GET_CONFIG(intr_mode); 61 + GET_CONFIG(wq_copy_count); 60 62 61 63 c->wq_enet_desc_count = 62 64 min_t(u32, VNIC_FNIC_WQ_DESCS_MAX, ··· 133 131 c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer); 134 132 c->intr_timer_type = c->intr_timer_type; 135 133 134 + /* for older firmware, GET_CONFIG will not return anything */ 135 + if (c->wq_copy_count == 0) 136 + c->wq_copy_count = 1; 137 + 138 + c->wq_copy_count = min_t(u16, FNIC_WQ_COPY_MAX, c->wq_copy_count); 139 + 136 140 shost_printk(KERN_INFO, fnic->lport->host, 137 141 "vNIC MAC addr %pM " 138 142 "wq/wq_copy/rq %d/%d/%d\n", ··· 169 161 shost_printk(KERN_INFO, fnic->lport->host, 170 162 "vNIC port dn io retries %d port dn timeout %d\n", 171 163 c->port_down_io_retries, c->port_down_timeout); 164 + shost_printk(KERN_INFO, fnic->lport->host, 165 + "vNIC wq_copy_count: %d\n", c->wq_copy_count); 166 + shost_printk(KERN_INFO, fnic->lport->host, 167 + "vNIC intr mode: %d\n", c->intr_mode); 172 168 173 169 return 0; 174 170 } ··· 199 187 void fnic_get_res_counts(struct fnic *fnic) 200 188 { 201 189 fnic->wq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_WQ); 202 - fnic->raw_wq_count = fnic->wq_count - 1; 203 - fnic->wq_copy_count = fnic->wq_count - fnic->raw_wq_count; 190 + fnic->raw_wq_count = 1; 191 + fnic->wq_copy_count = fnic->config.wq_copy_count; 204 192 fnic->rq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_RQ); 205 193 fnic->cq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_CQ); 206 194 fnic->intr_count = vnic_dev_get_res_count(fnic->vdev, 207 195 RES_TYPE_INTR_CTRL); 196 + 197 + shost_printk(KERN_INFO, fnic->lport->host, 198 + "vNIC fw resources wq_count: %d\n", fnic->wq_count); 199 + shost_printk(KERN_INFO, fnic->lport->host, 200 + "vNIC fw resources raw_wq_count: %d\n", fnic->raw_wq_count); 201 + shost_printk(KERN_INFO, fnic->lport->host, 202 + "vNIC fw resources wq_copy_count: %d\n", fnic->wq_copy_count); 203 + shost_printk(KERN_INFO, fnic->lport->host, 204 + "vNIC fw resources rq_count: %d\n", fnic->rq_count); 205 + shost_printk(KERN_INFO, fnic->lport->host, 206 + "vNIC fw resources cq_count: %d\n", fnic->cq_count); 207 + shost_printk(KERN_INFO, fnic->lport->host, 208 + "vNIC fw resources intr_count: %d\n", fnic->intr_count); 208 209 } 209 210 210 211 void fnic_free_vnic_resources(struct fnic *fnic) ··· 228 203 vnic_wq_free(&fnic->wq[i]); 229 204 230 205 for (i = 0; i < fnic->wq_copy_count; i++) 231 - vnic_wq_copy_free(&fnic->wq_copy[i]); 206 + vnic_wq_copy_free(&fnic->hw_copy_wq[i]); 232 207 233 208 for (i = 0; i < fnic->rq_count; i++) 234 209 vnic_rq_free(&fnic->rq[i]); ··· 259 234 intr_mode == VNIC_DEV_INTR_MODE_MSIX ? 260 235 "MSI-X" : "unknown"); 261 236 262 - shost_printk(KERN_INFO, fnic->lport->host, "vNIC resources avail: " 263 - "wq %d cp_wq %d raw_wq %d rq %d cq %d intr %d\n", 264 - fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count, 265 - fnic->rq_count, fnic->cq_count, fnic->intr_count); 237 + shost_printk(KERN_INFO, fnic->lport->host, 238 + "vNIC resources avail: wq %d cp_wq %d raw_wq %d rq %d", 239 + fnic->wq_count, fnic->wq_copy_count, 240 + fnic->raw_wq_count, fnic->rq_count); 241 + 242 + shost_printk(KERN_INFO, fnic->lport->host, 243 + "vNIC resources avail: cq %d intr %d cpy-wq desc count %d\n", 244 + fnic->cq_count, fnic->intr_count, 245 + fnic->config.wq_copy_desc_count); 266 246 267 247 /* Allocate Raw WQ used for FCS frames */ 268 248 for (i = 0; i < fnic->raw_wq_count; i++) { ··· 280 250 281 251 /* Allocate Copy WQs used for SCSI IOs */ 282 252 for (i = 0; i < fnic->wq_copy_count; i++) { 283 - err = vnic_wq_copy_alloc(fnic->vdev, &fnic->wq_copy[i], 253 + err = vnic_wq_copy_alloc(fnic->vdev, &fnic->hw_copy_wq[i], 284 254 (fnic->raw_wq_count + i), 285 255 fnic->config.wq_copy_desc_count, 286 256 sizeof(struct fcpio_host_req)); ··· 387 357 } 388 358 389 359 for (i = 0; i < fnic->wq_copy_count; i++) { 390 - vnic_wq_copy_init(&fnic->wq_copy[i], 360 + vnic_wq_copy_init(&fnic->hw_copy_wq[i], 391 361 0 /* cq_index 0 - always */, 392 362 error_interrupt_enable, 393 363 error_interrupt_offset);
+480 -390
drivers/scsi/fnic/fnic_scsi.c
··· 92 92 93 93 static void fnic_cleanup_io(struct fnic *fnic); 94 94 95 - static inline spinlock_t *fnic_io_lock_hash(struct fnic *fnic, 96 - struct scsi_cmnd *sc) 97 - { 98 - u32 hash = scsi_cmd_to_rq(sc)->tag & (FNIC_IO_LOCKS - 1); 99 - 100 - return &fnic->io_req_lock[hash]; 101 - } 102 - 103 - static inline spinlock_t *fnic_io_lock_tag(struct fnic *fnic, 104 - int tag) 105 - { 106 - return &fnic->io_req_lock[tag & (FNIC_IO_LOCKS - 1)]; 107 - } 108 - 109 95 /* 110 96 * Unmap the data buffer and sense buffer for an io_req, 111 97 * also unmap and free the device-private scatter/gather list. ··· 115 129 } 116 130 117 131 /* Free up Copy Wq descriptors. Called with copy_wq lock held */ 118 - static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq) 132 + static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq, unsigned int hwq) 119 133 { 120 134 /* if no Ack received from firmware, then nothing to clean */ 121 - if (!fnic->fw_ack_recd[0]) 135 + if (!fnic->fw_ack_recd[hwq]) 122 136 return 1; 123 137 124 138 /* 125 139 * Update desc_available count based on number of freed descriptors 126 140 * Account for wraparound 127 141 */ 128 - if (wq->to_clean_index <= fnic->fw_ack_index[0]) 129 - wq->ring.desc_avail += (fnic->fw_ack_index[0] 142 + if (wq->to_clean_index <= fnic->fw_ack_index[hwq]) 143 + wq->ring.desc_avail += (fnic->fw_ack_index[hwq] 130 144 - wq->to_clean_index + 1); 131 145 else 132 146 wq->ring.desc_avail += (wq->ring.desc_count 133 147 - wq->to_clean_index 134 - + fnic->fw_ack_index[0] + 1); 148 + + fnic->fw_ack_index[hwq] + 1); 135 149 136 150 /* 137 151 * just bump clean index to ack_index+1 accounting for wraparound ··· 139 153 * to_clean_index and fw_ack_index, both inclusive 140 154 */ 141 155 wq->to_clean_index = 142 - (fnic->fw_ack_index[0] + 1) % wq->ring.desc_count; 156 + (fnic->fw_ack_index[hwq] + 1) % wq->ring.desc_count; 143 157 144 158 /* we have processed the acks received so far */ 145 - fnic->fw_ack_recd[0] = 0; 159 + fnic->fw_ack_recd[hwq] = 0; 146 160 return 0; 147 161 } 148 162 ··· 156 170 unsigned long clearbits) 157 171 { 158 172 unsigned long flags = 0; 159 - unsigned long host_lock_flags = 0; 160 173 161 174 spin_lock_irqsave(&fnic->fnic_lock, flags); 162 - spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags); 163 175 164 176 if (clearbits) 165 177 fnic->state_flags &= ~st_flags; 166 178 else 167 179 fnic->state_flags |= st_flags; 168 180 169 - spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags); 170 181 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 171 182 172 183 return; ··· 176 193 */ 177 194 int fnic_fw_reset_handler(struct fnic *fnic) 178 195 { 179 - struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 196 + struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0]; 180 197 int ret = 0; 181 198 unsigned long flags; 182 199 ··· 193 210 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 194 211 195 212 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) 196 - free_wq_copy_descs(fnic, wq); 213 + free_wq_copy_descs(fnic, wq, 0); 197 214 198 215 if (!vnic_wq_copy_desc_avail(wq)) 199 216 ret = -EAGAIN; ··· 211 228 212 229 if (!ret) { 213 230 atomic64_inc(&fnic->fnic_stats.reset_stats.fw_resets); 214 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 215 - "Issued fw reset\n"); 231 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 232 + "Issued fw reset\n"); 216 233 } else { 217 234 fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET); 218 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 219 - "Failed to issue fw reset\n"); 235 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 236 + "Failed to issue fw reset\n"); 220 237 } 221 238 222 239 return ret; ··· 229 246 */ 230 247 int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id) 231 248 { 232 - struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 249 + struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0]; 233 250 enum fcpio_flogi_reg_format_type format; 234 251 struct fc_lport *lp = fnic->lport; 235 252 u8 gw_mac[ETH_ALEN]; ··· 239 256 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 240 257 241 258 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) 242 - free_wq_copy_descs(fnic, wq); 259 + free_wq_copy_descs(fnic, wq, 0); 243 260 244 261 if (!vnic_wq_copy_desc_avail(wq)) { 245 262 ret = -EAGAIN; ··· 259 276 fc_id, gw_mac, 260 277 fnic->data_src_addr, 261 278 lp->r_a_tov, lp->e_d_tov); 262 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 279 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 263 280 "FLOGI FIP reg issued fcid %x src %pM dest %pM\n", 264 281 fc_id, fnic->data_src_addr, gw_mac); 265 282 } else { 266 283 fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG, 267 284 format, fc_id, gw_mac); 268 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 269 - "FLOGI reg issued fcid %x map %d dest %pM\n", 270 - fc_id, fnic->ctlr.map_dest, gw_mac); 285 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 286 + "FLOGI reg issued fcid 0x%x map %d dest 0x%p\n", 287 + fc_id, fnic->ctlr.map_dest, gw_mac); 271 288 } 272 289 273 290 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); ··· 289 306 struct vnic_wq_copy *wq, 290 307 struct fnic_io_req *io_req, 291 308 struct scsi_cmnd *sc, 292 - int sg_count) 309 + int sg_count, 310 + uint32_t mqtag, 311 + uint16_t hwq) 293 312 { 294 313 struct scatterlist *sg; 295 314 struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); ··· 299 314 struct host_sg_desc *desc; 300 315 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; 301 316 unsigned int i; 302 - unsigned long intr_flags; 303 317 int flags; 304 318 u8 exch_flags; 305 319 struct scsi_lun fc_lun; ··· 338 354 int_to_scsilun(sc->device->lun, &fc_lun); 339 355 340 356 /* Enqueue the descriptor in the Copy WQ */ 341 - spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); 342 - 343 - if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) 344 - free_wq_copy_descs(fnic, wq); 357 + if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[hwq]) 358 + free_wq_copy_descs(fnic, wq, hwq); 345 359 346 360 if (unlikely(!vnic_wq_copy_desc_avail(wq))) { 347 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); 348 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 361 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 349 362 "fnic_queue_wq_copy_desc failure - no descriptors\n"); 350 363 atomic64_inc(&misc_stats->io_cpwq_alloc_failures); 351 364 return SCSI_MLQUEUE_HOST_BUSY; ··· 359 378 (rp->flags & FC_RP_FLAGS_RETRY)) 360 379 exch_flags |= FCPIO_ICMND_SRFLAG_RETRY; 361 380 362 - fnic_queue_wq_copy_desc_icmnd_16(wq, scsi_cmd_to_rq(sc)->tag, 381 + fnic_queue_wq_copy_desc_icmnd_16(wq, mqtag, 363 382 0, exch_flags, io_req->sgl_cnt, 364 383 SCSI_SENSE_BUFFERSIZE, 365 384 io_req->sgl_list_pa, ··· 380 399 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, 381 400 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); 382 401 383 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); 384 402 return 0; 385 403 } 386 404 387 - /* 388 - * fnic_queuecommand 389 - * Routine to send a scsi cdb 390 - * Called with host_lock held and interrupts disabled. 391 - */ 392 - static int fnic_queuecommand_lck(struct scsi_cmnd *sc) 405 + int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) 393 406 { 407 + struct request *const rq = scsi_cmd_to_rq(sc); 408 + uint32_t mqtag = 0; 394 409 void (*done)(struct scsi_cmnd *) = scsi_done; 395 - const int tag = scsi_cmd_to_rq(sc)->tag; 396 410 struct fc_lport *lp = shost_priv(sc->device->host); 397 411 struct fc_rport *rport; 398 412 struct fnic_io_req *io_req = NULL; 399 413 struct fnic *fnic = lport_priv(lp); 400 414 struct fnic_stats *fnic_stats = &fnic->fnic_stats; 401 415 struct vnic_wq_copy *wq; 402 - int ret; 416 + int ret = 1; 403 417 u64 cmd_trace; 404 418 int sg_count = 0; 405 419 unsigned long flags = 0; 406 420 unsigned long ptr; 407 - spinlock_t *io_lock = NULL; 408 421 int io_lock_acquired = 0; 409 422 struct fc_rport_libfc_priv *rp; 423 + uint16_t hwq = 0; 410 424 411 - if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) 412 - return SCSI_MLQUEUE_HOST_BUSY; 425 + mqtag = blk_mq_unique_tag(rq); 426 + spin_lock_irqsave(&fnic->fnic_lock, flags); 413 427 414 - if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) 428 + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) { 429 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 430 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 431 + "fnic IO blocked flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", 432 + fnic->state_flags); 415 433 return SCSI_MLQUEUE_HOST_BUSY; 434 + } 435 + 436 + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) { 437 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 438 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 439 + "fnic flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", 440 + fnic->state_flags); 441 + return SCSI_MLQUEUE_HOST_BUSY; 442 + } 416 443 417 444 rport = starget_to_rport(scsi_target(sc->device)); 418 445 if (!rport) { 419 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 446 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 447 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 420 448 "returning DID_NO_CONNECT for IO as rport is NULL\n"); 421 449 sc->result = DID_NO_CONNECT << 16; 422 450 done(sc); ··· 434 444 435 445 ret = fc_remote_port_chkready(rport); 436 446 if (ret) { 437 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 447 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 448 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 438 449 "rport is not ready\n"); 439 450 atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); 440 451 sc->result = ret; ··· 445 454 446 455 rp = rport->dd_data; 447 456 if (!rp || rp->rp_state == RPORT_ST_DELETE) { 448 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 457 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 458 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 449 459 "rport 0x%x removed, returning DID_NO_CONNECT\n", 450 460 rport->port_id); 451 461 ··· 457 465 } 458 466 459 467 if (rp->rp_state != RPORT_ST_READY) { 460 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 468 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 469 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 461 470 "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n", 462 471 rport->port_id, rp->rp_state); 463 472 ··· 467 474 return 0; 468 475 } 469 476 470 - if (lp->state != LPORT_ST_READY || !(lp->link_up)) 477 + if (lp->state != LPORT_ST_READY || !(lp->link_up)) { 478 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 479 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 480 + "state not ready: %d/link not up: %d Returning HOST_BUSY\n", 481 + lp->state, lp->link_up); 471 482 return SCSI_MLQUEUE_HOST_BUSY; 483 + } 472 484 473 485 atomic_inc(&fnic->in_flight); 474 486 475 - /* 476 - * Release host lock, use driver resource specific locks from here. 477 - * Don't re-enable interrupts in case they were disabled prior to the 478 - * caller disabling them. 479 - */ 480 - spin_unlock(lp->host->host_lock); 487 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 481 488 fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED; 482 489 fnic_priv(sc)->flags = FNIC_NO_FLAGS; 483 490 ··· 494 501 sg_count = scsi_dma_map(sc); 495 502 if (sg_count < 0) { 496 503 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 497 - tag, sc, 0, sc->cmnd[0], sg_count, fnic_priv(sc)->state); 504 + mqtag, sc, 0, sc->cmnd[0], sg_count, fnic_priv(sc)->state); 498 505 mempool_free(io_req, fnic->io_req_pool); 499 506 goto out; 500 507 } ··· 529 536 } 530 537 531 538 /* 532 - * Will acquire lock defore setting to IO initialized. 539 + * Will acquire lock before setting to IO initialized. 533 540 */ 534 - 535 - io_lock = fnic_io_lock_hash(fnic, sc); 536 - spin_lock_irqsave(io_lock, flags); 541 + hwq = blk_mq_unique_tag_to_hwq(mqtag); 542 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 537 543 538 544 /* initialize rest of io_req */ 539 545 io_lock_acquired = 1; ··· 541 549 fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; 542 550 fnic_priv(sc)->io_req = io_req; 543 551 fnic_priv(sc)->flags |= FNIC_IO_INITIALIZED; 552 + io_req->sc = sc; 553 + 554 + if (fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] != NULL) { 555 + WARN(1, "fnic<%d>: %s: hwq: %d tag 0x%x already exists\n", 556 + fnic->fnic_num, __func__, hwq, blk_mq_unique_tag_to_tag(mqtag)); 557 + return SCSI_MLQUEUE_HOST_BUSY; 558 + } 559 + 560 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] = io_req; 561 + io_req->tag = mqtag; 544 562 545 563 /* create copy wq desc and enqueue it */ 546 - wq = &fnic->wq_copy[0]; 547 - ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count); 564 + wq = &fnic->hw_copy_wq[hwq]; 565 + atomic64_inc(&fnic_stats->io_stats.ios[hwq]); 566 + ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count, mqtag, hwq); 548 567 if (ret) { 549 568 /* 550 569 * In case another thread cancelled the request, 551 570 * refetch the pointer under the lock. 552 571 */ 553 572 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 554 - tag, sc, 0, 0, 0, fnic_flags_and_state(sc)); 573 + mqtag, sc, 0, 0, 0, fnic_flags_and_state(sc)); 555 574 io_req = fnic_priv(sc)->io_req; 556 575 fnic_priv(sc)->io_req = NULL; 576 + if (io_req) 577 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] = NULL; 557 578 fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; 558 - spin_unlock_irqrestore(io_lock, flags); 579 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 559 580 if (io_req) { 560 581 fnic_release_ioreq_buf(fnic, io_req, sc); 561 582 mempool_free(io_req, fnic->io_req_pool); 562 583 } 563 584 atomic_dec(&fnic->in_flight); 564 - /* acquire host lock before returning to SCSI */ 565 - spin_lock(lp->host->host_lock); 566 585 return ret; 567 586 } else { 568 587 atomic64_inc(&fnic_stats->io_stats.active_ios); ··· 593 590 sc->cmnd[5]); 594 591 595 592 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 596 - tag, sc, io_req, sg_count, cmd_trace, 593 + mqtag, sc, io_req, sg_count, cmd_trace, 597 594 fnic_flags_and_state(sc)); 598 595 599 596 /* if only we issued IO, will we have the io lock */ 600 597 if (io_lock_acquired) 601 - spin_unlock_irqrestore(io_lock, flags); 598 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 602 599 603 600 atomic_dec(&fnic->in_flight); 604 - /* acquire host lock before returning to SCSI */ 605 - spin_lock(lp->host->host_lock); 606 601 return ret; 607 602 } 608 603 609 - DEF_SCSI_QCMD(fnic_queuecommand) 610 604 611 605 /* 612 606 * fnic_fcpio_fw_reset_cmpl_handler ··· 636 636 if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) { 637 637 /* Check status of reset completion */ 638 638 if (!hdr_status) { 639 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 640 - "reset cmpl success\n"); 639 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 640 + "reset cmpl success\n"); 641 641 /* Ready to send flogi out */ 642 642 fnic->state = FNIC_IN_ETH_MODE; 643 643 } else { 644 - FNIC_SCSI_DBG(KERN_DEBUG, 645 - fnic->lport->host, 646 - "fnic fw_reset : failed %s\n", 647 - fnic_fcpio_status_to_str(hdr_status)); 644 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 645 + "reset failed with header status: %s\n", 646 + fnic_fcpio_status_to_str(hdr_status)); 648 647 649 648 /* 650 649 * Unable to change to eth mode, cannot send out flogi ··· 656 657 ret = -1; 657 658 } 658 659 } else { 659 - FNIC_SCSI_DBG(KERN_DEBUG, 660 - fnic->lport->host, 661 - "Unexpected state %s while processing" 662 - " reset cmpl\n", fnic_state_to_str(fnic->state)); 660 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 661 + "Unexpected state while processing reset completion: %s\n", 662 + fnic_state_to_str(fnic->state)); 663 663 atomic64_inc(&reset_stats->fw_reset_failures); 664 664 ret = -1; 665 665 } ··· 709 711 710 712 /* Check flogi registration completion status */ 711 713 if (!hdr_status) { 712 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 714 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 713 715 "flog reg succeeded\n"); 714 716 fnic->state = FNIC_IN_FC_MODE; 715 717 } else { 716 718 FNIC_SCSI_DBG(KERN_DEBUG, 717 - fnic->lport->host, 719 + fnic->lport->host, fnic->fnic_num, 718 720 "fnic flogi reg :failed %s\n", 719 721 fnic_fcpio_status_to_str(hdr_status)); 720 722 fnic->state = FNIC_IN_ETH_MODE; 721 723 ret = -1; 722 724 } 723 725 } else { 724 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 726 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 725 727 "Unexpected fnic state %s while" 726 728 " processing flogi reg completion\n", 727 729 fnic_state_to_str(fnic->state)); ··· 778 780 u16 request_out = desc->u.ack.request_out; 779 781 unsigned long flags; 780 782 u64 *ox_id_tag = (u64 *)(void *)desc; 783 + unsigned int wq_index = cq_index; 781 784 782 785 /* mark the ack state */ 783 - wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count]; 784 - spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 786 + wq = &fnic->hw_copy_wq[cq_index]; 787 + spin_lock_irqsave(&fnic->wq_copy_lock[wq_index], flags); 785 788 786 789 fnic->fnic_stats.misc_stats.last_ack_time = jiffies; 787 790 if (is_ack_index_in_range(wq, request_out)) { 788 - fnic->fw_ack_index[0] = request_out; 789 - fnic->fw_ack_recd[0] = 1; 791 + fnic->fw_ack_index[wq_index] = request_out; 792 + fnic->fw_ack_recd[wq_index] = 1; 790 793 } else 791 794 atomic64_inc( 792 795 &fnic->fnic_stats.misc_stats.ack_index_out_of_range); 793 796 794 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); 797 + spin_unlock_irqrestore(&fnic->wq_copy_lock[wq_index], flags); 795 798 FNIC_TRACE(fnic_fcpio_ack_handler, 796 799 fnic->lport->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], 797 800 ox_id_tag[4], ox_id_tag[5]); ··· 802 803 * fnic_fcpio_icmnd_cmpl_handler 803 804 * Routine to handle icmnd completions 804 805 */ 805 - static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, 806 + static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_index, 806 807 struct fcpio_fw_req *desc) 807 808 { 808 809 u8 type; 809 810 u8 hdr_status; 810 - struct fcpio_tag tag; 811 + struct fcpio_tag ftag; 811 812 u32 id; 812 813 u64 xfer_len = 0; 813 814 struct fcpio_icmnd_cmpl *icmnd_cmpl; ··· 815 816 struct scsi_cmnd *sc; 816 817 struct fnic_stats *fnic_stats = &fnic->fnic_stats; 817 818 unsigned long flags; 818 - spinlock_t *io_lock; 819 819 u64 cmd_trace; 820 820 unsigned long start_time; 821 821 unsigned long io_duration_time; 822 + unsigned int hwq = 0; 823 + unsigned int mqtag = 0; 824 + unsigned int tag = 0; 822 825 823 826 /* Decode the cmpl description to get the io_req id */ 824 - fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); 825 - fcpio_tag_id_dec(&tag, &id); 827 + fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag); 828 + fcpio_tag_id_dec(&ftag, &id); 826 829 icmnd_cmpl = &desc->u.icmnd_cmpl; 827 830 828 - if (id >= fnic->fnic_max_tag_id) { 829 - shost_printk(KERN_ERR, fnic->lport->host, 830 - "Tag out of range tag %x hdr status = %s\n", 831 - id, fnic_fcpio_status_to_str(hdr_status)); 831 + mqtag = id; 832 + tag = blk_mq_unique_tag_to_tag(mqtag); 833 + hwq = blk_mq_unique_tag_to_hwq(mqtag); 834 + 835 + if (hwq != cq_index) { 836 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 837 + "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", 838 + hwq, mqtag, tag, cq_index); 839 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 840 + "hdr status: %s icmnd completion on the wrong queue\n", 841 + fnic_fcpio_status_to_str(hdr_status)); 842 + } 843 + 844 + if (tag >= fnic->fnic_max_tag_id) { 845 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 846 + "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", 847 + hwq, mqtag, tag, cq_index); 848 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 849 + "hdr status: %s Out of range tag\n", 850 + fnic_fcpio_status_to_str(hdr_status)); 832 851 return; 833 852 } 853 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 834 854 835 855 sc = scsi_host_find_tag(fnic->lport->host, id); 836 856 WARN_ON_ONCE(!sc); 837 857 if (!sc) { 838 858 atomic64_inc(&fnic_stats->io_stats.sc_null); 859 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 839 860 shost_printk(KERN_ERR, fnic->lport->host, 840 861 "icmnd_cmpl sc is null - " 841 862 "hdr status = %s tag = 0x%x desc = 0x%p\n", ··· 871 852 return; 872 853 } 873 854 874 - io_lock = fnic_io_lock_hash(fnic, sc); 875 - spin_lock_irqsave(io_lock, flags); 876 855 io_req = fnic_priv(sc)->io_req; 856 + if (fnic->sw_copy_wq[hwq].io_req_table[tag] != io_req) { 857 + WARN(1, "%s: %d: hwq: %d mqtag: 0x%x tag: 0x%x io_req tag mismatch\n", 858 + __func__, __LINE__, hwq, mqtag, tag); 859 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 860 + return; 861 + } 862 + 877 863 WARN_ON_ONCE(!io_req); 878 864 if (!io_req) { 879 865 atomic64_inc(&fnic_stats->io_stats.ioreq_null); 880 866 fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL; 881 - spin_unlock_irqrestore(io_lock, flags); 867 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 882 868 shost_printk(KERN_ERR, fnic->lport->host, 883 869 "icmnd_cmpl io_req is null - " 884 870 "hdr status = %s tag = 0x%x sc 0x%p\n", ··· 907 883 */ 908 884 fnic_priv(sc)->flags |= FNIC_IO_DONE; 909 885 fnic_priv(sc)->flags |= FNIC_IO_ABTS_PENDING; 910 - spin_unlock_irqrestore(io_lock, flags); 886 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 911 887 if(FCPIO_ABORTED == hdr_status) 912 888 fnic_priv(sc)->flags |= FNIC_IO_ABORTED; 913 889 914 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 890 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 915 891 "icmnd_cmpl abts pending " 916 892 "hdr status = %s tag = 0x%x sc = 0x%p " 917 893 "scsi_status = %x residual = %d\n", ··· 995 971 996 972 /* Break link with the SCSI command */ 997 973 fnic_priv(sc)->io_req = NULL; 974 + io_req->sc = NULL; 998 975 fnic_priv(sc)->flags |= FNIC_IO_DONE; 976 + fnic->sw_copy_wq[hwq].io_req_table[tag] = NULL; 977 + 978 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 999 979 1000 980 if (hdr_status != FCPIO_SUCCESS) { 1001 981 atomic64_inc(&fnic_stats->io_stats.io_failures); ··· 1033 1005 1034 1006 /* Call SCSI completion function to complete the IO */ 1035 1007 scsi_done(sc); 1036 - spin_unlock_irqrestore(io_lock, flags); 1037 1008 1038 1009 mempool_free(io_req, fnic->io_req_pool); 1039 1010 ··· 1069 1042 /* fnic_fcpio_itmf_cmpl_handler 1070 1043 * Routine to handle itmf completions 1071 1044 */ 1072 - static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, 1045 + static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_index, 1073 1046 struct fcpio_fw_req *desc) 1074 1047 { 1075 1048 u8 type; ··· 1083 1056 struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; 1084 1057 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; 1085 1058 unsigned long flags; 1086 - spinlock_t *io_lock; 1087 1059 unsigned long start_time; 1060 + unsigned int hwq = cq_index; 1061 + unsigned int mqtag; 1088 1062 unsigned int tag; 1089 1063 1090 1064 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag); 1091 1065 fcpio_tag_id_dec(&ftag, &id); 1092 1066 1093 - tag = id & FNIC_TAG_MASK; 1094 - if (tag == fnic->fnic_max_tag_id) { 1095 - if (!(id & FNIC_TAG_DEV_RST)) { 1096 - shost_printk(KERN_ERR, fnic->lport->host, 1097 - "Tag out of range id 0x%x hdr status = %s\n", 1098 - id, fnic_fcpio_status_to_str(hdr_status)); 1099 - return; 1100 - } 1101 - } else if (tag > fnic->fnic_max_tag_id) { 1102 - shost_printk(KERN_ERR, fnic->lport->host, 1103 - "Tag out of range tag 0x%x hdr status = %s\n", 1104 - tag, fnic_fcpio_status_to_str(hdr_status)); 1067 + mqtag = id & FNIC_TAG_MASK; 1068 + tag = blk_mq_unique_tag_to_tag(id & FNIC_TAG_MASK); 1069 + hwq = blk_mq_unique_tag_to_hwq(id & FNIC_TAG_MASK); 1070 + 1071 + if (hwq != cq_index) { 1072 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1073 + "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", 1074 + hwq, mqtag, tag, cq_index); 1075 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1076 + "hdr status: %s ITMF completion on the wrong queue\n", 1077 + fnic_fcpio_status_to_str(hdr_status)); 1078 + } 1079 + 1080 + if (tag > fnic->fnic_max_tag_id) { 1081 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1082 + "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", 1083 + hwq, mqtag, tag, cq_index); 1084 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1085 + "hdr status: %s Tag out of range\n", 1086 + fnic_fcpio_status_to_str(hdr_status)); 1087 + return; 1088 + } else if ((tag == fnic->fnic_max_tag_id) && !(id & FNIC_TAG_DEV_RST)) { 1089 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1090 + "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", 1091 + hwq, mqtag, tag, cq_index); 1092 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1093 + "hdr status: %s Tag out of range\n", 1094 + fnic_fcpio_status_to_str(hdr_status)); 1105 1095 return; 1106 1096 } 1107 1097 1108 - if ((tag == fnic->fnic_max_tag_id) && (id & FNIC_TAG_DEV_RST)) { 1109 - sc = fnic->sgreset_sc; 1110 - io_lock = &fnic->sgreset_lock; 1098 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1099 + 1100 + /* If it is sg3utils allocated SC then tag_id 1101 + * is max_tag_id and SC is retrieved from io_req 1102 + */ 1103 + if ((mqtag == fnic->fnic_max_tag_id) && (id & FNIC_TAG_DEV_RST)) { 1104 + io_req = fnic->sw_copy_wq[hwq].io_req_table[tag]; 1105 + if (io_req) 1106 + sc = io_req->sc; 1111 1107 } else { 1112 1108 sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK); 1113 - io_lock = fnic_io_lock_hash(fnic, sc); 1114 1109 } 1115 1110 1116 1111 WARN_ON_ONCE(!sc); 1117 1112 if (!sc) { 1118 1113 atomic64_inc(&fnic_stats->io_stats.sc_null); 1114 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1119 1115 shost_printk(KERN_ERR, fnic->lport->host, 1120 1116 "itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n", 1121 1117 fnic_fcpio_status_to_str(hdr_status), tag); 1122 1118 return; 1123 1119 } 1124 1120 1125 - spin_lock_irqsave(io_lock, flags); 1126 1121 io_req = fnic_priv(sc)->io_req; 1127 1122 WARN_ON_ONCE(!io_req); 1128 1123 if (!io_req) { 1129 1124 atomic64_inc(&fnic_stats->io_stats.ioreq_null); 1130 - spin_unlock_irqrestore(io_lock, flags); 1125 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1131 1126 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; 1132 1127 shost_printk(KERN_ERR, fnic->lport->host, 1133 1128 "itmf_cmpl io_req is null - " ··· 1162 1113 if ((id & FNIC_TAG_ABORT) && (id & FNIC_TAG_DEV_RST)) { 1163 1114 /* Abort and terminate completion of device reset req */ 1164 1115 /* REVISIT : Add asserts about various flags */ 1165 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1166 - "dev reset abts cmpl recd. id %x status %s\n", 1167 - id, fnic_fcpio_status_to_str(hdr_status)); 1116 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 1117 + "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Abt/term completion received\n", 1118 + hwq, mqtag, tag, 1119 + fnic_fcpio_status_to_str(hdr_status)); 1168 1120 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; 1169 1121 fnic_priv(sc)->abts_status = hdr_status; 1170 1122 fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; 1171 1123 if (io_req->abts_done) 1172 1124 complete(io_req->abts_done); 1173 - spin_unlock_irqrestore(io_lock, flags); 1125 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1174 1126 } else if (id & FNIC_TAG_ABORT) { 1175 1127 /* Completion of abort cmd */ 1128 + shost_printk(KERN_DEBUG, fnic->lport->host, 1129 + "hwq: %d mqtag: 0x%x tag: 0x%x Abort header status: %s\n", 1130 + hwq, mqtag, tag, 1131 + fnic_fcpio_status_to_str(hdr_status)); 1176 1132 switch (hdr_status) { 1177 1133 case FCPIO_SUCCESS: 1178 1134 break; ··· 1189 1135 &term_stats->terminate_fw_timeouts); 1190 1136 break; 1191 1137 case FCPIO_ITMF_REJECTED: 1192 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 1138 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 1193 1139 "abort reject recd. id %d\n", 1194 1140 (int)(id & FNIC_TAG_MASK)); 1195 1141 break; ··· 1210 1156 } 1211 1157 if (fnic_priv(sc)->state != FNIC_IOREQ_ABTS_PENDING) { 1212 1158 /* This is a late completion. Ignore it */ 1213 - spin_unlock_irqrestore(io_lock, flags); 1159 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1214 1160 return; 1215 1161 } 1216 1162 ··· 1224 1170 if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) 1225 1171 atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls); 1226 1172 1227 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1173 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1228 1174 "abts cmpl recd. id %d status %s\n", 1229 1175 (int)(id & FNIC_TAG_MASK), 1230 1176 fnic_fcpio_status_to_str(hdr_status)); ··· 1236 1182 */ 1237 1183 if (io_req->abts_done) { 1238 1184 complete(io_req->abts_done); 1239 - spin_unlock_irqrestore(io_lock, flags); 1185 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1186 + shost_printk(KERN_INFO, fnic->lport->host, 1187 + "hwq: %d mqtag: 0x%x tag: 0x%x Waking up abort thread\n", 1188 + hwq, mqtag, tag); 1240 1189 } else { 1241 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1242 - "abts cmpl, completing IO\n"); 1190 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1191 + "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Completing IO\n", 1192 + hwq, mqtag, 1193 + tag, fnic_fcpio_status_to_str(hdr_status)); 1243 1194 fnic_priv(sc)->io_req = NULL; 1244 1195 sc->result = (DID_ERROR << 16); 1245 - 1246 - spin_unlock_irqrestore(io_lock, flags); 1196 + fnic->sw_copy_wq[hwq].io_req_table[tag] = NULL; 1197 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1247 1198 1248 1199 fnic_release_ioreq_buf(fnic, io_req, sc); 1249 1200 mempool_free(io_req, fnic->io_req_pool); ··· 1272 1213 } 1273 1214 } else if (id & FNIC_TAG_DEV_RST) { 1274 1215 /* Completion of device reset */ 1216 + shost_printk(KERN_INFO, fnic->lport->host, 1217 + "hwq: %d mqtag: 0x%x tag: 0x%x DR hst: %s\n", 1218 + hwq, mqtag, 1219 + tag, fnic_fcpio_status_to_str(hdr_status)); 1275 1220 fnic_priv(sc)->lr_status = hdr_status; 1276 1221 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { 1277 - spin_unlock_irqrestore(io_lock, flags); 1222 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1278 1223 fnic_priv(sc)->flags |= FNIC_DEV_RST_ABTS_PENDING; 1279 1224 FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, 1280 1225 sc->device->host->host_no, id, sc, 1281 1226 jiffies_to_msecs(jiffies - start_time), 1282 1227 desc, 0, fnic_flags_and_state(sc)); 1283 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1284 - "Terminate pending " 1285 - "dev reset cmpl recd. id %d status %s\n", 1286 - (int)(id & FNIC_TAG_MASK), 1287 - fnic_fcpio_status_to_str(hdr_status)); 1228 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1229 + "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Terminate pending\n", 1230 + hwq, mqtag, 1231 + tag, fnic_fcpio_status_to_str(hdr_status)); 1288 1232 return; 1289 1233 } 1290 1234 if (fnic_priv(sc)->flags & FNIC_DEV_RST_TIMED_OUT) { 1291 1235 /* Need to wait for terminate completion */ 1292 - spin_unlock_irqrestore(io_lock, flags); 1236 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1293 1237 FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, 1294 1238 sc->device->host->host_no, id, sc, 1295 1239 jiffies_to_msecs(jiffies - start_time), 1296 1240 desc, 0, fnic_flags_and_state(sc)); 1297 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1241 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1298 1242 "dev reset cmpl recd after time out. " 1299 1243 "id %d status %s\n", 1300 1244 (int)(id & FNIC_TAG_MASK), ··· 1306 1244 } 1307 1245 fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; 1308 1246 fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; 1309 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1310 - "dev reset cmpl recd. id %d status %s\n", 1311 - (int)(id & FNIC_TAG_MASK), 1312 - fnic_fcpio_status_to_str(hdr_status)); 1247 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 1248 + "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s DR completion received\n", 1249 + hwq, mqtag, 1250 + tag, fnic_fcpio_status_to_str(hdr_status)); 1313 1251 if (io_req->dr_done) 1314 1252 complete(io_req->dr_done); 1315 - spin_unlock_irqrestore(io_lock, flags); 1253 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1316 1254 1317 1255 } else { 1318 1256 shost_printk(KERN_ERR, fnic->lport->host, 1319 - "Unexpected itmf io state %s tag %x\n", 1320 - fnic_ioreq_state_to_str(fnic_priv(sc)->state), id); 1321 - spin_unlock_irqrestore(io_lock, flags); 1257 + "%s: Unexpected itmf io state: hwq: %d tag 0x%x %s\n", 1258 + __func__, hwq, id, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); 1259 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1322 1260 } 1323 1261 1324 1262 } ··· 1345 1283 break; 1346 1284 } 1347 1285 1286 + cq_index -= fnic->copy_wq_base; 1287 + 1348 1288 switch (desc->hdr.type) { 1349 1289 case FCPIO_ACK: /* fw copied copy wq desc to its queue */ 1350 1290 fnic_fcpio_ack_handler(fnic, cq_index, desc); 1351 1291 break; 1352 1292 1353 1293 case FCPIO_ICMND_CMPL: /* fw completed a command */ 1354 - fnic_fcpio_icmnd_cmpl_handler(fnic, desc); 1294 + fnic_fcpio_icmnd_cmpl_handler(fnic, cq_index, desc); 1355 1295 break; 1356 1296 1357 1297 case FCPIO_ITMF_CMPL: /* fw completed itmf (abort cmd, lun reset)*/ 1358 - fnic_fcpio_itmf_cmpl_handler(fnic, desc); 1298 + fnic_fcpio_itmf_cmpl_handler(fnic, cq_index, desc); 1359 1299 break; 1360 1300 1361 1301 case FCPIO_FLOGI_REG_CMPL: /* fw completed flogi_reg */ ··· 1370 1306 break; 1371 1307 1372 1308 default: 1373 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1309 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1374 1310 "firmware completion type %d\n", 1375 1311 desc->hdr.type); 1376 1312 break; ··· 1383 1319 * fnic_wq_copy_cmpl_handler 1384 1320 * Routine to process wq copy 1385 1321 */ 1386 - int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do) 1322 + int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index) 1387 1323 { 1388 - unsigned int wq_work_done = 0; 1389 - unsigned int i, cq_index; 1390 1324 unsigned int cur_work_done; 1391 1325 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; 1392 1326 u64 start_jiffies = 0; ··· 1392 1330 u64 delta_jiffies = 0; 1393 1331 u64 delta_ms = 0; 1394 1332 1395 - for (i = 0; i < fnic->wq_copy_count; i++) { 1396 - cq_index = i + fnic->raw_wq_count + fnic->rq_count; 1397 - 1398 - start_jiffies = jiffies; 1399 - cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index], 1400 - fnic_fcpio_cmpl_handler, 1401 - copy_work_to_do); 1402 - end_jiffies = jiffies; 1403 - 1404 - wq_work_done += cur_work_done; 1405 - delta_jiffies = end_jiffies - start_jiffies; 1406 - if (delta_jiffies > 1407 - (u64) atomic64_read(&misc_stats->max_isr_jiffies)) { 1408 - atomic64_set(&misc_stats->max_isr_jiffies, 1409 - delta_jiffies); 1410 - delta_ms = jiffies_to_msecs(delta_jiffies); 1411 - atomic64_set(&misc_stats->max_isr_time_ms, delta_ms); 1412 - atomic64_set(&misc_stats->corr_work_done, 1413 - cur_work_done); 1414 - } 1333 + start_jiffies = jiffies; 1334 + cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index], 1335 + fnic_fcpio_cmpl_handler, 1336 + copy_work_to_do); 1337 + end_jiffies = jiffies; 1338 + delta_jiffies = end_jiffies - start_jiffies; 1339 + if (delta_jiffies > (u64) atomic64_read(&misc_stats->max_isr_jiffies)) { 1340 + atomic64_set(&misc_stats->max_isr_jiffies, delta_jiffies); 1341 + delta_ms = jiffies_to_msecs(delta_jiffies); 1342 + atomic64_set(&misc_stats->max_isr_time_ms, delta_ms); 1343 + atomic64_set(&misc_stats->corr_work_done, cur_work_done); 1415 1344 } 1416 - return wq_work_done; 1345 + 1346 + return cur_work_done; 1417 1347 } 1418 1348 1419 1349 static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) 1420 1350 { 1421 - const int tag = scsi_cmd_to_rq(sc)->tag; 1351 + struct request *const rq = scsi_cmd_to_rq(sc); 1422 1352 struct fnic *fnic = data; 1423 1353 struct fnic_io_req *io_req; 1424 1354 unsigned long flags = 0; 1425 - spinlock_t *io_lock; 1426 1355 unsigned long start_time = 0; 1427 1356 struct fnic_stats *fnic_stats = &fnic->fnic_stats; 1357 + uint16_t hwq = 0; 1358 + int tag; 1359 + int mqtag; 1428 1360 1429 - io_lock = fnic_io_lock_tag(fnic, tag); 1430 - spin_lock_irqsave(io_lock, flags); 1361 + mqtag = blk_mq_unique_tag(rq); 1362 + hwq = blk_mq_unique_tag_to_hwq(mqtag); 1363 + tag = blk_mq_unique_tag_to_tag(mqtag); 1364 + 1365 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1366 + 1367 + fnic->sw_copy_wq[hwq].io_req_table[tag] = NULL; 1431 1368 1432 1369 io_req = fnic_priv(sc)->io_req; 1370 + if (!io_req) { 1371 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1372 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1373 + "hwq: %d mqtag: 0x%x tag: 0x%x flags: 0x%x No ioreq. Returning\n", 1374 + hwq, mqtag, tag, fnic_priv(sc)->flags); 1375 + return true; 1376 + } 1377 + 1433 1378 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && 1434 1379 !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { 1435 1380 /* ··· 1448 1379 complete(io_req->dr_done); 1449 1380 else if (io_req && io_req->abts_done) 1450 1381 complete(io_req->abts_done); 1451 - spin_unlock_irqrestore(io_lock, flags); 1382 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1452 1383 return true; 1453 1384 } else if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { 1454 - spin_unlock_irqrestore(io_lock, flags); 1385 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1455 1386 return true; 1456 - } 1457 - if (!io_req) { 1458 - spin_unlock_irqrestore(io_lock, flags); 1459 - goto cleanup_scsi_cmd; 1460 1387 } 1461 1388 1462 1389 fnic_priv(sc)->io_req = NULL; 1463 - 1464 - spin_unlock_irqrestore(io_lock, flags); 1390 + io_req->sc = NULL; 1391 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1465 1392 1466 1393 /* 1467 1394 * If there is a scsi_cmnd associated with this io_req, then ··· 1467 1402 fnic_release_ioreq_buf(fnic, io_req, sc); 1468 1403 mempool_free(io_req, fnic->io_req_pool); 1469 1404 1470 - cleanup_scsi_cmd: 1471 1405 sc->result = DID_TRANSPORT_DISRUPTED << 16; 1472 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1473 - "fnic_cleanup_io: tag:0x%x : sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", 1474 - tag, sc, jiffies - start_time); 1406 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1407 + "mqtag:0x%x tag: 0x%x sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", 1408 + mqtag, tag, sc, (jiffies - start_time)); 1475 1409 1476 1410 if (atomic64_read(&fnic->io_cmpl_skip)) 1477 1411 atomic64_dec(&fnic->io_cmpl_skip); 1478 1412 else 1479 1413 atomic64_inc(&fnic_stats->io_stats.io_completions); 1480 - 1481 - /* Complete the command to SCSI */ 1482 - if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) 1483 - shost_printk(KERN_ERR, fnic->lport->host, 1484 - "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n", 1485 - tag, sc); 1486 1414 1487 1415 FNIC_TRACE(fnic_cleanup_io, 1488 1416 sc->device->host->host_no, tag, sc, ··· 1505 1447 struct fnic_io_req *io_req; 1506 1448 struct scsi_cmnd *sc; 1507 1449 unsigned long flags; 1508 - spinlock_t *io_lock; 1509 1450 unsigned long start_time = 0; 1451 + uint16_t hwq; 1510 1452 1511 1453 /* get the tag reference */ 1512 1454 fcpio_tag_id_dec(&desc->hdr.tag, &id); ··· 1519 1461 if (!sc) 1520 1462 return; 1521 1463 1522 - io_lock = fnic_io_lock_hash(fnic, sc); 1523 - spin_lock_irqsave(io_lock, flags); 1464 + hwq = blk_mq_unique_tag_to_hwq(id); 1465 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1524 1466 1525 1467 /* Get the IO context which this desc refers to */ 1526 1468 io_req = fnic_priv(sc)->io_req; ··· 1528 1470 /* fnic interrupts are turned off by now */ 1529 1471 1530 1472 if (!io_req) { 1531 - spin_unlock_irqrestore(io_lock, flags); 1473 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1532 1474 goto wq_copy_cleanup_scsi_cmd; 1533 1475 } 1534 1476 1535 1477 fnic_priv(sc)->io_req = NULL; 1478 + io_req->sc = NULL; 1479 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(id)] = NULL; 1536 1480 1537 - spin_unlock_irqrestore(io_lock, flags); 1481 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1538 1482 1539 1483 start_time = io_req->start_time; 1540 1484 fnic_release_ioreq_buf(fnic, io_req, sc); ··· 1544 1484 1545 1485 wq_copy_cleanup_scsi_cmd: 1546 1486 sc->result = DID_NO_CONNECT << 16; 1547 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" 1487 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "wq_copy_cleanup_handler:" 1548 1488 " DID_NO_CONNECT\n"); 1549 1489 1550 1490 FNIC_TRACE(fnic_wq_copy_cleanup_handler, ··· 1560 1500 1561 1501 static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, 1562 1502 u32 task_req, u8 *fc_lun, 1563 - struct fnic_io_req *io_req) 1503 + struct fnic_io_req *io_req, 1504 + unsigned int hwq) 1564 1505 { 1565 - struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 1566 - struct Scsi_Host *host = fnic->lport->host; 1506 + struct vnic_wq_copy *wq = &fnic->hw_copy_wq[hwq]; 1567 1507 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; 1568 1508 unsigned long flags; 1569 1509 1570 - spin_lock_irqsave(host->host_lock, flags); 1510 + spin_lock_irqsave(&fnic->fnic_lock, flags); 1571 1511 if (unlikely(fnic_chk_state_flags_locked(fnic, 1572 1512 FNIC_FLAGS_IO_BLOCKED))) { 1573 - spin_unlock_irqrestore(host->host_lock, flags); 1513 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 1574 1514 return 1; 1575 1515 } else 1576 1516 atomic_inc(&fnic->in_flight); 1577 - spin_unlock_irqrestore(host->host_lock, flags); 1517 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 1578 1518 1579 - spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 1519 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1580 1520 1581 - if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) 1582 - free_wq_copy_descs(fnic, wq); 1521 + if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[hwq]) 1522 + free_wq_copy_descs(fnic, wq, hwq); 1583 1523 1584 1524 if (!vnic_wq_copy_desc_avail(wq)) { 1585 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); 1525 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1586 1526 atomic_dec(&fnic->in_flight); 1587 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1527 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1588 1528 "fnic_queue_abort_io_req: failure: no descriptors\n"); 1589 1529 atomic64_inc(&misc_stats->abts_cpwq_alloc_failures); 1590 1530 return 1; ··· 1599 1539 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, 1600 1540 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); 1601 1541 1602 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); 1542 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1603 1543 atomic_dec(&fnic->in_flight); 1604 1544 1605 1545 return 0; ··· 1613 1553 1614 1554 static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) 1615 1555 { 1556 + struct request *const rq = scsi_cmd_to_rq(sc); 1616 1557 struct fnic_rport_abort_io_iter_data *iter_data = data; 1617 1558 struct fnic *fnic = iter_data->fnic; 1618 - int abt_tag = scsi_cmd_to_rq(sc)->tag; 1559 + int abt_tag = 0; 1619 1560 struct fnic_io_req *io_req; 1620 - spinlock_t *io_lock; 1621 1561 unsigned long flags; 1622 1562 struct reset_stats *reset_stats = &fnic->fnic_stats.reset_stats; 1623 1563 struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; 1624 1564 struct scsi_lun fc_lun; 1625 1565 enum fnic_ioreq_state old_ioreq_state; 1566 + uint16_t hwq = 0; 1626 1567 1627 - io_lock = fnic_io_lock_tag(fnic, abt_tag); 1628 - spin_lock_irqsave(io_lock, flags); 1568 + abt_tag = blk_mq_unique_tag(rq); 1569 + hwq = blk_mq_unique_tag_to_hwq(abt_tag); 1570 + 1571 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1629 1572 1630 1573 io_req = fnic_priv(sc)->io_req; 1631 1574 1632 1575 if (!io_req || io_req->port_id != iter_data->port_id) { 1633 - spin_unlock_irqrestore(io_lock, flags); 1576 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1634 1577 return true; 1635 1578 } 1636 1579 1637 1580 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && 1638 1581 !(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) { 1639 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1640 - "fnic_rport_exch_reset dev rst not pending sc 0x%p\n", 1641 - sc); 1642 - spin_unlock_irqrestore(io_lock, flags); 1582 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1583 + "hwq: %d abt_tag: 0x%x flags: 0x%x Device reset is not pending\n", 1584 + hwq, abt_tag, fnic_priv(sc)->flags); 1585 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1643 1586 return true; 1644 1587 } 1645 1588 ··· 1651 1588 * belongs to rport that went away 1652 1589 */ 1653 1590 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { 1654 - spin_unlock_irqrestore(io_lock, flags); 1591 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1655 1592 return true; 1656 1593 } 1657 1594 if (io_req->abts_done) { ··· 1675 1612 atomic64_inc(&reset_stats->device_reset_terminates); 1676 1613 abt_tag |= FNIC_TAG_DEV_RST; 1677 1614 } 1678 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1615 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1679 1616 "fnic_rport_exch_reset dev rst sc 0x%p\n", sc); 1680 1617 BUG_ON(io_req->abts_done); 1681 1618 1682 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1619 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1683 1620 "fnic_rport_reset_exch: Issuing abts\n"); 1684 1621 1685 - spin_unlock_irqrestore(io_lock, flags); 1622 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1686 1623 1687 1624 /* Now queue the abort command to firmware */ 1688 1625 int_to_scsilun(sc->device->lun, &fc_lun); 1689 1626 1690 1627 if (fnic_queue_abort_io_req(fnic, abt_tag, 1691 1628 FCPIO_ITMF_ABT_TASK_TERM, 1692 - fc_lun.scsi_lun, io_req)) { 1629 + fc_lun.scsi_lun, io_req, hwq)) { 1693 1630 /* 1694 1631 * Revert the cmd state back to old state, if 1695 1632 * it hasn't changed in between. This cmd will get 1696 1633 * aborted later by scsi_eh, or cleaned up during 1697 1634 * lun reset 1698 1635 */ 1699 - spin_lock_irqsave(io_lock, flags); 1636 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1637 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1638 + "hwq: %d abt_tag: 0x%x flags: 0x%x Queuing abort failed\n", 1639 + hwq, abt_tag, fnic_priv(sc)->flags); 1700 1640 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) 1701 1641 fnic_priv(sc)->state = old_ioreq_state; 1702 - spin_unlock_irqrestore(io_lock, flags); 1642 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1703 1643 } else { 1704 - spin_lock_irqsave(io_lock, flags); 1644 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1705 1645 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) 1706 1646 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; 1707 1647 else 1708 1648 fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; 1709 - spin_unlock_irqrestore(io_lock, flags); 1649 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1710 1650 atomic64_inc(&term_stats->terminates); 1711 1651 iter_data->term_cnt++; 1712 1652 } ··· 1726 1660 }; 1727 1661 1728 1662 FNIC_SCSI_DBG(KERN_DEBUG, 1729 - fnic->lport->host, 1663 + fnic->lport->host, fnic->fnic_num, 1730 1664 "fnic_rport_exch_reset called portid 0x%06x\n", 1731 1665 port_id); 1732 1666 ··· 1763 1697 return; 1764 1698 } 1765 1699 fnic = lport_priv(lport); 1766 - FNIC_SCSI_DBG(KERN_DEBUG, 1767 - fnic->lport->host, "fnic_terminate_rport_io called" 1768 - " wwpn 0x%llx, wwnn0x%llx, rport 0x%p, portid 0x%06x\n", 1700 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1701 + "wwpn 0x%llx, wwnn0x%llx, rport 0x%p, portid 0x%06x\n", 1769 1702 rport->port_name, rport->node_name, rport, 1770 1703 rport->port_id); 1771 1704 ··· 1786 1721 struct fnic *fnic; 1787 1722 struct fnic_io_req *io_req = NULL; 1788 1723 struct fc_rport *rport; 1789 - spinlock_t *io_lock; 1790 1724 unsigned long flags; 1791 1725 unsigned long start_time = 0; 1792 1726 int ret = SUCCESS; ··· 1795 1731 struct abort_stats *abts_stats; 1796 1732 struct terminate_stats *term_stats; 1797 1733 enum fnic_ioreq_state old_ioreq_state; 1798 - const int tag = rq->tag; 1734 + int mqtag; 1799 1735 unsigned long abt_issued_time; 1736 + uint16_t hwq = 0; 1737 + 1800 1738 DECLARE_COMPLETION_ONSTACK(tm_done); 1801 1739 1802 1740 /* Wait for rport to unblock */ ··· 1808 1742 lp = shost_priv(sc->device->host); 1809 1743 1810 1744 fnic = lport_priv(lp); 1745 + 1746 + spin_lock_irqsave(&fnic->fnic_lock, flags); 1811 1747 fnic_stats = &fnic->fnic_stats; 1812 1748 abts_stats = &fnic->fnic_stats.abts_stats; 1813 1749 term_stats = &fnic->fnic_stats.term_stats; 1814 1750 1815 1751 rport = starget_to_rport(scsi_target(sc->device)); 1816 - FNIC_SCSI_DBG(KERN_DEBUG, 1817 - fnic->lport->host, 1818 - "Abort Cmd called FCID 0x%x, LUN 0x%llx TAG %x flags %x\n", 1819 - rport->port_id, sc->device->lun, tag, fnic_priv(sc)->flags); 1752 + mqtag = blk_mq_unique_tag(rq); 1753 + hwq = blk_mq_unique_tag_to_hwq(mqtag); 1820 1754 1821 1755 fnic_priv(sc)->flags = FNIC_NO_FLAGS; 1822 1756 1823 1757 if (lp->state != LPORT_ST_READY || !(lp->link_up)) { 1824 1758 ret = FAILED; 1759 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 1825 1760 goto fnic_abort_cmd_end; 1826 1761 } 1827 1762 1763 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 1828 1764 /* 1829 1765 * Avoid a race between SCSI issuing the abort and the device 1830 1766 * completing the command. ··· 1839 1771 * 1840 1772 * .io_req will not be cleared except while holding io_req_lock. 1841 1773 */ 1842 - io_lock = fnic_io_lock_hash(fnic, sc); 1843 - spin_lock_irqsave(io_lock, flags); 1774 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1844 1775 io_req = fnic_priv(sc)->io_req; 1845 1776 if (!io_req) { 1846 - spin_unlock_irqrestore(io_lock, flags); 1777 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1847 1778 goto fnic_abort_cmd_end; 1848 1779 } 1849 1780 1850 1781 io_req->abts_done = &tm_done; 1851 1782 1852 1783 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { 1853 - spin_unlock_irqrestore(io_lock, flags); 1784 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1854 1785 goto wait_pending; 1855 1786 } 1856 1787 ··· 1869 1802 else 1870 1803 atomic64_inc(&abts_stats->abort_issued_greater_than_60_sec); 1871 1804 1872 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 1873 - "CBD Opcode: %02x Abort issued time: %lu msec\n", sc->cmnd[0], abt_issued_time); 1805 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 1806 + "CDB Opcode: 0x%02x Abort issued time: %lu msec\n", 1807 + sc->cmnd[0], abt_issued_time); 1874 1808 /* 1875 1809 * Command is still pending, need to abort it 1876 1810 * If the firmware completes the command after this point, ··· 1882 1814 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; 1883 1815 fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; 1884 1816 1885 - spin_unlock_irqrestore(io_lock, flags); 1817 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1886 1818 1887 1819 /* 1888 1820 * Check readiness of the remote port. If the path to remote ··· 1899 1831 /* Now queue the abort command to firmware */ 1900 1832 int_to_scsilun(sc->device->lun, &fc_lun); 1901 1833 1902 - if (fnic_queue_abort_io_req(fnic, tag, task_req, fc_lun.scsi_lun, 1903 - io_req)) { 1904 - spin_lock_irqsave(io_lock, flags); 1834 + if (fnic_queue_abort_io_req(fnic, mqtag, task_req, fc_lun.scsi_lun, 1835 + io_req, hwq)) { 1836 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1905 1837 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) 1906 1838 fnic_priv(sc)->state = old_ioreq_state; 1907 1839 io_req = fnic_priv(sc)->io_req; 1908 1840 if (io_req) 1909 1841 io_req->abts_done = NULL; 1910 - spin_unlock_irqrestore(io_lock, flags); 1842 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1911 1843 ret = FAILED; 1912 1844 goto fnic_abort_cmd_end; 1913 1845 } ··· 1931 1863 fnic->config.ed_tov)); 1932 1864 1933 1865 /* Check the abort status */ 1934 - spin_lock_irqsave(io_lock, flags); 1866 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 1935 1867 1936 1868 io_req = fnic_priv(sc)->io_req; 1937 1869 if (!io_req) { 1938 1870 atomic64_inc(&fnic_stats->io_stats.ioreq_null); 1939 - spin_unlock_irqrestore(io_lock, flags); 1871 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1940 1872 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; 1941 1873 ret = FAILED; 1942 1874 goto fnic_abort_cmd_end; ··· 1945 1877 1946 1878 /* fw did not complete abort, timed out */ 1947 1879 if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { 1948 - spin_unlock_irqrestore(io_lock, flags); 1880 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1949 1881 if (task_req == FCPIO_ITMF_ABT_TASK) { 1950 1882 atomic64_inc(&abts_stats->abort_drv_timeouts); 1951 1883 } else { ··· 1959 1891 /* IO out of order */ 1960 1892 1961 1893 if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { 1962 - spin_unlock_irqrestore(io_lock, flags); 1963 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1964 - "Issuing Host reset due to out of order IO\n"); 1894 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1895 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 1896 + "Issuing host reset due to out of order IO\n"); 1965 1897 1966 1898 ret = FAILED; 1967 1899 goto fnic_abort_cmd_end; ··· 1975 1907 * free the io_req if successful. If abort fails, 1976 1908 * Device reset will clean the I/O. 1977 1909 */ 1978 - if (fnic_priv(sc)->abts_status == FCPIO_SUCCESS) { 1910 + if (fnic_priv(sc)->abts_status == FCPIO_SUCCESS || 1911 + (fnic_priv(sc)->abts_status == FCPIO_ABORTED)) { 1979 1912 fnic_priv(sc)->io_req = NULL; 1913 + io_req->sc = NULL; 1980 1914 } else { 1981 1915 ret = FAILED; 1982 - spin_unlock_irqrestore(io_lock, flags); 1916 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1983 1917 goto fnic_abort_cmd_end; 1984 1918 } 1985 1919 1986 - spin_unlock_irqrestore(io_lock, flags); 1920 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] = NULL; 1921 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 1987 1922 1988 1923 fnic_release_ioreq_buf(fnic, io_req, sc); 1989 1924 mempool_free(io_req, fnic->io_req_pool); ··· 2001 1930 atomic64_inc(&fnic_stats->io_stats.io_completions); 2002 1931 2003 1932 fnic_abort_cmd_end: 2004 - FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, tag, sc, 1933 + FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, mqtag, sc, 2005 1934 jiffies_to_msecs(jiffies - start_time), 2006 1935 0, ((u64)sc->cmnd[0] << 32 | 2007 1936 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | 2008 1937 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 2009 1938 fnic_flags_and_state(sc)); 2010 1939 2011 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1940 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2012 1941 "Returning from abort cmd type %x %s\n", task_req, 2013 1942 (ret == SUCCESS) ? 2014 1943 "SUCCESS" : "FAILED"); ··· 2019 1948 struct scsi_cmnd *sc, 2020 1949 struct fnic_io_req *io_req) 2021 1950 { 2022 - struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 2023 - struct Scsi_Host *host = fnic->lport->host; 1951 + struct vnic_wq_copy *wq; 2024 1952 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; 2025 1953 struct scsi_lun fc_lun; 2026 1954 int ret = 0; 2027 - unsigned long intr_flags; 2028 - unsigned int tag = scsi_cmd_to_rq(sc)->tag; 1955 + unsigned long flags; 1956 + uint16_t hwq = 0; 1957 + uint32_t tag = 0; 2029 1958 2030 - if (tag == SCSI_NO_TAG) 2031 - tag = io_req->tag; 1959 + tag = io_req->tag; 1960 + hwq = blk_mq_unique_tag_to_hwq(tag); 1961 + wq = &fnic->hw_copy_wq[hwq]; 2032 1962 2033 - spin_lock_irqsave(host->host_lock, intr_flags); 1963 + spin_lock_irqsave(&fnic->fnic_lock, flags); 2034 1964 if (unlikely(fnic_chk_state_flags_locked(fnic, 2035 1965 FNIC_FLAGS_IO_BLOCKED))) { 2036 - spin_unlock_irqrestore(host->host_lock, intr_flags); 1966 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 2037 1967 return FAILED; 2038 1968 } else 2039 1969 atomic_inc(&fnic->in_flight); 2040 - spin_unlock_irqrestore(host->host_lock, intr_flags); 1970 + spin_unlock_irqrestore(&fnic->fnic_lock, flags); 2041 1971 2042 - spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); 1972 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2043 1973 2044 - if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) 2045 - free_wq_copy_descs(fnic, wq); 1974 + if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[hwq]) 1975 + free_wq_copy_descs(fnic, wq, hwq); 2046 1976 2047 1977 if (!vnic_wq_copy_desc_avail(wq)) { 2048 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1978 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2049 1979 "queue_dr_io_req failure - no descriptors\n"); 2050 1980 atomic64_inc(&misc_stats->devrst_cpwq_alloc_failures); 2051 1981 ret = -EAGAIN; ··· 2069 1997 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); 2070 1998 2071 1999 lr_io_req_end: 2072 - spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); 2000 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2073 2001 atomic_dec(&fnic->in_flight); 2074 2002 2075 2003 return ret; ··· 2084 2012 2085 2013 static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data) 2086 2014 { 2015 + struct request *const rq = scsi_cmd_to_rq(sc); 2087 2016 struct fnic_pending_aborts_iter_data *iter_data = data; 2088 2017 struct fnic *fnic = iter_data->fnic; 2089 2018 struct scsi_device *lun_dev = iter_data->lun_dev; 2090 - int abt_tag = scsi_cmd_to_rq(sc)->tag; 2019 + unsigned long abt_tag = 0; 2020 + uint16_t hwq = 0; 2091 2021 struct fnic_io_req *io_req; 2092 - spinlock_t *io_lock; 2093 2022 unsigned long flags; 2094 2023 struct scsi_lun fc_lun; 2095 2024 DECLARE_COMPLETION_ONSTACK(tm_done); ··· 2099 2026 if (sc == iter_data->lr_sc || sc->device != lun_dev) 2100 2027 return true; 2101 2028 2102 - io_lock = fnic_io_lock_tag(fnic, abt_tag); 2103 - spin_lock_irqsave(io_lock, flags); 2029 + abt_tag = blk_mq_unique_tag(rq); 2030 + hwq = blk_mq_unique_tag_to_hwq(abt_tag); 2031 + 2032 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2104 2033 io_req = fnic_priv(sc)->io_req; 2105 2034 if (!io_req) { 2106 - spin_unlock_irqrestore(io_lock, flags); 2035 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2107 2036 return true; 2108 2037 } 2109 2038 ··· 2113 2038 * Found IO that is still pending with firmware and 2114 2039 * belongs to the LUN that we are resetting 2115 2040 */ 2116 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2041 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2117 2042 "Found IO in %s on lun\n", 2118 2043 fnic_ioreq_state_to_str(fnic_priv(sc)->state)); 2119 2044 2120 2045 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { 2121 - spin_unlock_irqrestore(io_lock, flags); 2046 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2122 2047 return true; 2123 2048 } 2124 2049 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && 2125 2050 (!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) { 2126 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 2127 - "%s dev rst not pending sc 0x%p\n", __func__, 2128 - sc); 2129 - spin_unlock_irqrestore(io_lock, flags); 2051 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2052 + "dev rst not pending sc 0x%p\n", sc); 2053 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2130 2054 return true; 2131 2055 } 2132 2056 ··· 2146 2072 BUG_ON(io_req->abts_done); 2147 2073 2148 2074 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { 2149 - abt_tag |= FNIC_TAG_DEV_RST; 2150 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 2151 - "%s: dev rst sc 0x%p\n", __func__, sc); 2075 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2076 + "dev rst sc 0x%p\n", sc); 2152 2077 } 2153 2078 2154 2079 fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; 2155 2080 io_req->abts_done = &tm_done; 2156 - spin_unlock_irqrestore(io_lock, flags); 2081 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2157 2082 2158 2083 /* Now queue the abort command to firmware */ 2159 2084 int_to_scsilun(sc->device->lun, &fc_lun); 2160 2085 2161 2086 if (fnic_queue_abort_io_req(fnic, abt_tag, 2162 2087 FCPIO_ITMF_ABT_TASK_TERM, 2163 - fc_lun.scsi_lun, io_req)) { 2164 - spin_lock_irqsave(io_lock, flags); 2088 + fc_lun.scsi_lun, io_req, hwq)) { 2089 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2165 2090 io_req = fnic_priv(sc)->io_req; 2166 2091 if (io_req) 2167 2092 io_req->abts_done = NULL; 2168 2093 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) 2169 2094 fnic_priv(sc)->state = old_ioreq_state; 2170 - spin_unlock_irqrestore(io_lock, flags); 2095 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2171 2096 iter_data->ret = FAILED; 2097 + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, 2098 + "hwq: %d abt_tag: 0x%lx Abort could not be queued\n", 2099 + hwq, abt_tag); 2172 2100 return false; 2173 2101 } else { 2174 - spin_lock_irqsave(io_lock, flags); 2102 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2175 2103 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) 2176 2104 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; 2177 - spin_unlock_irqrestore(io_lock, flags); 2105 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2178 2106 } 2179 2107 fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; 2180 2108 ··· 2184 2108 (fnic->config.ed_tov)); 2185 2109 2186 2110 /* Recheck cmd state to check if it is now aborted */ 2187 - spin_lock_irqsave(io_lock, flags); 2111 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2188 2112 io_req = fnic_priv(sc)->io_req; 2189 2113 if (!io_req) { 2190 - spin_unlock_irqrestore(io_lock, flags); 2114 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2191 2115 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; 2192 2116 return true; 2193 2117 } ··· 2196 2120 2197 2121 /* if abort is still pending with fw, fail */ 2198 2122 if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { 2199 - spin_unlock_irqrestore(io_lock, flags); 2123 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2200 2124 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE; 2201 2125 iter_data->ret = FAILED; 2202 2126 return false; ··· 2204 2128 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; 2205 2129 2206 2130 /* original sc used for lr is handled by dev reset code */ 2207 - if (sc != iter_data->lr_sc) 2131 + if (sc != iter_data->lr_sc) { 2208 2132 fnic_priv(sc)->io_req = NULL; 2209 - spin_unlock_irqrestore(io_lock, flags); 2133 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(abt_tag)] = NULL; 2134 + } 2135 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2210 2136 2211 2137 /* original sc used for lr is handled by dev reset code */ 2212 2138 if (sc != iter_data->lr_sc) { ··· 2260 2182 ret = 1; 2261 2183 2262 2184 clean_pending_aborts_end: 2263 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 2264 - "%s: exit status: %d\n", __func__, ret); 2185 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2186 + "exit status: %d\n", ret); 2265 2187 return ret; 2266 2188 } 2267 2189 ··· 2279 2201 struct fc_rport *rport; 2280 2202 int status; 2281 2203 int ret = FAILED; 2282 - spinlock_t *io_lock; 2283 2204 unsigned long flags; 2284 2205 unsigned long start_time = 0; 2285 2206 struct scsi_lun fc_lun; 2286 2207 struct fnic_stats *fnic_stats; 2287 2208 struct reset_stats *reset_stats; 2288 - int tag = rq->tag; 2209 + int mqtag = rq->tag; 2289 2210 DECLARE_COMPLETION_ONSTACK(tm_done); 2290 2211 bool new_sc = 0; 2212 + uint16_t hwq = 0; 2291 2213 2292 2214 /* Wait for rport to unblock */ 2293 2215 fc_block_scsi_eh(sc); ··· 2302 2224 atomic64_inc(&reset_stats->device_resets); 2303 2225 2304 2226 rport = starget_to_rport(scsi_target(sc->device)); 2305 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2306 - "Device reset called FCID 0x%x, LUN 0x%llx sc 0x%p\n", 2307 - rport->port_id, sc->device->lun, sc); 2227 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2228 + "fcid: 0x%x lun: 0x%llx hwq: %d mqtag: 0x%x flags: 0x%x Device reset\n", 2229 + rport->port_id, sc->device->lun, hwq, mqtag, 2230 + fnic_priv(sc)->flags); 2308 2231 2309 2232 if (lp->state != LPORT_ST_READY || !(lp->link_up)) 2310 2233 goto fnic_device_reset_end; ··· 2318 2239 2319 2240 fnic_priv(sc)->flags = FNIC_DEVICE_RESET; 2320 2241 2321 - if (unlikely(tag < 0)) { 2242 + if (unlikely(mqtag < 0)) { 2322 2243 /* 2323 2244 * For device reset issued through sg3utils, we let 2324 2245 * only one LUN_RESET to go through and use a special ··· 2327 2248 * allocated by mid layer. 2328 2249 */ 2329 2250 mutex_lock(&fnic->sgreset_mutex); 2330 - tag = fnic->fnic_max_tag_id; 2251 + mqtag = fnic->fnic_max_tag_id; 2331 2252 new_sc = 1; 2332 - fnic->sgreset_sc = sc; 2333 - io_lock = &fnic->sgreset_lock; 2334 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 2335 - "fcid: 0x%x lun: 0x%llx flags: 0x%x tag: 0x%x Issuing sgreset\n", 2336 - rport->port_id, sc->device->lun, fnic_priv(sc)->flags, tag); 2337 - } else 2338 - io_lock = fnic_io_lock_hash(fnic, sc); 2253 + } else { 2254 + mqtag = blk_mq_unique_tag(rq); 2255 + hwq = blk_mq_unique_tag_to_hwq(mqtag); 2256 + } 2339 2257 2340 - spin_lock_irqsave(io_lock, flags); 2258 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2341 2259 io_req = fnic_priv(sc)->io_req; 2342 2260 2343 2261 /* ··· 2344 2268 if (!io_req) { 2345 2269 io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); 2346 2270 if (!io_req) { 2347 - spin_unlock_irqrestore(io_lock, flags); 2271 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2348 2272 goto fnic_device_reset_end; 2349 2273 } 2350 2274 memset(io_req, 0, sizeof(*io_req)); 2351 2275 io_req->port_id = rport->port_id; 2352 - io_req->tag = tag; 2353 - io_req->sc = sc; 2276 + io_req->tag = mqtag; 2354 2277 fnic_priv(sc)->io_req = io_req; 2278 + io_req->sc = sc; 2279 + 2280 + if (fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] != NULL) 2281 + WARN(1, "fnic<%d>: %s: tag 0x%x already exists\n", 2282 + fnic->fnic_num, __func__, blk_mq_unique_tag_to_tag(mqtag)); 2283 + 2284 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] = 2285 + io_req; 2355 2286 } 2356 2287 io_req->dr_done = &tm_done; 2357 2288 fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; 2358 2289 fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE; 2359 - spin_unlock_irqrestore(io_lock, flags); 2290 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2360 2291 2361 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %x\n", tag); 2292 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "TAG %x\n", mqtag); 2362 2293 2363 2294 /* 2364 2295 * issue the device reset, if enqueue failed, clean up the ioreq 2365 2296 * and break assoc with scsi cmd 2366 2297 */ 2367 2298 if (fnic_queue_dr_io_req(fnic, sc, io_req)) { 2368 - spin_lock_irqsave(io_lock, flags); 2299 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2369 2300 io_req = fnic_priv(sc)->io_req; 2370 2301 if (io_req) 2371 2302 io_req->dr_done = NULL; 2372 2303 goto fnic_device_reset_clean; 2373 2304 } 2374 - spin_lock_irqsave(io_lock, flags); 2305 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2375 2306 fnic_priv(sc)->flags |= FNIC_DEV_RST_ISSUED; 2376 - spin_unlock_irqrestore(io_lock, flags); 2307 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2377 2308 2378 2309 /* 2379 2310 * Wait on the local completion for LUN reset. The io_req may be ··· 2389 2306 wait_for_completion_timeout(&tm_done, 2390 2307 msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); 2391 2308 2392 - spin_lock_irqsave(io_lock, flags); 2309 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2393 2310 io_req = fnic_priv(sc)->io_req; 2394 2311 if (!io_req) { 2395 - spin_unlock_irqrestore(io_lock, flags); 2396 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2397 - "io_req is null tag 0x%x sc 0x%p\n", tag, sc); 2312 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2313 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2314 + "io_req is null mqtag 0x%x sc 0x%p\n", mqtag, sc); 2398 2315 goto fnic_device_reset_end; 2399 2316 } 2400 2317 io_req->dr_done = NULL; ··· 2407 2324 */ 2408 2325 if (status == FCPIO_INVALID_CODE) { 2409 2326 atomic64_inc(&reset_stats->device_reset_timeouts); 2410 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2327 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2411 2328 "Device reset timed out\n"); 2412 2329 fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT; 2413 - spin_unlock_irqrestore(io_lock, flags); 2330 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2414 2331 int_to_scsilun(sc->device->lun, &fc_lun); 2415 2332 /* 2416 2333 * Issue abort and terminate on device reset request. 2417 2334 * If q'ing of terminate fails, retry it after a delay. 2418 2335 */ 2419 2336 while (1) { 2420 - spin_lock_irqsave(io_lock, flags); 2337 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2421 2338 if (fnic_priv(sc)->flags & FNIC_DEV_RST_TERM_ISSUED) { 2422 - spin_unlock_irqrestore(io_lock, flags); 2339 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2423 2340 break; 2424 2341 } 2425 - spin_unlock_irqrestore(io_lock, flags); 2342 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2426 2343 if (fnic_queue_abort_io_req(fnic, 2427 - tag | FNIC_TAG_DEV_RST, 2344 + mqtag | FNIC_TAG_DEV_RST, 2428 2345 FCPIO_ITMF_ABT_TASK_TERM, 2429 - fc_lun.scsi_lun, io_req)) { 2346 + fc_lun.scsi_lun, io_req, hwq)) { 2430 2347 wait_for_completion_timeout(&tm_done, 2431 2348 msecs_to_jiffies(FNIC_ABT_TERM_DELAY_TIMEOUT)); 2432 2349 } else { 2433 - spin_lock_irqsave(io_lock, flags); 2350 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2434 2351 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; 2435 2352 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; 2436 2353 io_req->abts_done = &tm_done; 2437 - spin_unlock_irqrestore(io_lock, flags); 2438 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2439 - "Abort and terminate issued on Device reset " 2440 - "tag 0x%x sc 0x%p\n", tag, sc); 2354 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2355 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2356 + "Abort and terminate issued on Device reset mqtag 0x%x sc 0x%p\n", 2357 + mqtag, sc); 2441 2358 break; 2442 2359 } 2443 2360 } 2444 2361 while (1) { 2445 - spin_lock_irqsave(io_lock, flags); 2362 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2446 2363 if (!(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { 2447 - spin_unlock_irqrestore(io_lock, flags); 2364 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2448 2365 wait_for_completion_timeout(&tm_done, 2449 2366 msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); 2450 2367 break; ··· 2455 2372 } 2456 2373 } 2457 2374 } else { 2458 - spin_unlock_irqrestore(io_lock, flags); 2375 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2459 2376 } 2460 2377 2461 2378 /* Completed, but not successful, clean up the io_req, return fail */ 2462 2379 if (status != FCPIO_SUCCESS) { 2463 - spin_lock_irqsave(io_lock, flags); 2380 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2464 2381 FNIC_SCSI_DBG(KERN_DEBUG, 2465 - fnic->lport->host, 2382 + fnic->lport->host, fnic->fnic_num, 2466 2383 "Device reset completed - failed\n"); 2467 2384 io_req = fnic_priv(sc)->io_req; 2468 2385 goto fnic_device_reset_clean; ··· 2476 2393 * succeeds 2477 2394 */ 2478 2395 if (fnic_clean_pending_aborts(fnic, sc, new_sc)) { 2479 - spin_lock_irqsave(io_lock, flags); 2396 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2480 2397 io_req = fnic_priv(sc)->io_req; 2481 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2398 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2482 2399 "Device reset failed" 2483 2400 " since could not abort all IOs\n"); 2484 2401 goto fnic_device_reset_clean; 2485 2402 } 2486 2403 2487 2404 /* Clean lun reset command */ 2488 - spin_lock_irqsave(io_lock, flags); 2405 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2489 2406 io_req = fnic_priv(sc)->io_req; 2490 2407 if (io_req) 2491 2408 /* Completed, and successful */ 2492 2409 ret = SUCCESS; 2493 2410 2494 2411 fnic_device_reset_clean: 2495 - if (io_req) 2412 + if (io_req) { 2496 2413 fnic_priv(sc)->io_req = NULL; 2414 + io_req->sc = NULL; 2415 + fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(io_req->tag)] = NULL; 2416 + } 2497 2417 2498 - spin_unlock_irqrestore(io_lock, flags); 2418 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2499 2419 2500 2420 if (io_req) { 2501 2421 start_time = io_req->start_time; ··· 2519 2433 mutex_unlock(&fnic->sgreset_mutex); 2520 2434 } 2521 2435 2522 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2436 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2523 2437 "Returning from device reset %s\n", 2524 2438 (ret == SUCCESS) ? 2525 2439 "SUCCESS" : "FAILED"); ··· 2542 2456 fnic = lport_priv(lp); 2543 2457 reset_stats = &fnic->fnic_stats.reset_stats; 2544 2458 2545 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2546 - "fnic_reset called\n"); 2459 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2460 + "Issuing fnic reset\n"); 2547 2461 2548 2462 atomic64_inc(&reset_stats->fnic_resets); 2549 2463 ··· 2553 2467 */ 2554 2468 ret = fc_lport_reset(lp); 2555 2469 2556 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2557 - "Returning from fnic reset %s\n", 2558 - (ret == 0) ? 2559 - "SUCCESS" : "FAILED"); 2470 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2471 + "Returning from fnic reset with: %s\n", 2472 + (ret == 0) ? "SUCCESS" : "FAILED"); 2560 2473 2561 2474 if (ret == 0) 2562 2475 atomic64_inc(&reset_stats->fnic_reset_completions); ··· 2588 2503 fnic->internal_reset_inprogress = true; 2589 2504 } else { 2590 2505 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 2591 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2506 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2592 2507 "host reset in progress skipping another host reset\n"); 2593 2508 return SUCCESS; 2594 2509 } ··· 2663 2578 2664 2579 spin_lock_irqsave(&fnic->fnic_lock, flags); 2665 2580 fnic->remove_wait = NULL; 2666 - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2581 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, 2667 2582 "fnic_scsi_abort_io %s\n", 2668 2583 (fnic->state == FNIC_IN_ETH_MODE) ? 2669 2584 "SUCCESS" : "FAILED"); ··· 2737 2652 2738 2653 static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data) 2739 2654 { 2655 + struct request *const rq = scsi_cmd_to_rq(sc); 2740 2656 struct fnic_pending_aborts_iter_data *iter_data = data; 2741 2657 struct fnic *fnic = iter_data->fnic; 2742 2658 int cmd_state; 2743 2659 struct fnic_io_req *io_req; 2744 - spinlock_t *io_lock; 2745 2660 unsigned long flags; 2661 + uint16_t hwq = 0; 2662 + int tag; 2663 + 2664 + tag = blk_mq_unique_tag(rq); 2665 + hwq = blk_mq_unique_tag_to_hwq(tag); 2746 2666 2747 2667 /* 2748 2668 * ignore this lun reset cmd or cmds that do not belong to ··· 2758 2668 if (iter_data->lun_dev && sc->device != iter_data->lun_dev) 2759 2669 return true; 2760 2670 2761 - io_lock = fnic_io_lock_hash(fnic, sc); 2762 - spin_lock_irqsave(io_lock, flags); 2671 + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); 2763 2672 2764 2673 io_req = fnic_priv(sc)->io_req; 2765 2674 if (!io_req) { 2766 - spin_unlock_irqrestore(io_lock, flags); 2675 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2767 2676 return true; 2768 2677 } 2769 2678 ··· 2770 2681 * Found IO that is still pending with firmware and 2771 2682 * belongs to the LUN that we are resetting 2772 2683 */ 2773 - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 2774 - "Found IO in %s on lun\n", 2775 - fnic_ioreq_state_to_str(fnic_priv(sc)->state)); 2684 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, 2685 + "hwq: %d tag: 0x%x Found IO in state: %s on lun\n", 2686 + hwq, tag, 2687 + fnic_ioreq_state_to_str(fnic_priv(sc)->state)); 2776 2688 cmd_state = fnic_priv(sc)->state; 2777 - spin_unlock_irqrestore(io_lock, flags); 2689 + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); 2778 2690 if (cmd_state == FNIC_IOREQ_ABTS_PENDING) 2779 2691 iter_data->ret = 1; 2780 2692
+3
drivers/scsi/fnic/fnic_stats.h
··· 2 2 /* Copyright 2013 Cisco Systems, Inc. All rights reserved. */ 3 3 #ifndef _FNIC_STATS_H_ 4 4 #define _FNIC_STATS_H_ 5 + #define FNIC_MQ_MAX_QUEUES 64 5 6 6 7 struct stats_timestamps { 7 8 struct timespec64 last_reset_time; ··· 27 26 atomic64_t io_btw_10000_to_30000_msec; 28 27 atomic64_t io_greater_than_30000_msec; 29 28 atomic64_t current_max_io_time; 29 + atomic64_t ios[FNIC_MQ_MAX_QUEUES]; 30 30 }; 31 31 32 32 struct abort_stats { ··· 105 103 atomic64_t rport_not_ready; 106 104 atomic64_t frame_errors; 107 105 atomic64_t current_port_speed; 106 + atomic64_t intx_dummy; 108 107 }; 109 108 110 109 struct fnic_stats {
+11
drivers/scsi/fnic/fnic_trace.c
··· 204 204 int len = 0; 205 205 int buf_size = debug->buf_size; 206 206 struct timespec64 val1, val2; 207 + int i = 0; 207 208 208 209 ktime_get_real_ts64(&val1); 209 210 len = scnprintf(debug->debug_buffer + len, buf_size - len, ··· 266 265 (u64)atomic64_read(&stats->io_stats.io_btw_5000_to_10000_msec), 267 266 (u64)atomic64_read(&stats->io_stats.io_btw_10000_to_30000_msec), 268 267 (u64)atomic64_read(&stats->io_stats.io_greater_than_30000_msec)); 268 + 269 + len += scnprintf(debug->debug_buffer + len, buf_size - len, 270 + "------------------------------------------\n" 271 + "\t\tIO Queues and cumulative IOs\n" 272 + "------------------------------------------\n"); 273 + 274 + for (i = 0; i < FNIC_MQ_MAX_QUEUES; i++) { 275 + len += scnprintf(debug->debug_buffer + len, buf_size - len, 276 + "Q:%d -> %lld\n", i, (u64)atomic64_read(&stats->io_stats.ios[i])); 277 + } 269 278 270 279 len += scnprintf(debug->debug_buffer + len, buf_size - len, 271 280 "\nCurrent Max IO time : %lld\n",
+4
drivers/scsi/fnic/vnic_dev.c
··· 143 143 vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset; 144 144 } 145 145 146 + pr_info("res_type_wq: %d res_type_rq: %d res_type_cq: %d res_type_intr_ctrl: %d\n", 147 + vdev->res[RES_TYPE_WQ].count, vdev->res[RES_TYPE_RQ].count, 148 + vdev->res[RES_TYPE_CQ].count, vdev->res[RES_TYPE_INTR_CTRL].count); 149 + 146 150 return 0; 147 151 } 148 152
+11 -2
drivers/scsi/fnic/vnic_scsi.h
··· 26 26 #define VNIC_FNIC_RATOV_MAX 255000 27 27 28 28 #define VNIC_FNIC_MAXDATAFIELDSIZE_MIN 256 29 - #define VNIC_FNIC_MAXDATAFIELDSIZE_MAX 2112 29 + #define VNIC_FNIC_MAXDATAFIELDSIZE_MAX 2048 30 30 31 31 #define VNIC_FNIC_FLOGI_RETRIES_MIN 0 32 32 #define VNIC_FNIC_FLOGI_RETRIES_MAX 0xffffffff ··· 55 55 #define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX 255 56 56 57 57 #define VNIC_FNIC_LUNS_PER_TARGET_MIN 1 58 - #define VNIC_FNIC_LUNS_PER_TARGET_MAX 1024 58 + #define VNIC_FNIC_LUNS_PER_TARGET_MAX 4096 59 59 60 60 /* Device-specific region: scsi configuration */ 61 61 struct vnic_fc_config { ··· 79 79 u16 ra_tov; 80 80 u16 intr_timer; 81 81 u8 intr_timer_type; 82 + u8 intr_mode; 83 + u8 lun_queue_depth; 84 + u8 io_timeout_retry; 85 + u16 wq_copy_count; 82 86 }; 83 87 84 88 #define VFCF_FCP_SEQ_LVL_ERR 0x1 /* Enable FCP-2 Error Recovery */ 85 89 #define VFCF_PERBI 0x2 /* persistent binding info available */ 86 90 #define VFCF_FIP_CAPABLE 0x4 /* firmware can handle FIP */ 91 + 92 + #define VFCF_FC_INITIATOR 0x20 /* FC Initiator Mode */ 93 + #define VFCF_FC_TARGET 0x40 /* FC Target Mode */ 94 + #define VFCF_FC_NVME_INITIATOR 0x80 /* FC-NVMe Initiator Mode */ 95 + #define VFCF_FC_NVME_TARGET 0x100 /* FC-NVMe Target Mode */ 87 96 88 97 #endif /* _VNIC_SCSI_H_ */
+7 -4
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 1565 1565 static int hisi_sas_controller_prereset(struct hisi_hba *hisi_hba) 1566 1566 { 1567 1567 if (!hisi_hba->hw->soft_reset) 1568 - return -1; 1568 + return -ENOENT; 1569 1569 1570 1570 down(&hisi_hba->sem); 1571 1571 if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) { 1572 1572 up(&hisi_hba->sem); 1573 - return -1; 1573 + return -EPERM; 1574 1574 } 1575 1575 1576 1576 if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct) ··· 1641 1641 task->task_state_flags |= SAS_TASK_STATE_ABORTED; 1642 1642 spin_unlock_irqrestore(&task->task_state_lock, flags); 1643 1643 1644 - if (slot && task->task_proto & SAS_PROTOCOL_SSP) { 1644 + if (!slot) 1645 + goto out; 1646 + 1647 + if (task->task_proto & SAS_PROTOCOL_SSP) { 1645 1648 u16 tag = slot->idx; 1646 1649 int rc2; 1647 1650 ··· 1691 1688 rc = hisi_sas_softreset_ata_disk(device); 1692 1689 } 1693 1690 } 1694 - } else if (slot && task->task_proto & SAS_PROTOCOL_SMP) { 1691 + } else if (task->task_proto & SAS_PROTOCOL_SMP) { 1695 1692 /* SMP */ 1696 1693 u32 tag = slot->idx; 1697 1694 struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue];
+12 -7
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 1605 1605 } 1606 1606 1607 1607 phy->port_id = port_id; 1608 + spin_lock(&phy->lock); 1609 + /* Delete timer and set phy_attached atomically */ 1610 + del_timer(&phy->timer); 1611 + phy->phy_attached = 1; 1612 + spin_unlock(&phy->lock); 1608 1613 1609 1614 /* 1610 1615 * Call pm_runtime_get_noresume() which pairs with ··· 1623 1618 1624 1619 res = IRQ_HANDLED; 1625 1620 1626 - spin_lock(&phy->lock); 1627 - /* Delete timer and set phy_attached atomically */ 1628 - del_timer(&phy->timer); 1629 - phy->phy_attached = 1; 1630 - spin_unlock(&phy->lock); 1631 1621 end: 1632 1622 if (phy->reset_completion) 1633 1623 complete(phy->reset_completion); ··· 3476 3476 u32 *databuf = hisi_hba->debugfs_regs[dump_index][DEBUGFS_GLOBAL].data; 3477 3477 int i; 3478 3478 3479 - for (i = 0; i < debugfs_axi_reg.count; i++, databuf++) 3479 + for (i = 0; i < debugfs_global_reg.count; i++, databuf++) 3480 3480 *databuf = hisi_sas_read32(hisi_hba, 4 * i); 3481 3481 } 3482 3482 ··· 4968 4968 { 4969 4969 struct sas_ha_struct *sha = pci_get_drvdata(pdev); 4970 4970 struct hisi_hba *hisi_hba = sha->lldd_ha; 4971 + struct Scsi_Host *shost = hisi_hba->shost; 4971 4972 struct device *dev = hisi_hba->dev; 4972 4973 int rc; 4973 4974 ··· 4977 4976 rc = hw_init_v3_hw(hisi_hba); 4978 4977 if (rc) { 4979 4978 dev_err(dev, "FLR: hw init failed rc=%d\n", rc); 4979 + clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); 4980 + scsi_unblock_requests(shost); 4981 + clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); 4982 + up(&hisi_hba->sem); 4980 4983 return; 4981 4984 } 4982 4985 ··· 5023 5018 } 5024 5019 5025 5020 if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) 5026 - return -1; 5021 + return -EPERM; 5027 5022 5028 5023 dev_warn(dev, "entering suspend state\n"); 5029 5024
+7 -5
drivers/scsi/ibmvscsi/ibmvfc.c
··· 1464 1464 1465 1465 name = of_get_property(rootdn, "ibm,partition-name", NULL); 1466 1466 if (name) 1467 - strncpy(vhost->partition_name, name, sizeof(vhost->partition_name)); 1467 + strscpy(vhost->partition_name, name, sizeof(vhost->partition_name)); 1468 1468 num = of_get_property(rootdn, "ibm,partition-no", NULL); 1469 1469 if (num) 1470 1470 vhost->partition_number = *num; ··· 1513 1513 login_info->async.va = cpu_to_be64(vhost->async_crq.msg_token); 1514 1514 login_info->async.len = cpu_to_be32(async_crq->size * 1515 1515 sizeof(*async_crq->msgs.async)); 1516 - strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME); 1517 - strncpy(login_info->device_name, 1518 - dev_name(&vhost->host->shost_gendev), IBMVFC_MAX_NAME); 1516 + strscpy(login_info->partition_name, vhost->partition_name, 1517 + sizeof(login_info->partition_name)); 1518 + 1519 + strscpy(login_info->device_name, 1520 + dev_name(&vhost->host->shost_gendev), sizeof(login_info->device_name)); 1519 1521 1520 1522 location = of_get_property(of_node, "ibm,loc-code", NULL); 1521 1523 location = location ? location : dev_name(vhost->dev); 1522 - strncpy(login_info->drc_name, location, IBMVFC_MAX_NAME); 1524 + strscpy(login_info->drc_name, location, sizeof(login_info->drc_name)); 1523 1525 } 1524 1526 1525 1527 /**
+1 -1
drivers/scsi/ibmvscsi/ibmvscsi.c
··· 266 266 dev_info(hostdata->dev, "SRP_VERSION: %s\n", SRP_VERSION); 267 267 strcpy(hostdata->madapter_info.srp_version, SRP_VERSION); 268 268 269 - strncpy(hostdata->madapter_info.partition_name, partition_name, 269 + strscpy(hostdata->madapter_info.partition_name, partition_name, 270 270 sizeof(hostdata->madapter_info.partition_name)); 271 271 272 272 hostdata->madapter_info.partition_number =
-55
drivers/scsi/ipr.c
··· 77 77 static LIST_HEAD(ipr_ioa_head); 78 78 static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL; 79 79 static unsigned int ipr_max_speed = 1; 80 - static int ipr_testmode = 0; 81 80 static unsigned int ipr_fastfail = 0; 82 81 static unsigned int ipr_transop_timeout = 0; 83 82 static unsigned int ipr_debug = 0; ··· 192 193 MODULE_PARM_DESC(max_speed, "Maximum bus speed (0-2). Default: 1=U160. Speeds: 0=80 MB/s, 1=U160, 2=U320"); 193 194 module_param_named(log_level, ipr_log_level, uint, 0); 194 195 MODULE_PARM_DESC(log_level, "Set to 0 - 4 for increasing verbosity of device driver"); 195 - module_param_named(testmode, ipr_testmode, int, 0); 196 - MODULE_PARM_DESC(testmode, "DANGEROUS!!! Allows unsupported configurations"); 197 196 module_param_named(fastfail, ipr_fastfail, int, S_IRUGO | S_IWUSR); 198 197 MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries"); 199 198 module_param_named(transop_timeout, ipr_transop_timeout, int, 0); ··· 6413 6416 .proc_name = IPR_NAME, 6414 6417 }; 6415 6418 6416 - #ifdef CONFIG_PPC_PSERIES 6417 - static const u16 ipr_blocked_processors[] = { 6418 - PVR_NORTHSTAR, 6419 - PVR_PULSAR, 6420 - PVR_POWER4, 6421 - PVR_ICESTAR, 6422 - PVR_SSTAR, 6423 - PVR_POWER4p, 6424 - PVR_630, 6425 - PVR_630p 6426 - }; 6427 - 6428 - /** 6429 - * ipr_invalid_adapter - Determine if this adapter is supported on this hardware 6430 - * @ioa_cfg: ioa cfg struct 6431 - * 6432 - * Adapters that use Gemstone revision < 3.1 do not work reliably on 6433 - * certain pSeries hardware. This function determines if the given 6434 - * adapter is in one of these confgurations or not. 6435 - * 6436 - * Return value: 6437 - * 1 if adapter is not supported / 0 if adapter is supported 6438 - **/ 6439 - static int ipr_invalid_adapter(struct ipr_ioa_cfg *ioa_cfg) 6440 - { 6441 - int i; 6442 - 6443 - if ((ioa_cfg->type == 0x5702) && (ioa_cfg->pdev->revision < 4)) { 6444 - for (i = 0; i < ARRAY_SIZE(ipr_blocked_processors); i++) { 6445 - if (pvr_version_is(ipr_blocked_processors[i])) 6446 - return 1; 6447 - } 6448 - } 6449 - return 0; 6450 - } 6451 - #else 6452 - #define ipr_invalid_adapter(ioa_cfg) 0 6453 - #endif 6454 - 6455 6419 /** 6456 6420 * ipr_ioa_bringdown_done - IOA bring down completion. 6457 6421 * @ipr_cmd: ipr command struct ··· 7342 7384 memcpy(type, ioa_cfg->vpd_cbs->ioa_vpd.std_inq_data.vpids.product_id, 4); 7343 7385 type[4] = '\0'; 7344 7386 ioa_cfg->type = simple_strtoul((char *)type, NULL, 16); 7345 - 7346 - if (ipr_invalid_adapter(ioa_cfg)) { 7347 - dev_err(&ioa_cfg->pdev->dev, 7348 - "Adapter not supported in this hardware configuration.\n"); 7349 - 7350 - if (!ipr_testmode) { 7351 - ioa_cfg->reset_retries += IPR_NUM_RESET_RELOAD_RETRIES; 7352 - ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE); 7353 - list_add_tail(&ipr_cmd->queue, 7354 - &ioa_cfg->hrrq->hrrq_free_q); 7355 - return IPR_RC_JOB_RETURN; 7356 - } 7357 - } 7358 7387 7359 7388 ipr_cmd->job_step = ipr_ioafp_page3_inquiry; 7360 7389
+1 -4
drivers/scsi/isci/request.c
··· 738 738 return SCI_SUCCESS; 739 739 } 740 740 741 - enum sci_status sci_task_request_construct_ssp( 742 - struct isci_request *ireq) 741 + void sci_task_request_construct_ssp(struct isci_request *ireq) 743 742 { 744 743 /* Construct the SSP Task SCU Task Context */ 745 744 scu_ssp_task_request_construct_task_context(ireq); ··· 747 748 sci_task_request_build_ssp_task_iu(ireq); 748 749 749 750 sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); 750 - 751 - return SCI_SUCCESS; 752 751 } 753 752 754 753 static enum sci_status sci_io_request_construct_basic_sata(struct isci_request *ireq)
+1 -1
drivers/scsi/isci/request.h
··· 300 300 struct isci_remote_device *idev, 301 301 u16 io_tag, 302 302 struct isci_request *ireq); 303 - enum sci_status sci_task_request_construct_ssp(struct isci_request *ireq); 303 + void sci_task_request_construct_ssp(struct isci_request *ireq); 304 304 void sci_smp_request_copy_response(struct isci_request *ireq); 305 305 306 306 static inline int isci_task_is_ncq_recovery(struct sas_task *task)
+1 -3
drivers/scsi/isci/task.c
··· 243 243 /* XXX convert to get this from task->tproto like other drivers */ 244 244 if (dev->dev_type == SAS_END_DEVICE) { 245 245 isci_tmf->proto = SAS_PROTOCOL_SSP; 246 - status = sci_task_request_construct_ssp(ireq); 247 - if (status != SCI_SUCCESS) 248 - return NULL; 246 + sci_task_request_construct_ssp(ireq); 249 247 } 250 248 251 249 return ireq;
+2 -4
drivers/scsi/jazz_esp.c
··· 176 176 return err; 177 177 } 178 178 179 - static int esp_jazz_remove(struct platform_device *dev) 179 + static void esp_jazz_remove(struct platform_device *dev) 180 180 { 181 181 struct esp *esp = dev_get_drvdata(&dev->dev); 182 182 unsigned int irq = esp->host->irq; ··· 189 189 esp->command_block_dma); 190 190 191 191 scsi_host_put(esp->host); 192 - 193 - return 0; 194 192 } 195 193 196 194 /* work with hotplug and coldplug */ ··· 196 198 197 199 static struct platform_driver esp_jazz_driver = { 198 200 .probe = esp_jazz_probe, 199 - .remove = esp_jazz_remove, 201 + .remove_new = esp_jazz_remove, 200 202 .driver = { 201 203 .name = "jazz_esp", 202 204 },
+14 -8
drivers/scsi/libfc/fc_fcp.c
··· 265 265 if (!fsp->seq_ptr) 266 266 return -EINVAL; 267 267 268 + if (fsp->state & FC_SRB_ABORT_PENDING) { 269 + FC_FCP_DBG(fsp, "abort already pending\n"); 270 + return -EBUSY; 271 + } 272 + 268 273 this_cpu_inc(fsp->lp->stats->FcpPktAborts); 269 274 270 275 fsp->state |= FC_SRB_ABORT_PENDING; ··· 1676 1671 if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) 1677 1672 fc_fcp_rec(fsp); 1678 1673 else 1679 - fc_fcp_recovery(fsp, FC_ERROR); 1674 + fc_fcp_recovery(fsp, FC_TIMED_OUT); 1680 1675 break; 1681 1676 } 1682 1677 fc_fcp_unlock_pkt(fsp); ··· 1695 1690 fsp->status_code = code; 1696 1691 fsp->cdb_status = 0; 1697 1692 fsp->io_status = 0; 1698 - /* 1699 - * if this fails then we let the scsi command timer fire and 1700 - * scsi-ml escalate. 1701 - */ 1702 - fc_fcp_send_abort(fsp); 1693 + if (!fsp->cmd) 1694 + /* 1695 + * Only abort non-scsi commands; otherwise let the 1696 + * scsi command timer fire and scsi-ml escalate. 1697 + */ 1698 + fc_fcp_send_abort(fsp); 1703 1699 } 1704 1700 1705 1701 /** ··· 2062 2056 sc_cmd->result = (DID_PARITY << 16); 2063 2057 break; 2064 2058 case FC_TIMED_OUT: 2065 - FC_FCP_DBG(fsp, "Returning DID_BUS_BUSY to scsi-ml " 2059 + FC_FCP_DBG(fsp, "Returning DID_TIME_OUT to scsi-ml " 2066 2060 "due to FC_TIMED_OUT\n"); 2067 - sc_cmd->result = (DID_BUS_BUSY << 16) | fsp->io_status; 2061 + sc_cmd->result = (DID_TIME_OUT << 16); 2068 2062 break; 2069 2063 default: 2070 2064 FC_FCP_DBG(fsp, "Returning DID_ERROR to scsi-ml "
+1
drivers/scsi/lpfc/lpfc.h
··· 33 33 struct lpfc_sli2_slim; 34 34 35 35 #define ELX_MODEL_NAME_SIZE 80 36 + #define ELX_FW_NAME_SIZE 84 36 37 37 38 #define LPFC_PCI_DEV_LP 0x1 38 39 #define LPFC_PCI_DEV_OC 0x2
+6 -6
drivers/scsi/lpfc/lpfc_attr.c
··· 5905 5905 /* 5906 5906 * lpfc_ras_fwlog_func: Firmware logging enabled on function number 5907 5907 * Default function which has RAS support : 0 5908 - * Value Range is [0..7]. 5908 + * Value Range is [0..3]. 5909 5909 * FW logging is a global action and enablement is via a specific 5910 5910 * port. 5911 5911 */ 5912 - LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function"); 5912 + LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 3, "Firmware Logging Enabled on Function"); 5913 5913 5914 5914 /* 5915 5915 * lpfc_enable_bbcr: Enable BB Credit Recovery ··· 5954 5954 * 4 - 255 = vmid support enabled for 4-255 VMs 5955 5955 * Value range is [4,255]. 5956 5956 */ 5957 - LPFC_ATTR_RW(max_vmid, LPFC_MIN_VMID, LPFC_MIN_VMID, LPFC_MAX_VMID, 5957 + LPFC_ATTR_R(max_vmid, LPFC_MIN_VMID, LPFC_MIN_VMID, LPFC_MAX_VMID, 5958 5958 "Maximum number of VMs supported"); 5959 5959 5960 5960 /* ··· 5962 5962 * 0 = Timeout is disabled 5963 5963 * Value range is [0,24]. 5964 5964 */ 5965 - LPFC_ATTR_RW(vmid_inactivity_timeout, 4, 0, 24, 5965 + LPFC_ATTR_R(vmid_inactivity_timeout, 4, 0, 24, 5966 5966 "Inactivity timeout in hours"); 5967 5967 5968 5968 /* ··· 5971 5971 * 1 = Support is enabled 5972 5972 * Value range is [0,1]. 5973 5973 */ 5974 - LPFC_ATTR_RW(vmid_app_header, LPFC_VMID_APP_HEADER_DISABLE, 5974 + LPFC_ATTR_R(vmid_app_header, LPFC_VMID_APP_HEADER_DISABLE, 5975 5975 LPFC_VMID_APP_HEADER_DISABLE, LPFC_VMID_APP_HEADER_ENABLE, 5976 5976 "Enable App Header VMID support"); 5977 5977 ··· 5982 5982 * 2 = Allow all targets 5983 5983 * Value range is [0,2]. 5984 5984 */ 5985 - LPFC_ATTR_RW(vmid_priority_tagging, LPFC_VMID_PRIO_TAG_DISABLE, 5985 + LPFC_ATTR_R(vmid_priority_tagging, LPFC_VMID_PRIO_TAG_DISABLE, 5986 5986 LPFC_VMID_PRIO_TAG_DISABLE, 5987 5987 LPFC_VMID_PRIO_TAG_ALL_TARGETS, 5988 5988 "Enable Priority Tagging VMID support");
+44 -23
drivers/scsi/lpfc/lpfc_els.c
··· 1130 1130 vport->port_state, vport->fc_flag, 1131 1131 sp->cmn.priority_tagging, kref_read(&ndlp->kref)); 1132 1132 1133 - if (sp->cmn.priority_tagging) 1134 - vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA | 1135 - LPFC_VMID_TYPE_PRIO); 1136 1133 /* reinitialize the VMID datastructure before returning */ 1137 1134 if (lpfc_is_vmid_enabled(phba)) 1138 1135 lpfc_reinit_vmid(vport); 1136 + if (sp->cmn.priority_tagging) 1137 + vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA | 1138 + LPFC_VMID_TYPE_PRIO); 1139 1139 1140 1140 /* 1141 1141 * Address a timing race with dev_loss. If dev_loss is active on ··· 2062 2062 /* PLOGI completes to NPort <nlp_DID> */ 2063 2063 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2064 2064 "0102 PLOGI completes to NPort x%06x " 2065 - "Data: x%x x%x x%x x%x x%x\n", 2066 - ndlp->nlp_DID, ndlp->nlp_fc4_type, 2065 + "IoTag x%x Data: x%x x%x x%x x%x x%x\n", 2066 + ndlp->nlp_DID, iotag, 2067 + ndlp->nlp_fc4_type, 2067 2068 ulp_status, ulp_word4, 2068 2069 disc, vport->num_disc_nodes); 2069 2070 ··· 2129 2128 NLP_EVT_DEVICE_RM); 2130 2129 } else { 2131 2130 /* Good status, call state machine */ 2132 - prsp = list_entry(cmdiocb->cmd_dmabuf->list.next, 2133 - struct lpfc_dmabuf, list); 2131 + prsp = list_get_first(&cmdiocb->cmd_dmabuf->list, 2132 + struct lpfc_dmabuf, list); 2134 2133 if (!prsp) 2135 2134 goto out; 2136 2135 if (!lpfc_is_els_acc_rsp(prsp)) ··· 2363 2362 /* PRLI completes to NPort <nlp_DID> */ 2364 2363 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2365 2364 "0103 PRLI completes to NPort x%06x " 2366 - "Data: x%x x%x x%x x%x\n", 2365 + "Data: x%x x%x x%x x%x x%x\n", 2367 2366 ndlp->nlp_DID, ulp_status, ulp_word4, 2368 - vport->num_disc_nodes, ndlp->fc4_prli_sent); 2367 + vport->num_disc_nodes, ndlp->fc4_prli_sent, 2368 + ndlp->fc4_xpt_flags); 2369 2369 2370 2370 /* Check to see if link went down during discovery */ 2371 2371 if (lpfc_els_chk_latt(vport)) ··· 2807 2805 IOCB_t *irsp; 2808 2806 struct lpfc_nodelist *ndlp; 2809 2807 int disc; 2810 - u32 ulp_status, ulp_word4, tmo; 2808 + u32 ulp_status, ulp_word4, tmo, iotag; 2811 2809 bool release_node = false; 2812 2810 2813 2811 /* we pass cmdiocb to state machine which needs rspiocb as well */ ··· 2820 2818 2821 2819 if (phba->sli_rev == LPFC_SLI_REV4) { 2822 2820 tmo = get_wqe_tmo(cmdiocb); 2821 + iotag = get_wqe_reqtag(cmdiocb); 2823 2822 } else { 2824 2823 irsp = &rspiocb->iocb; 2825 2824 tmo = irsp->ulpTimeout; 2825 + iotag = irsp->ulpIoTag; 2826 2826 } 2827 2827 2828 2828 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, ··· 2842 2838 /* ADISC completes to NPort <nlp_DID> */ 2843 2839 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 2844 2840 "0104 ADISC completes to NPort x%x " 2845 - "Data: x%x x%x x%x x%x x%x\n", 2846 - ndlp->nlp_DID, ulp_status, ulp_word4, 2841 + "IoTag x%x Data: x%x x%x x%x x%x x%x\n", 2842 + ndlp->nlp_DID, iotag, 2843 + ulp_status, ulp_word4, 2847 2844 tmo, disc, vport->num_disc_nodes); 2845 + 2848 2846 /* Check to see if link went down during discovery */ 2849 2847 if (lpfc_els_chk_latt(vport)) { 2850 2848 spin_lock_irq(&ndlp->lock); ··· 3007 3001 int wake_up_waiter = 0; 3008 3002 u32 ulp_status; 3009 3003 u32 ulp_word4; 3010 - u32 tmo; 3004 + u32 tmo, iotag; 3011 3005 3012 3006 /* we pass cmdiocb to state machine which needs rspiocb as well */ 3013 3007 cmdiocb->rsp_iocb = rspiocb; ··· 3017 3011 3018 3012 if (phba->sli_rev == LPFC_SLI_REV4) { 3019 3013 tmo = get_wqe_tmo(cmdiocb); 3014 + iotag = get_wqe_reqtag(cmdiocb); 3020 3015 } else { 3021 3016 irsp = &rspiocb->iocb; 3022 3017 tmo = irsp->ulpTimeout; 3018 + iotag = irsp->ulpIoTag; 3023 3019 } 3024 3020 3025 3021 spin_lock_irq(&ndlp->lock); ··· 3040 3032 /* LOGO completes to NPort <nlp_DID> */ 3041 3033 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 3042 3034 "0105 LOGO completes to NPort x%x " 3043 - "refcnt %d nflags x%x Data: x%x x%x x%x x%x\n", 3044 - ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp->nlp_flag, 3045 - ulp_status, ulp_word4, 3035 + "IoTag x%x refcnt %d nflags x%x xflags x%x " 3036 + "Data: x%x x%x x%x x%x\n", 3037 + ndlp->nlp_DID, iotag, 3038 + kref_read(&ndlp->kref), ndlp->nlp_flag, 3039 + ndlp->fc4_xpt_flags, ulp_status, ulp_word4, 3046 3040 tmo, vport->num_disc_nodes); 3047 3041 3048 3042 if (lpfc_els_chk_latt(vport)) { ··· 5085 5075 if (logerr) { 5086 5076 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 5087 5077 "0137 No retry ELS command x%x to remote " 5088 - "NPORT x%x: Out of Resources: Error:x%x/%x\n", 5089 - cmd, did, ulp_status, 5090 - ulp_word4); 5078 + "NPORT x%x: Out of Resources: Error:x%x/%x " 5079 + "IoTag x%x\n", 5080 + cmd, did, ulp_status, ulp_word4, 5081 + cmdiocb->iotag); 5091 5082 } 5092 5083 else { 5093 5084 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, 5094 - "0108 No retry ELS command x%x to remote " 5095 - "NPORT x%x Retried:%d Error:x%x/%x\n", 5096 - cmd, did, cmdiocb->retry, ulp_status, 5097 - ulp_word4); 5085 + "0108 No retry ELS command x%x to remote " 5086 + "NPORT x%x Retried:%d Error:x%x/%x " 5087 + "IoTag x%x nflags x%x\n", 5088 + cmd, did, cmdiocb->retry, ulp_status, 5089 + ulp_word4, cmdiocb->iotag, 5090 + (ndlp ? ndlp->nlp_flag : 0)); 5098 5091 } 5099 5092 return 0; 5100 5093 } ··· 11143 11130 lpfc_nlp_put(ndlp); 11144 11131 11145 11132 mempool_free(pmb, phba->mbox_mem_pool); 11133 + 11134 + /* reinitialize the VMID datastructure before returning. 11135 + * this is specifically for vport 11136 + */ 11137 + if (lpfc_is_vmid_enabled(phba)) 11138 + lpfc_reinit_vmid(vport); 11139 + vport->vmid_flag = vport->phba->pport->vmid_flag; 11140 + 11146 11141 return; 11147 11142 } 11148 11143
+1 -1
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 411 411 "port_state = x%x\n", 412 412 ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp, 413 413 ndlp->nlp_flag, vport->port_state); 414 - spin_lock_irqsave(&ndlp->lock, iflags); 414 + return; 415 415 } 416 416 spin_unlock_irqrestore(&ndlp->lock, iflags); 417 417 }
+2 -2
drivers/scsi/lpfc/lpfc_init.c
··· 14721 14721 int 14722 14722 lpfc_sli4_request_firmware_update(struct lpfc_hba *phba, uint8_t fw_upgrade) 14723 14723 { 14724 - uint8_t file_name[ELX_MODEL_NAME_SIZE]; 14724 + char file_name[ELX_FW_NAME_SIZE] = {0}; 14725 14725 int ret; 14726 14726 const struct firmware *fw; 14727 14727 ··· 14730 14730 LPFC_SLI_INTF_IF_TYPE_2) 14731 14731 return -EPERM; 14732 14732 14733 - snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName); 14733 + scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); 14734 14734 14735 14735 if (fw_upgrade == INT_FW_UPGRADE) { 14736 14736 ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_UEVENT,
+4 -2
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-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 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. * ··· 1814 1814 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, 1815 1815 mbox->sge_array->addr[sgentry], phyaddr); 1816 1816 } 1817 - /* Free the sge address array memory */ 1817 + /* Reinitialize the context pointers to avoid stale usage. */ 1818 + mbox->ctx_buf = NULL; 1819 + mbox->context3 = NULL; 1818 1820 kfree(mbox->sge_array); 1819 1821 /* Finally, free the mailbox command itself */ 1820 1822 mempool_free(mbox, phba->mbox_mem_pool);
+27 -20
drivers/scsi/lpfc/lpfc_mem.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-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term * 5 5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * 6 6 * Copyright (C) 2004-2014 Emulex. All rights reserved. * 7 7 * EMULEX and SLI are trademarks of Emulex. * ··· 47 47 #define LPFC_DEVICE_DATA_POOL_SIZE 64 /* max elements in device data pool */ 48 48 #define LPFC_RRQ_POOL_SIZE 256 /* max elements in non-DMA pool */ 49 49 #define LPFC_MBX_POOL_SIZE 256 /* max elements in MBX non-DMA pool */ 50 + 51 + /* lpfc_mbox_free_sli_mbox 52 + * 53 + * @phba: HBA to free memory for 54 + * @mbox: mailbox command to free 55 + * 56 + * This routine detects the mbox type and calls the correct 57 + * free routine to fully release all associated memory. 58 + */ 59 + static void 60 + lpfc_mem_free_sli_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) 61 + { 62 + /* Detect if the caller's mbox is an SLI4_CONFIG type. If so, this 63 + * mailbox type requires a different cleanup routine. Otherwise, the 64 + * mailbox is just an mbuf and mem_pool release. 65 + */ 66 + if (phba->sli_rev == LPFC_SLI_REV4 && 67 + bf_get(lpfc_mqe_command, &mbox->u.mqe) == MBX_SLI4_CONFIG) { 68 + lpfc_sli4_mbox_cmd_free(phba, mbox); 69 + } else { 70 + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); 71 + } 72 + } 50 73 51 74 int 52 75 lpfc_mem_alloc_active_rrq_pool_s4(struct lpfc_hba *phba) { ··· 311 288 { 312 289 struct lpfc_sli *psli = &phba->sli; 313 290 LPFC_MBOXQ_t *mbox, *next_mbox; 314 - struct lpfc_dmabuf *mp; 315 291 316 292 /* Free memory used in mailbox queue back to mailbox memory pool */ 317 293 list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq, list) { 318 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 319 - if (mp) { 320 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 321 - kfree(mp); 322 - } 323 294 list_del(&mbox->list); 324 - mempool_free(mbox, phba->mbox_mem_pool); 295 + lpfc_mem_free_sli_mbox(phba, mbox); 325 296 } 326 297 /* Free memory used in mailbox cmpl list back to mailbox memory pool */ 327 298 list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq_cmpl, list) { 328 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 329 - if (mp) { 330 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 331 - kfree(mp); 332 - } 333 299 list_del(&mbox->list); 334 - mempool_free(mbox, phba->mbox_mem_pool); 300 + lpfc_mem_free_sli_mbox(phba, mbox); 335 301 } 336 302 /* Free the active mailbox command back to the mailbox memory pool */ 337 303 spin_lock_irq(&phba->hbalock); ··· 328 316 spin_unlock_irq(&phba->hbalock); 329 317 if (psli->mbox_active) { 330 318 mbox = psli->mbox_active; 331 - mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); 332 - if (mp) { 333 - lpfc_mbuf_free(phba, mp->virt, mp->phys); 334 - kfree(mp); 335 - } 336 - mempool_free(mbox, phba->mbox_mem_pool); 319 + lpfc_mem_free_sli_mbox(phba, mbox); 337 320 psli->mbox_active = NULL; 338 321 } 339 322
+16 -4
drivers/scsi/lpfc/lpfc_sli.c
··· 2995 2995 LPFC_SLI_INTF_IF_TYPE_2)) { 2996 2996 if (ndlp) { 2997 2997 lpfc_printf_vlog( 2998 - vport, KERN_INFO, LOG_MBOX | LOG_SLI, 2999 - "0010 UNREG_LOGIN vpi:%x " 2998 + vport, KERN_INFO, 2999 + LOG_MBOX | LOG_SLI | LOG_NODE, 3000 + "0010 UNREG_LOGIN vpi:x%x " 3000 3001 "rpi:%x DID:%x defer x%x flg x%x " 3001 3002 "x%px\n", 3002 3003 vport->vpi, ndlp->nlp_rpi, ··· 3013 3012 (ndlp->nlp_defer_did != 3014 3013 NLP_EVT_NOTHING_PENDING)) { 3015 3014 lpfc_printf_vlog( 3016 - vport, KERN_INFO, LOG_DISCOVERY, 3015 + vport, KERN_INFO, 3016 + LOG_MBOX | LOG_SLI | LOG_NODE, 3017 3017 "4111 UNREG cmpl deferred " 3018 3018 "clr x%x on " 3019 3019 "NPort x%x Data: x%x x%px\n", ··· 3938 3936 3939 3937 phba = from_timer(phba, t, eratt_poll); 3940 3938 if (!(phba->hba_flag & HBA_SETUP)) 3939 + return; 3940 + 3941 + if (phba->pport->load_flag & FC_UNLOADING) 3941 3942 return; 3942 3943 3943 3944 /* Here we will also keep track of interrupts per sec of the hba */ ··· 10146 10141 spin_unlock_irqrestore(&phba->hbalock, iflags); 10147 10142 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 10148 10143 "(%d):0354 Mbox cmd issue - Enqueue Data: " 10149 - "x%x (x%x/x%x) x%x x%x x%x\n", 10144 + "x%x (x%x/x%x) x%x x%x x%x x%x\n", 10150 10145 mboxq->vport ? mboxq->vport->vpi : 0xffffff, 10151 10146 bf_get(lpfc_mqe_command, &mboxq->u.mqe), 10152 10147 lpfc_sli_config_mbox_subsys_get(phba, mboxq), 10153 10148 lpfc_sli_config_mbox_opcode_get(phba, mboxq), 10149 + mboxq->u.mb.un.varUnregLogin.rpi, 10154 10150 phba->pport->port_state, 10155 10151 psli->sli_flag, MBX_NOWAIT); 10156 10152 /* Wake up worker thread to transport mailbox command from head */ ··· 22173 22167 * The data will be truncated if datasz is not large enough. 22174 22168 * Version 1 is not supported with Embedded mbox cmd, so we must use version 0. 22175 22169 * Returns the actual bytes read from the object. 22170 + * 22171 + * This routine is hard coded to use a poll completion. Unlike other 22172 + * sli4_config mailboxes, it uses lpfc_mbuf memory which is not 22173 + * cleaned up in lpfc_sli4_cmd_mbox_free. If this routine is modified 22174 + * to use interrupt-based completions, code is needed to fully cleanup 22175 + * the memory. 22176 22176 */ 22177 22177 int 22178 22178 lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap,
+6 -4
drivers/scsi/lpfc/lpfc_sli.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-2022 Broadcom. All Rights Reserved. The term * 4 + * Copyright (C) 2017-2023 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. * ··· 182 182 struct lpfc_mqe mqe; 183 183 } u; 184 184 struct lpfc_vport *vport; /* virtual port pointer */ 185 - void *ctx_ndlp; /* caller ndlp information */ 186 - void *ctx_buf; /* caller buffer information */ 187 - void *context3; 185 + void *ctx_ndlp; /* an lpfc_nodelist pointer */ 186 + void *ctx_buf; /* an lpfc_dmabuf pointer */ 187 + void *context3; /* a generic pointer. Code must 188 + * accommodate the actual datatype. 189 + */ 188 190 189 191 void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); 190 192 uint8_t mbox_flag;
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "14.2.0.15" 23 + #define LPFC_DRIVER_VERSION "14.2.0.17" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */
+1
drivers/scsi/lpfc/lpfc_vmid.c
··· 321 321 if (!hash_empty(vport->hash_table)) 322 322 hash_for_each_safe(vport->hash_table, bucket, tmp, cur, hnode) 323 323 hash_del(&cur->hnode); 324 + vport->vmid_flag = 0; 324 325 write_unlock(&vport->vmid_lock); 325 326 }
+2 -4
drivers/scsi/mac_esp.c
··· 407 407 return err; 408 408 } 409 409 410 - static int esp_mac_remove(struct platform_device *dev) 410 + static void esp_mac_remove(struct platform_device *dev) 411 411 { 412 412 struct mac_esp_priv *mep = platform_get_drvdata(dev); 413 413 struct esp *esp = mep->esp; ··· 428 428 kfree(esp->command_block); 429 429 430 430 scsi_host_put(esp->host); 431 - 432 - return 0; 433 431 } 434 432 435 433 static struct platform_driver esp_mac_driver = { 436 434 .probe = esp_mac_probe, 437 - .remove = esp_mac_remove, 435 + .remove_new = esp_mac_remove, 438 436 .driver = { 439 437 .name = DRV_MODULE_NAME, 440 438 },
+2 -3
drivers/scsi/mac_scsi.c
··· 523 523 return error; 524 524 } 525 525 526 - static int __exit mac_scsi_remove(struct platform_device *pdev) 526 + static void __exit mac_scsi_remove(struct platform_device *pdev) 527 527 { 528 528 struct Scsi_Host *instance = platform_get_drvdata(pdev); 529 529 ··· 532 532 free_irq(instance->irq, instance); 533 533 NCR5380_exit(instance); 534 534 scsi_host_put(instance); 535 - return 0; 536 535 } 537 536 538 537 static struct platform_driver mac_scsi_driver = { 539 - .remove = __exit_p(mac_scsi_remove), 538 + .remove_new = __exit_p(mac_scsi_remove), 540 539 .driver = { 541 540 .name = DRV_MODULE_NAME, 542 541 },
+1
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h
··· 28 28 __le64 driver_information_address; 29 29 }; 30 30 31 + #define MPI3_IOCINIT_MSGFLAGS_SCSIIOSTATUSREPLY_SUPPORTED (0x04) 31 32 #define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_MASK (0x03) 32 33 #define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_NOT_USED (0x00) 33 34 #define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_SEPARATED (0x01)
+26 -7
drivers/scsi/mpi3mr/mpi3mr.h
··· 55 55 extern int prot_mask; 56 56 extern atomic64_t event_counter; 57 57 58 - #define MPI3MR_DRIVER_VERSION "8.5.0.0.0" 59 - #define MPI3MR_DRIVER_RELDATE "24-July-2023" 58 + #define MPI3MR_DRIVER_VERSION "8.5.1.0.0" 59 + #define MPI3MR_DRIVER_RELDATE "5-December-2023" 60 60 61 61 #define MPI3MR_DRIVER_NAME "mpi3mr" 62 62 #define MPI3MR_DRIVER_LICENSE "GPL" ··· 218 218 * @length: SGE length 219 219 * @rsvd: Reserved 220 220 * @rsvd1: Reserved 221 - * @sgl_type: sgl type 221 + * @sub_type: sgl sub type 222 + * @type: sgl type 222 223 */ 223 224 struct mpi3mr_nvme_pt_sge { 224 - u64 base_addr; 225 - u32 length; 225 + __le64 base_addr; 226 + __le32 length; 226 227 u16 rsvd; 227 228 u8 rsvd1; 228 - u8 sgl_type; 229 + u8 sub_type:4; 230 + u8 type:4; 229 231 }; 230 232 231 233 /** ··· 249 247 u32 kern_buf_len; 250 248 dma_addr_t kern_buf_dma; 251 249 u8 data_dir; 250 + u16 num_dma_desc; 251 + struct dma_memory_desc *dma_desc; 252 252 }; 253 253 254 254 /* IOC State definitions */ ··· 481 477 /* HBA port flags */ 482 478 #define MPI3MR_HBA_PORT_FLAG_DIRTY 0x01 483 479 480 + /* IOCTL data transfer sge*/ 481 + #define MPI3MR_NUM_IOCTL_SGE 256 482 + #define MPI3MR_IOCTL_SGE_SIZE (8 * 1024) 483 + 484 484 /** 485 485 * struct mpi3mr_hba_port - HBA's port information 486 486 * @port_id: Port number ··· 514 506 u8 num_phys; 515 507 u8 marked_responding; 516 508 int lowest_phy; 517 - u32 phy_mask; 509 + u64 phy_mask; 518 510 struct mpi3mr_hba_port *hba_port; 519 511 struct sas_identify remote_identify; 520 512 struct sas_rphy *rphy; ··· 1050 1042 * @sas_node_lock: Lock to protect SAS node list 1051 1043 * @hba_port_table_list: List of HBA Ports 1052 1044 * @enclosure_list: List of Enclosure objects 1045 + * @ioctl_dma_pool: DMA pool for IOCTL data buffers 1046 + * @ioctl_sge: DMA buffer descriptors for IOCTL data 1047 + * @ioctl_chain_sge: DMA buffer descriptor for IOCTL chain 1048 + * @ioctl_resp_sge: DMA buffer descriptor for Mgmt cmd response 1049 + * @ioctl_sges_allocated: Flag for IOCTL SGEs allocated or not 1053 1050 */ 1054 1051 struct mpi3mr_ioc { 1055 1052 struct list_head list; ··· 1240 1227 spinlock_t sas_node_lock; 1241 1228 struct list_head hba_port_table_list; 1242 1229 struct list_head enclosure_list; 1230 + 1231 + struct dma_pool *ioctl_dma_pool; 1232 + struct dma_memory_desc ioctl_sge[MPI3MR_NUM_IOCTL_SGE]; 1233 + struct dma_memory_desc ioctl_chain_sge; 1234 + struct dma_memory_desc ioctl_resp_sge; 1235 + bool ioctl_sges_allocated; 1243 1236 }; 1244 1237 1245 1238 /**
+428 -108
drivers/scsi/mpi3mr/mpi3mr_app.c
··· 223 223 return rval; 224 224 } 225 225 226 + if (mrioc->unrecoverable) { 227 + dprint_bsg_err(mrioc, "%s: unrecoverable controller\n", 228 + __func__); 229 + return -EFAULT; 230 + } 231 + 232 + if (mrioc->reset_in_progress) { 233 + dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__); 234 + return -EAGAIN; 235 + } 236 + 237 + if (mrioc->stop_bsgs) { 238 + dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__); 239 + return -EAGAIN; 240 + } 241 + 226 242 sg_copy_to_buffer(job->request_payload.sg_list, 227 243 job->request_payload.sg_cnt, 228 244 &pel_enable, sizeof(pel_enable)); ··· 564 548 } 565 549 566 550 /** 551 + * mpi3mr_total_num_ioctl_sges - Count number of SGEs required 552 + * @drv_bufs: DMA address of the buffers to be placed in sgl 553 + * @bufcnt: Number of DMA buffers 554 + * 555 + * This function returns total number of data SGEs required 556 + * including zero length SGEs and excluding management request 557 + * and response buffer for the given list of data buffer 558 + * descriptors 559 + * 560 + * Return: Number of SGE elements needed 561 + */ 562 + static inline u16 mpi3mr_total_num_ioctl_sges(struct mpi3mr_buf_map *drv_bufs, 563 + u8 bufcnt) 564 + { 565 + u16 i, sge_count = 0; 566 + 567 + for (i = 0; i < bufcnt; i++, drv_bufs++) { 568 + if (drv_bufs->data_dir == DMA_NONE || 569 + drv_bufs->kern_buf) 570 + continue; 571 + sge_count += drv_bufs->num_dma_desc; 572 + if (!drv_bufs->num_dma_desc) 573 + sge_count++; 574 + } 575 + return sge_count; 576 + } 577 + 578 + /** 567 579 * mpi3mr_bsg_build_sgl - SGL construction for MPI commands 580 + * @mrioc: Adapter instance reference 568 581 * @mpi_req: MPI request 569 582 * @sgl_offset: offset to start sgl in the MPI request 570 583 * @drv_bufs: DMA address of the buffers to be placed in sgl ··· 605 560 * This function places the DMA address of the given buffers in 606 561 * proper format as SGEs in the given MPI request. 607 562 * 608 - * Return: Nothing 563 + * Return: 0 on success,-1 on failure 609 564 */ 610 - static void mpi3mr_bsg_build_sgl(u8 *mpi_req, uint32_t sgl_offset, 611 - struct mpi3mr_buf_map *drv_bufs, u8 bufcnt, u8 is_rmc, 612 - u8 is_rmr, u8 num_datasges) 565 + static int mpi3mr_bsg_build_sgl(struct mpi3mr_ioc *mrioc, u8 *mpi_req, 566 + u32 sgl_offset, struct mpi3mr_buf_map *drv_bufs, 567 + u8 bufcnt, u8 is_rmc, u8 is_rmr, u8 num_datasges) 613 568 { 569 + struct mpi3_request_header *mpi_header = 570 + (struct mpi3_request_header *)mpi_req; 614 571 u8 *sgl = (mpi_req + sgl_offset), count = 0; 615 572 struct mpi3_mgmt_passthrough_request *rmgmt_req = 616 573 (struct mpi3_mgmt_passthrough_request *)mpi_req; 617 574 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; 618 - u8 sgl_flags, sgl_flags_last; 575 + u8 flag, sgl_flags, sgl_flag_eob, sgl_flags_last, last_chain_sgl_flag; 576 + u16 available_sges, i, sges_needed; 577 + u32 sge_element_size = sizeof(struct mpi3_sge_common); 578 + bool chain_used = false; 619 579 620 580 sgl_flags = MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | 621 - MPI3_SGE_FLAGS_DLAS_SYSTEM | MPI3_SGE_FLAGS_END_OF_BUFFER; 622 - sgl_flags_last = sgl_flags | MPI3_SGE_FLAGS_END_OF_LIST; 581 + MPI3_SGE_FLAGS_DLAS_SYSTEM; 582 + sgl_flag_eob = sgl_flags | MPI3_SGE_FLAGS_END_OF_BUFFER; 583 + sgl_flags_last = sgl_flag_eob | MPI3_SGE_FLAGS_END_OF_LIST; 584 + last_chain_sgl_flag = MPI3_SGE_FLAGS_ELEMENT_TYPE_LAST_CHAIN | 585 + MPI3_SGE_FLAGS_DLAS_SYSTEM; 586 + 587 + sges_needed = mpi3mr_total_num_ioctl_sges(drv_bufs, bufcnt); 623 588 624 589 if (is_rmc) { 625 590 mpi3mr_add_sg_single(&rmgmt_req->command_sgl, 626 591 sgl_flags_last, drv_buf_iter->kern_buf_len, 627 592 drv_buf_iter->kern_buf_dma); 628 - sgl = (u8 *)drv_buf_iter->kern_buf + drv_buf_iter->bsg_buf_len; 593 + sgl = (u8 *)drv_buf_iter->kern_buf + 594 + drv_buf_iter->bsg_buf_len; 595 + available_sges = (drv_buf_iter->kern_buf_len - 596 + drv_buf_iter->bsg_buf_len) / sge_element_size; 597 + 598 + if (sges_needed > available_sges) 599 + return -1; 600 + 601 + chain_used = true; 629 602 drv_buf_iter++; 630 603 count++; 631 604 if (is_rmr) { ··· 655 592 } else 656 593 mpi3mr_build_zero_len_sge( 657 594 &rmgmt_req->response_sgl); 595 + if (num_datasges) { 596 + i = 0; 597 + goto build_sges; 598 + } 599 + } else { 600 + if (sgl_offset >= MPI3MR_ADMIN_REQ_FRAME_SZ) 601 + return -1; 602 + available_sges = (MPI3MR_ADMIN_REQ_FRAME_SZ - sgl_offset) / 603 + sge_element_size; 604 + if (!available_sges) 605 + return -1; 658 606 } 659 607 if (!num_datasges) { 660 608 mpi3mr_build_zero_len_sge(sgl); 661 - return; 609 + return 0; 662 610 } 611 + if (mpi_header->function == MPI3_BSG_FUNCTION_SMP_PASSTHROUGH) { 612 + if ((sges_needed > 2) || (sges_needed > available_sges)) 613 + return -1; 614 + for (; count < bufcnt; count++, drv_buf_iter++) { 615 + if (drv_buf_iter->data_dir == DMA_NONE || 616 + !drv_buf_iter->num_dma_desc) 617 + continue; 618 + mpi3mr_add_sg_single(sgl, sgl_flags_last, 619 + drv_buf_iter->dma_desc[0].size, 620 + drv_buf_iter->dma_desc[0].dma_addr); 621 + sgl += sge_element_size; 622 + } 623 + return 0; 624 + } 625 + i = 0; 626 + 627 + build_sges: 663 628 for (; count < bufcnt; count++, drv_buf_iter++) { 664 629 if (drv_buf_iter->data_dir == DMA_NONE) 665 630 continue; 666 - if (num_datasges == 1 || !is_rmc) 667 - mpi3mr_add_sg_single(sgl, sgl_flags_last, 668 - drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma); 669 - else 670 - mpi3mr_add_sg_single(sgl, sgl_flags, 671 - drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma); 672 - sgl += sizeof(struct mpi3_sge_common); 631 + if (!drv_buf_iter->num_dma_desc) { 632 + if (chain_used && !available_sges) 633 + return -1; 634 + if (!chain_used && (available_sges == 1) && 635 + (sges_needed > 1)) 636 + goto setup_chain; 637 + flag = sgl_flag_eob; 638 + if (num_datasges == 1) 639 + flag = sgl_flags_last; 640 + mpi3mr_add_sg_single(sgl, flag, 0, 0); 641 + sgl += sge_element_size; 642 + sges_needed--; 643 + available_sges--; 644 + num_datasges--; 645 + continue; 646 + } 647 + for (; i < drv_buf_iter->num_dma_desc; i++) { 648 + if (chain_used && !available_sges) 649 + return -1; 650 + if (!chain_used && (available_sges == 1) && 651 + (sges_needed > 1)) 652 + goto setup_chain; 653 + flag = sgl_flags; 654 + if (i == (drv_buf_iter->num_dma_desc - 1)) { 655 + if (num_datasges == 1) 656 + flag = sgl_flags_last; 657 + else 658 + flag = sgl_flag_eob; 659 + } 660 + 661 + mpi3mr_add_sg_single(sgl, flag, 662 + drv_buf_iter->dma_desc[i].size, 663 + drv_buf_iter->dma_desc[i].dma_addr); 664 + sgl += sge_element_size; 665 + available_sges--; 666 + sges_needed--; 667 + } 673 668 num_datasges--; 669 + i = 0; 674 670 } 671 + return 0; 672 + 673 + setup_chain: 674 + available_sges = mrioc->ioctl_chain_sge.size / sge_element_size; 675 + if (sges_needed > available_sges) 676 + return -1; 677 + mpi3mr_add_sg_single(sgl, last_chain_sgl_flag, 678 + (sges_needed * sge_element_size), 679 + mrioc->ioctl_chain_sge.dma_addr); 680 + memset(mrioc->ioctl_chain_sge.addr, 0, mrioc->ioctl_chain_sge.size); 681 + sgl = (u8 *)mrioc->ioctl_chain_sge.addr; 682 + chain_used = true; 683 + goto build_sges; 675 684 } 676 685 677 686 /** ··· 783 648 struct mpi3mr_buf_map *drv_bufs, u8 bufcnt) 784 649 { 785 650 struct mpi3mr_nvme_pt_sge *nvme_sgl; 786 - u64 sgl_ptr; 651 + __le64 sgl_dma; 787 652 u8 count; 788 653 size_t length = 0; 654 + u16 available_sges = 0, i; 655 + u32 sge_element_size = sizeof(struct mpi3mr_nvme_pt_sge); 789 656 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; 790 657 u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) << 791 658 mrioc->facts.sge_mod_shift) << 32); 792 659 u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) << 793 660 mrioc->facts.sge_mod_shift) << 32; 661 + u32 size; 662 + 663 + nvme_sgl = (struct mpi3mr_nvme_pt_sge *) 664 + ((u8 *)(nvme_encap_request->command) + MPI3MR_NVME_CMD_SGL_OFFSET); 794 665 795 666 /* 796 667 * Not all commands require a data transfer. If no data, just return ··· 805 664 for (count = 0; count < bufcnt; count++, drv_buf_iter++) { 806 665 if (drv_buf_iter->data_dir == DMA_NONE) 807 666 continue; 808 - sgl_ptr = (u64)drv_buf_iter->kern_buf_dma; 809 667 length = drv_buf_iter->kern_buf_len; 810 668 break; 811 669 } 812 - if (!length) 670 + if (!length || !drv_buf_iter->num_dma_desc) 813 671 return 0; 814 672 815 - if (sgl_ptr & sgemod_mask) { 673 + if (drv_buf_iter->num_dma_desc == 1) { 674 + available_sges = 1; 675 + goto build_sges; 676 + } 677 + 678 + sgl_dma = cpu_to_le64(mrioc->ioctl_chain_sge.dma_addr); 679 + if (sgl_dma & sgemod_mask) { 816 680 dprint_bsg_err(mrioc, 817 - "%s: SGL address collides with SGE modifier\n", 681 + "%s: SGL chain address collides with SGE modifier\n", 818 682 __func__); 819 683 return -1; 820 684 } 821 685 822 - sgl_ptr &= ~sgemod_mask; 823 - sgl_ptr |= sgemod_val; 824 - nvme_sgl = (struct mpi3mr_nvme_pt_sge *) 825 - ((u8 *)(nvme_encap_request->command) + MPI3MR_NVME_CMD_SGL_OFFSET); 686 + sgl_dma &= ~sgemod_mask; 687 + sgl_dma |= sgemod_val; 688 + 689 + memset(mrioc->ioctl_chain_sge.addr, 0, mrioc->ioctl_chain_sge.size); 690 + available_sges = mrioc->ioctl_chain_sge.size / sge_element_size; 691 + if (available_sges < drv_buf_iter->num_dma_desc) 692 + return -1; 826 693 memset(nvme_sgl, 0, sizeof(struct mpi3mr_nvme_pt_sge)); 827 - nvme_sgl->base_addr = sgl_ptr; 828 - nvme_sgl->length = length; 694 + nvme_sgl->base_addr = sgl_dma; 695 + size = drv_buf_iter->num_dma_desc * sizeof(struct mpi3mr_nvme_pt_sge); 696 + nvme_sgl->length = cpu_to_le32(size); 697 + nvme_sgl->type = MPI3MR_NVMESGL_LAST_SEGMENT; 698 + nvme_sgl = (struct mpi3mr_nvme_pt_sge *)mrioc->ioctl_chain_sge.addr; 699 + 700 + build_sges: 701 + for (i = 0; i < drv_buf_iter->num_dma_desc; i++) { 702 + sgl_dma = cpu_to_le64(drv_buf_iter->dma_desc[i].dma_addr); 703 + if (sgl_dma & sgemod_mask) { 704 + dprint_bsg_err(mrioc, 705 + "%s: SGL address collides with SGE modifier\n", 706 + __func__); 707 + return -1; 708 + } 709 + 710 + sgl_dma &= ~sgemod_mask; 711 + sgl_dma |= sgemod_val; 712 + 713 + nvme_sgl->base_addr = sgl_dma; 714 + nvme_sgl->length = cpu_to_le32(drv_buf_iter->dma_desc[i].size); 715 + nvme_sgl->type = MPI3MR_NVMESGL_DATA_SEGMENT; 716 + nvme_sgl++; 717 + available_sges--; 718 + } 719 + 829 720 return 0; 830 721 } 831 722 ··· 885 712 dma_addr_t prp_entry_dma, prp_page_dma, dma_addr; 886 713 u32 offset, entry_len, dev_pgsz; 887 714 u32 page_mask_result, page_mask; 888 - size_t length = 0; 715 + size_t length = 0, desc_len; 889 716 u8 count; 890 717 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; 891 718 u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) << ··· 894 721 mrioc->facts.sge_mod_shift) << 32; 895 722 u16 dev_handle = nvme_encap_request->dev_handle; 896 723 struct mpi3mr_tgt_dev *tgtdev; 724 + u16 desc_count = 0; 897 725 898 726 tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle); 899 727 if (!tgtdev) { ··· 913 739 914 740 dev_pgsz = 1 << (tgtdev->dev_spec.pcie_inf.pgsz); 915 741 mpi3mr_tgtdev_put(tgtdev); 742 + page_mask = dev_pgsz - 1; 743 + 744 + if (dev_pgsz > MPI3MR_IOCTL_SGE_SIZE) { 745 + dprint_bsg_err(mrioc, 746 + "%s: NVMe device page size(%d) is greater than ioctl data sge size(%d) for handle 0x%04x\n", 747 + __func__, dev_pgsz, MPI3MR_IOCTL_SGE_SIZE, dev_handle); 748 + return -1; 749 + } 750 + 751 + if (MPI3MR_IOCTL_SGE_SIZE % dev_pgsz) { 752 + dprint_bsg_err(mrioc, 753 + "%s: ioctl data sge size(%d) is not a multiple of NVMe device page size(%d) for handle 0x%04x\n", 754 + __func__, MPI3MR_IOCTL_SGE_SIZE, dev_pgsz, dev_handle); 755 + return -1; 756 + } 916 757 917 758 /* 918 759 * Not all commands require a data transfer. If no data, just return ··· 936 747 for (count = 0; count < bufcnt; count++, drv_buf_iter++) { 937 748 if (drv_buf_iter->data_dir == DMA_NONE) 938 749 continue; 939 - dma_addr = drv_buf_iter->kern_buf_dma; 940 750 length = drv_buf_iter->kern_buf_len; 941 751 break; 942 752 } 943 753 944 - if (!length) 754 + if (!length || !drv_buf_iter->num_dma_desc) 945 755 return 0; 756 + 757 + for (count = 0; count < drv_buf_iter->num_dma_desc; count++) { 758 + dma_addr = drv_buf_iter->dma_desc[count].dma_addr; 759 + if (dma_addr & page_mask) { 760 + dprint_bsg_err(mrioc, 761 + "%s:dma_addr %pad is not aligned with page size 0x%x\n", 762 + __func__, &dma_addr, dev_pgsz); 763 + return -1; 764 + } 765 + } 766 + 767 + dma_addr = drv_buf_iter->dma_desc[0].dma_addr; 768 + desc_len = drv_buf_iter->dma_desc[0].size; 946 769 947 770 mrioc->prp_sz = 0; 948 771 mrioc->prp_list_virt = dma_alloc_coherent(&mrioc->pdev->dev, ··· 985 784 * Check if we are within 1 entry of a page boundary we don't 986 785 * want our first entry to be a PRP List entry. 987 786 */ 988 - page_mask = dev_pgsz - 1; 989 787 page_mask_result = (uintptr_t)((u8 *)prp_page + prp_size) & page_mask; 990 788 if (!page_mask_result) { 991 789 dprint_bsg_err(mrioc, "%s: PRP page is not page aligned\n", ··· 1098 898 prp_entry_dma += prp_size; 1099 899 } 1100 900 1101 - /* 1102 - * Bump the phys address of the command's data buffer by the 1103 - * entry_len. 1104 - */ 1105 - dma_addr += entry_len; 1106 - 1107 901 /* decrement length accounting for last partial page. */ 1108 - if (entry_len > length) 902 + if (entry_len >= length) { 1109 903 length = 0; 1110 - else 904 + } else { 905 + if (entry_len <= desc_len) { 906 + dma_addr += entry_len; 907 + desc_len -= entry_len; 908 + } 909 + if (!desc_len) { 910 + if ((++desc_count) >= 911 + drv_buf_iter->num_dma_desc) { 912 + dprint_bsg_err(mrioc, 913 + "%s: Invalid len %zd while building PRP\n", 914 + __func__, length); 915 + goto err_out; 916 + } 917 + dma_addr = 918 + drv_buf_iter->dma_desc[desc_count].dma_addr; 919 + desc_len = 920 + drv_buf_iter->dma_desc[desc_count].size; 921 + } 1111 922 length -= entry_len; 923 + } 1112 924 } 925 + 1113 926 return 0; 1114 927 err_out: 1115 928 if (mrioc->prp_list_virt) { ··· 1132 919 } 1133 920 return -1; 1134 921 } 922 + 923 + /** 924 + * mpi3mr_map_data_buffer_dma - build dma descriptors for data 925 + * buffers 926 + * @mrioc: Adapter instance reference 927 + * @drv_buf: buffer map descriptor 928 + * @desc_count: Number of already consumed dma descriptors 929 + * 930 + * This function computes how many pre-allocated DMA descriptors 931 + * are required for the given data buffer and if those number of 932 + * descriptors are free, then setup the mapping of the scattered 933 + * DMA address to the given data buffer, if the data direction 934 + * of the buffer is DMA_TO_DEVICE then the actual data is copied to 935 + * the DMA buffers 936 + * 937 + * Return: 0 on success, -1 on failure 938 + */ 939 + static int mpi3mr_map_data_buffer_dma(struct mpi3mr_ioc *mrioc, 940 + struct mpi3mr_buf_map *drv_buf, 941 + u16 desc_count) 942 + { 943 + u16 i, needed_desc = drv_buf->kern_buf_len / MPI3MR_IOCTL_SGE_SIZE; 944 + u32 buf_len = drv_buf->kern_buf_len, copied_len = 0; 945 + 946 + if (drv_buf->kern_buf_len % MPI3MR_IOCTL_SGE_SIZE) 947 + needed_desc++; 948 + if ((needed_desc + desc_count) > MPI3MR_NUM_IOCTL_SGE) { 949 + dprint_bsg_err(mrioc, "%s: DMA descriptor mapping error %d:%d:%d\n", 950 + __func__, needed_desc, desc_count, MPI3MR_NUM_IOCTL_SGE); 951 + return -1; 952 + } 953 + drv_buf->dma_desc = kzalloc(sizeof(*drv_buf->dma_desc) * needed_desc, 954 + GFP_KERNEL); 955 + if (!drv_buf->dma_desc) 956 + return -1; 957 + for (i = 0; i < needed_desc; i++, desc_count++) { 958 + drv_buf->dma_desc[i].addr = mrioc->ioctl_sge[desc_count].addr; 959 + drv_buf->dma_desc[i].dma_addr = 960 + mrioc->ioctl_sge[desc_count].dma_addr; 961 + if (buf_len < mrioc->ioctl_sge[desc_count].size) 962 + drv_buf->dma_desc[i].size = buf_len; 963 + else 964 + drv_buf->dma_desc[i].size = 965 + mrioc->ioctl_sge[desc_count].size; 966 + buf_len -= drv_buf->dma_desc[i].size; 967 + memset(drv_buf->dma_desc[i].addr, 0, 968 + mrioc->ioctl_sge[desc_count].size); 969 + if (drv_buf->data_dir == DMA_TO_DEVICE) { 970 + memcpy(drv_buf->dma_desc[i].addr, 971 + drv_buf->bsg_buf + copied_len, 972 + drv_buf->dma_desc[i].size); 973 + copied_len += drv_buf->dma_desc[i].size; 974 + } 975 + } 976 + drv_buf->num_dma_desc = needed_desc; 977 + return 0; 978 + } 1135 979 /** 1136 980 * mpi3mr_bsg_process_mpt_cmds - MPI Pass through BSG handler 1137 981 * @job: BSG job reference 1138 - * @reply_payload_rcv_len: length of payload recvd 1139 982 * 1140 983 * This function is the top level handler for MPI Pass through 1141 984 * command, this does basic validation of the input data buffers, ··· 1207 938 * Return: 0 on success and proper error codes on failure 1208 939 */ 1209 940 1210 - static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply_payload_rcv_len) 941 + static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) 1211 942 { 1212 943 long rval = -EINVAL; 1213 - 1214 944 struct mpi3mr_ioc *mrioc = NULL; 1215 945 u8 *mpi_req = NULL, *sense_buff_k = NULL; 1216 946 u8 mpi_msg_size = 0; ··· 1217 949 struct mpi3mr_bsg_mptcmd *karg; 1218 950 struct mpi3mr_buf_entry *buf_entries = NULL; 1219 951 struct mpi3mr_buf_map *drv_bufs = NULL, *drv_buf_iter = NULL; 1220 - u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0, din_cnt = 0, dout_cnt = 0; 1221 - u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF, sg_entries = 0; 1222 - u8 block_io = 0, resp_code = 0, nvme_fmt = 0; 952 + u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0; 953 + u8 din_cnt = 0, dout_cnt = 0; 954 + u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF; 955 + u8 block_io = 0, nvme_fmt = 0, resp_code = 0; 1223 956 struct mpi3_request_header *mpi_header = NULL; 1224 957 struct mpi3_status_reply_descriptor *status_desc; 1225 958 struct mpi3_scsi_task_mgmt_request *tm_req; ··· 1232 963 u32 din_size = 0, dout_size = 0; 1233 964 u8 *din_buf = NULL, *dout_buf = NULL; 1234 965 u8 *sgl_iter = NULL, *sgl_din_iter = NULL, *sgl_dout_iter = NULL; 966 + u16 rmc_size = 0, desc_count = 0; 1235 967 1236 968 bsg_req = job->request; 1237 969 karg = (struct mpi3mr_bsg_mptcmd *)&bsg_req->cmd.mptcmd; ··· 1240 970 mrioc = mpi3mr_bsg_verify_adapter(karg->mrioc_id); 1241 971 if (!mrioc) 1242 972 return -ENODEV; 973 + 974 + if (!mrioc->ioctl_sges_allocated) { 975 + dprint_bsg_err(mrioc, "%s: DMA memory was not allocated\n", 976 + __func__); 977 + return -ENOMEM; 978 + } 1243 979 1244 980 if (karg->timeout < MPI3MR_APP_DEFAULT_TIMEOUT) 1245 981 karg->timeout = MPI3MR_APP_DEFAULT_TIMEOUT; ··· 1287 1011 1288 1012 for (count = 0; count < bufcnt; count++, buf_entries++, drv_buf_iter++) { 1289 1013 1290 - if (sgl_dout_iter > (dout_buf + job->request_payload.payload_len)) { 1291 - dprint_bsg_err(mrioc, "%s: data_out buffer length mismatch\n", 1292 - __func__); 1293 - rval = -EINVAL; 1294 - goto out; 1295 - } 1296 - if (sgl_din_iter > (din_buf + job->reply_payload.payload_len)) { 1297 - dprint_bsg_err(mrioc, "%s: data_in buffer length mismatch\n", 1298 - __func__); 1299 - rval = -EINVAL; 1300 - goto out; 1301 - } 1302 - 1303 1014 switch (buf_entries->buf_type) { 1304 1015 case MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD: 1305 1016 sgl_iter = sgl_dout_iter; 1306 1017 sgl_dout_iter += buf_entries->buf_len; 1307 1018 drv_buf_iter->data_dir = DMA_TO_DEVICE; 1308 1019 is_rmcb = 1; 1309 - if (count != 0) 1020 + if ((count != 0) || !buf_entries->buf_len) 1310 1021 invalid_be = 1; 1311 1022 break; 1312 1023 case MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP: ··· 1301 1038 sgl_din_iter += buf_entries->buf_len; 1302 1039 drv_buf_iter->data_dir = DMA_FROM_DEVICE; 1303 1040 is_rmrb = 1; 1304 - if (count != 1 || !is_rmcb) 1041 + if (count != 1 || !is_rmcb || !buf_entries->buf_len) 1305 1042 invalid_be = 1; 1306 1043 break; 1307 1044 case MPI3MR_BSG_BUFTYPE_DATA_IN: ··· 1309 1046 sgl_din_iter += buf_entries->buf_len; 1310 1047 drv_buf_iter->data_dir = DMA_FROM_DEVICE; 1311 1048 din_cnt++; 1312 - din_size += drv_buf_iter->bsg_buf_len; 1049 + din_size += buf_entries->buf_len; 1313 1050 if ((din_cnt > 1) && !is_rmcb) 1314 1051 invalid_be = 1; 1315 1052 break; ··· 1318 1055 sgl_dout_iter += buf_entries->buf_len; 1319 1056 drv_buf_iter->data_dir = DMA_TO_DEVICE; 1320 1057 dout_cnt++; 1321 - dout_size += drv_buf_iter->bsg_buf_len; 1058 + dout_size += buf_entries->buf_len; 1322 1059 if ((dout_cnt > 1) && !is_rmcb) 1323 1060 invalid_be = 1; 1324 1061 break; ··· 1327 1064 sgl_din_iter += buf_entries->buf_len; 1328 1065 drv_buf_iter->data_dir = DMA_NONE; 1329 1066 mpirep_offset = count; 1067 + if (!buf_entries->buf_len) 1068 + invalid_be = 1; 1330 1069 break; 1331 1070 case MPI3MR_BSG_BUFTYPE_ERR_RESPONSE: 1332 1071 sgl_iter = sgl_din_iter; 1333 1072 sgl_din_iter += buf_entries->buf_len; 1334 1073 drv_buf_iter->data_dir = DMA_NONE; 1335 1074 erb_offset = count; 1075 + if (!buf_entries->buf_len) 1076 + invalid_be = 1; 1336 1077 break; 1337 1078 case MPI3MR_BSG_BUFTYPE_MPI_REQUEST: 1338 1079 sgl_iter = sgl_dout_iter; ··· 1363 1096 goto out; 1364 1097 } 1365 1098 1366 - drv_buf_iter->bsg_buf = sgl_iter; 1367 - drv_buf_iter->bsg_buf_len = buf_entries->buf_len; 1368 - 1369 - } 1370 - if (!is_rmcb && (dout_cnt || din_cnt)) { 1371 - sg_entries = dout_cnt + din_cnt; 1372 - if (((mpi_msg_size) + (sg_entries * 1373 - sizeof(struct mpi3_sge_common))) > MPI3MR_ADMIN_REQ_FRAME_SZ) { 1374 - dprint_bsg_err(mrioc, 1375 - "%s:%d: invalid message size passed\n", 1376 - __func__, __LINE__); 1099 + if (sgl_dout_iter > (dout_buf + job->request_payload.payload_len)) { 1100 + dprint_bsg_err(mrioc, "%s: data_out buffer length mismatch\n", 1101 + __func__); 1377 1102 rval = -EINVAL; 1378 1103 goto out; 1379 1104 } 1105 + if (sgl_din_iter > (din_buf + job->reply_payload.payload_len)) { 1106 + dprint_bsg_err(mrioc, "%s: data_in buffer length mismatch\n", 1107 + __func__); 1108 + rval = -EINVAL; 1109 + goto out; 1110 + } 1111 + 1112 + drv_buf_iter->bsg_buf = sgl_iter; 1113 + drv_buf_iter->bsg_buf_len = buf_entries->buf_len; 1380 1114 } 1115 + 1116 + if (is_rmcb && ((din_size + dout_size) > MPI3MR_MAX_APP_XFER_SIZE)) { 1117 + dprint_bsg_err(mrioc, "%s:%d: invalid data transfer size passed for function 0x%x din_size = %d, dout_size = %d\n", 1118 + __func__, __LINE__, mpi_header->function, din_size, 1119 + dout_size); 1120 + rval = -EINVAL; 1121 + goto out; 1122 + } 1123 + 1381 1124 if (din_size > MPI3MR_MAX_APP_XFER_SIZE) { 1382 1125 dprint_bsg_err(mrioc, 1383 1126 "%s:%d: invalid data transfer size passed for function 0x%x din_size=%d\n", ··· 1403 1126 goto out; 1404 1127 } 1405 1128 1129 + if (mpi_header->function == MPI3_BSG_FUNCTION_SMP_PASSTHROUGH) { 1130 + if (din_size > MPI3MR_IOCTL_SGE_SIZE || 1131 + dout_size > MPI3MR_IOCTL_SGE_SIZE) { 1132 + dprint_bsg_err(mrioc, "%s:%d: invalid message size passed:%d:%d:%d:%d\n", 1133 + __func__, __LINE__, din_cnt, dout_cnt, din_size, 1134 + dout_size); 1135 + rval = -EINVAL; 1136 + goto out; 1137 + } 1138 + } 1139 + 1406 1140 drv_buf_iter = drv_bufs; 1407 1141 for (count = 0; count < bufcnt; count++, drv_buf_iter++) { 1408 1142 if (drv_buf_iter->data_dir == DMA_NONE) 1409 1143 continue; 1410 1144 1411 1145 drv_buf_iter->kern_buf_len = drv_buf_iter->bsg_buf_len; 1412 - if (is_rmcb && !count) 1413 - drv_buf_iter->kern_buf_len += ((dout_cnt + din_cnt) * 1414 - sizeof(struct mpi3_sge_common)); 1415 - 1416 - if (!drv_buf_iter->kern_buf_len) 1417 - continue; 1418 - 1419 - drv_buf_iter->kern_buf = dma_alloc_coherent(&mrioc->pdev->dev, 1420 - drv_buf_iter->kern_buf_len, &drv_buf_iter->kern_buf_dma, 1421 - GFP_KERNEL); 1422 - if (!drv_buf_iter->kern_buf) { 1423 - rval = -ENOMEM; 1146 + if (is_rmcb && !count) { 1147 + drv_buf_iter->kern_buf_len = 1148 + mrioc->ioctl_chain_sge.size; 1149 + drv_buf_iter->kern_buf = 1150 + mrioc->ioctl_chain_sge.addr; 1151 + drv_buf_iter->kern_buf_dma = 1152 + mrioc->ioctl_chain_sge.dma_addr; 1153 + drv_buf_iter->dma_desc = NULL; 1154 + drv_buf_iter->num_dma_desc = 0; 1155 + memset(drv_buf_iter->kern_buf, 0, 1156 + drv_buf_iter->kern_buf_len); 1157 + tmplen = min(drv_buf_iter->kern_buf_len, 1158 + drv_buf_iter->bsg_buf_len); 1159 + rmc_size = tmplen; 1160 + memcpy(drv_buf_iter->kern_buf, drv_buf_iter->bsg_buf, tmplen); 1161 + } else if (is_rmrb && (count == 1)) { 1162 + drv_buf_iter->kern_buf_len = 1163 + mrioc->ioctl_resp_sge.size; 1164 + drv_buf_iter->kern_buf = 1165 + mrioc->ioctl_resp_sge.addr; 1166 + drv_buf_iter->kern_buf_dma = 1167 + mrioc->ioctl_resp_sge.dma_addr; 1168 + drv_buf_iter->dma_desc = NULL; 1169 + drv_buf_iter->num_dma_desc = 0; 1170 + memset(drv_buf_iter->kern_buf, 0, 1171 + drv_buf_iter->kern_buf_len); 1172 + tmplen = min(drv_buf_iter->kern_buf_len, 1173 + drv_buf_iter->bsg_buf_len); 1174 + drv_buf_iter->kern_buf_len = tmplen; 1175 + memset(drv_buf_iter->bsg_buf, 0, 1176 + drv_buf_iter->bsg_buf_len); 1177 + } else { 1178 + if (!drv_buf_iter->kern_buf_len) 1179 + continue; 1180 + if (mpi3mr_map_data_buffer_dma(mrioc, drv_buf_iter, desc_count)) { 1181 + rval = -ENOMEM; 1182 + dprint_bsg_err(mrioc, "%s:%d: mapping data buffers failed\n", 1183 + __func__, __LINE__); 1424 1184 goto out; 1425 1185 } 1426 - if (drv_buf_iter->data_dir == DMA_TO_DEVICE) { 1427 - tmplen = min(drv_buf_iter->kern_buf_len, 1428 - drv_buf_iter->bsg_buf_len); 1429 - memcpy(drv_buf_iter->kern_buf, drv_buf_iter->bsg_buf, tmplen); 1186 + desc_count += drv_buf_iter->num_dma_desc; 1430 1187 } 1431 1188 } 1432 1189 ··· 1530 1219 goto out; 1531 1220 } 1532 1221 } else { 1533 - mpi3mr_bsg_build_sgl(mpi_req, (mpi_msg_size), 1534 - drv_bufs, bufcnt, is_rmcb, is_rmrb, 1535 - (dout_cnt + din_cnt)); 1222 + if (mpi3mr_bsg_build_sgl(mrioc, mpi_req, mpi_msg_size, 1223 + drv_bufs, bufcnt, is_rmcb, is_rmrb, 1224 + (dout_cnt + din_cnt))) { 1225 + dprint_bsg_err(mrioc, "%s: sgl build failed\n", __func__); 1226 + rval = -EAGAIN; 1227 + mutex_unlock(&mrioc->bsg_cmds.mutex); 1228 + goto out; 1229 + } 1536 1230 } 1537 1231 1538 1232 if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_TASK_MGMT) { ··· 1573 1257 if (mpi_header->function == MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) { 1574 1258 drv_buf_iter = &drv_bufs[0]; 1575 1259 dprint_dump(drv_buf_iter->kern_buf, 1576 - drv_buf_iter->kern_buf_len, "mpi3_mgmt_req"); 1260 + rmc_size, "mpi3_mgmt_req"); 1577 1261 } 1578 1262 } 1579 1263 ··· 1608 1292 MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) { 1609 1293 drv_buf_iter = &drv_bufs[0]; 1610 1294 dprint_dump(drv_buf_iter->kern_buf, 1611 - drv_buf_iter->kern_buf_len, "mpi3_mgmt_req"); 1295 + rmc_size, "mpi3_mgmt_req"); 1612 1296 } 1613 1297 } 1614 - 1615 1298 if ((mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) || 1616 1299 (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO)) 1617 1300 mpi3mr_issue_tm(mrioc, ··· 1681 1366 for (count = 0; count < bufcnt; count++, drv_buf_iter++) { 1682 1367 if (drv_buf_iter->data_dir == DMA_NONE) 1683 1368 continue; 1684 - if (drv_buf_iter->data_dir == DMA_FROM_DEVICE) { 1685 - tmplen = min(drv_buf_iter->kern_buf_len, 1686 - drv_buf_iter->bsg_buf_len); 1369 + if ((count == 1) && is_rmrb) { 1687 1370 memcpy(drv_buf_iter->bsg_buf, 1688 - drv_buf_iter->kern_buf, tmplen); 1371 + drv_buf_iter->kern_buf, 1372 + drv_buf_iter->kern_buf_len); 1373 + } else if (drv_buf_iter->data_dir == DMA_FROM_DEVICE) { 1374 + tmplen = 0; 1375 + for (desc_count = 0; 1376 + desc_count < drv_buf_iter->num_dma_desc; 1377 + desc_count++) { 1378 + memcpy(((u8 *)drv_buf_iter->bsg_buf + tmplen), 1379 + drv_buf_iter->dma_desc[desc_count].addr, 1380 + drv_buf_iter->dma_desc[desc_count].size); 1381 + tmplen += 1382 + drv_buf_iter->dma_desc[desc_count].size; 1689 1383 } 1384 + } 1690 1385 } 1691 1386 1692 1387 out_unlock: 1693 1388 if (din_buf) { 1694 - *reply_payload_rcv_len = 1389 + job->reply_payload_rcv_len = 1695 1390 sg_copy_from_buffer(job->reply_payload.sg_list, 1696 1391 job->reply_payload.sg_cnt, 1697 1392 din_buf, job->reply_payload.payload_len); ··· 1717 1392 kfree(mpi_req); 1718 1393 if (drv_bufs) { 1719 1394 drv_buf_iter = drv_bufs; 1720 - for (count = 0; count < bufcnt; count++, drv_buf_iter++) { 1721 - if (drv_buf_iter->kern_buf && drv_buf_iter->kern_buf_dma) 1722 - dma_free_coherent(&mrioc->pdev->dev, 1723 - drv_buf_iter->kern_buf_len, 1724 - drv_buf_iter->kern_buf, 1725 - drv_buf_iter->kern_buf_dma); 1726 - } 1395 + for (count = 0; count < bufcnt; count++, drv_buf_iter++) 1396 + kfree(drv_buf_iter->dma_desc); 1727 1397 kfree(drv_bufs); 1728 1398 } 1729 1399 kfree(bsg_reply_buf); ··· 1777 1457 rval = mpi3mr_bsg_process_drv_cmds(job); 1778 1458 break; 1779 1459 case MPI3MR_MPT_CMD: 1780 - rval = mpi3mr_bsg_process_mpt_cmds(job, &reply_payload_rcv_len); 1460 + rval = mpi3mr_bsg_process_mpt_cmds(job); 1781 1461 break; 1782 1462 default: 1783 1463 pr_err("%s: unsupported BSG command(0x%08x)\n",
+117 -1
drivers/scsi/mpi3mr/mpi3mr_fw.c
··· 1059 1059 } 1060 1060 1061 1061 /** 1062 + * mpi3mr_free_ioctl_dma_memory - free memory for ioctl dma 1063 + * @mrioc: Adapter instance reference 1064 + * 1065 + * Free the DMA memory allocated for IOCTL handling purpose. 1066 + 1067 + * 1068 + * Return: None 1069 + */ 1070 + static void mpi3mr_free_ioctl_dma_memory(struct mpi3mr_ioc *mrioc) 1071 + { 1072 + struct dma_memory_desc *mem_desc; 1073 + u16 i; 1074 + 1075 + if (!mrioc->ioctl_dma_pool) 1076 + return; 1077 + 1078 + for (i = 0; i < MPI3MR_NUM_IOCTL_SGE; i++) { 1079 + mem_desc = &mrioc->ioctl_sge[i]; 1080 + if (mem_desc->addr) { 1081 + dma_pool_free(mrioc->ioctl_dma_pool, 1082 + mem_desc->addr, 1083 + mem_desc->dma_addr); 1084 + mem_desc->addr = NULL; 1085 + } 1086 + } 1087 + dma_pool_destroy(mrioc->ioctl_dma_pool); 1088 + mrioc->ioctl_dma_pool = NULL; 1089 + mem_desc = &mrioc->ioctl_chain_sge; 1090 + 1091 + if (mem_desc->addr) { 1092 + dma_free_coherent(&mrioc->pdev->dev, mem_desc->size, 1093 + mem_desc->addr, mem_desc->dma_addr); 1094 + mem_desc->addr = NULL; 1095 + } 1096 + mem_desc = &mrioc->ioctl_resp_sge; 1097 + if (mem_desc->addr) { 1098 + dma_free_coherent(&mrioc->pdev->dev, mem_desc->size, 1099 + mem_desc->addr, mem_desc->dma_addr); 1100 + mem_desc->addr = NULL; 1101 + } 1102 + 1103 + mrioc->ioctl_sges_allocated = false; 1104 + } 1105 + 1106 + /** 1107 + * mpi3mr_alloc_ioctl_dma_memory - Alloc memory for ioctl dma 1108 + * @mrioc: Adapter instance reference 1109 + 1110 + * 1111 + * This function allocates dmaable memory required to handle the 1112 + * application issued MPI3 IOCTL requests. 1113 + * 1114 + * Return: None 1115 + */ 1116 + static void mpi3mr_alloc_ioctl_dma_memory(struct mpi3mr_ioc *mrioc) 1117 + 1118 + { 1119 + struct dma_memory_desc *mem_desc; 1120 + u16 i; 1121 + 1122 + mrioc->ioctl_dma_pool = dma_pool_create("ioctl dma pool", 1123 + &mrioc->pdev->dev, 1124 + MPI3MR_IOCTL_SGE_SIZE, 1125 + MPI3MR_PAGE_SIZE_4K, 0); 1126 + 1127 + if (!mrioc->ioctl_dma_pool) { 1128 + ioc_err(mrioc, "ioctl_dma_pool: dma_pool_create failed\n"); 1129 + goto out_failed; 1130 + } 1131 + 1132 + for (i = 0; i < MPI3MR_NUM_IOCTL_SGE; i++) { 1133 + mem_desc = &mrioc->ioctl_sge[i]; 1134 + mem_desc->size = MPI3MR_IOCTL_SGE_SIZE; 1135 + mem_desc->addr = dma_pool_zalloc(mrioc->ioctl_dma_pool, 1136 + GFP_KERNEL, 1137 + &mem_desc->dma_addr); 1138 + if (!mem_desc->addr) 1139 + goto out_failed; 1140 + } 1141 + 1142 + mem_desc = &mrioc->ioctl_chain_sge; 1143 + mem_desc->size = MPI3MR_PAGE_SIZE_4K; 1144 + mem_desc->addr = dma_alloc_coherent(&mrioc->pdev->dev, 1145 + mem_desc->size, 1146 + &mem_desc->dma_addr, 1147 + GFP_KERNEL); 1148 + if (!mem_desc->addr) 1149 + goto out_failed; 1150 + 1151 + mem_desc = &mrioc->ioctl_resp_sge; 1152 + mem_desc->size = MPI3MR_PAGE_SIZE_4K; 1153 + mem_desc->addr = dma_alloc_coherent(&mrioc->pdev->dev, 1154 + mem_desc->size, 1155 + &mem_desc->dma_addr, 1156 + GFP_KERNEL); 1157 + if (!mem_desc->addr) 1158 + goto out_failed; 1159 + 1160 + mrioc->ioctl_sges_allocated = true; 1161 + 1162 + return; 1163 + out_failed: 1164 + ioc_warn(mrioc, "cannot allocate DMA memory for the mpt commands\n" 1165 + "from the applications, application interface for MPT command is disabled\n"); 1166 + mpi3mr_free_ioctl_dma_memory(mrioc); 1167 + } 1168 + 1169 + /** 1062 1170 * mpi3mr_clear_reset_history - clear reset history 1063 1171 * @mrioc: Adapter instance reference 1064 1172 * ··· 2000 1892 2001 1893 reply_qid = qidx + 1; 2002 1894 op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD; 2003 - if (!mrioc->pdev->revision) 1895 + if ((mrioc->pdev->device == MPI3_MFGPAGE_DEVID_SAS4116) && 1896 + !mrioc->pdev->revision) 2004 1897 op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD4K; 2005 1898 op_reply_q->ci = 0; 2006 1899 op_reply_q->ephase = 1; ··· 3302 3193 current_time = ktime_get_real(); 3303 3194 iocinit_req.time_stamp = cpu_to_le64(ktime_to_ms(current_time)); 3304 3195 3196 + iocinit_req.msg_flags |= 3197 + MPI3_IOCINIT_MSGFLAGS_SCSIIOSTATUSREPLY_SUPPORTED; 3198 + 3305 3199 init_completion(&mrioc->init_cmds.done); 3306 3200 retval = mpi3mr_admin_request_post(mrioc, &iocinit_req, 3307 3201 sizeof(iocinit_req), 1); ··· 3982 3870 } 3983 3871 } 3984 3872 3873 + dprint_init(mrioc, "allocating ioctl dma buffers\n"); 3874 + mpi3mr_alloc_ioctl_dma_memory(mrioc); 3875 + 3985 3876 if (!mrioc->init_cmds.reply) { 3986 3877 retval = mpi3mr_alloc_reply_sense_bufs(mrioc); 3987 3878 if (retval) { ··· 4404 4289 struct mpi3mr_intr_info *intr_info; 4405 4290 4406 4291 mpi3mr_free_enclosure_list(mrioc); 4292 + mpi3mr_free_ioctl_dma_memory(mrioc); 4407 4293 4408 4294 if (mrioc->sense_buf_pool) { 4409 4295 if (mrioc->sense_buf)
+28 -5
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 1047 1047 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, 1048 1048 list) { 1049 1049 if ((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) && 1050 - tgtdev->host_exposed && tgtdev->starget && 1051 - tgtdev->starget->hostdata) { 1050 + tgtdev->is_hidden && 1051 + tgtdev->host_exposed && tgtdev->starget && 1052 + tgtdev->starget->hostdata) { 1052 1053 tgt_priv = tgtdev->starget->hostdata; 1053 1054 tgt_priv->dev_removed = 1; 1054 1055 atomic_set(&tgt_priv->block_io, 0); ··· 1065 1064 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); 1066 1065 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev, true); 1067 1066 mpi3mr_tgtdev_put(tgtdev); 1067 + } else if (tgtdev->is_hidden & tgtdev->host_exposed) { 1068 + dprint_reset(mrioc, "hiding target device with perst_id(%d)\n", 1069 + tgtdev->perst_id); 1070 + mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); 1068 1071 } 1069 1072 } 1070 1073 1071 1074 tgtdev = NULL; 1072 1075 list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) { 1073 1076 if ((tgtdev->dev_handle != MPI3MR_INVALID_DEV_HANDLE) && 1074 - !tgtdev->is_hidden && !tgtdev->host_exposed) 1075 - mpi3mr_report_tgtdev_to_host(mrioc, tgtdev->perst_id); 1077 + !tgtdev->is_hidden) { 1078 + if (!tgtdev->host_exposed) 1079 + mpi3mr_report_tgtdev_to_host(mrioc, 1080 + tgtdev->perst_id); 1081 + else if (tgtdev->starget) 1082 + starget_for_each_device(tgtdev->starget, 1083 + (void *)tgtdev, mpi3mr_update_sdev); 1084 + } 1076 1085 } 1077 1086 } 1078 1087 ··· 3205 3194 tg = stgt_priv_data->throttle_group; 3206 3195 throttle_enabled_dev = 3207 3196 stgt_priv_data->io_throttle_enabled; 3197 + dev_handle = stgt_priv_data->dev_handle; 3208 3198 } 3209 3199 } 3210 3200 if (unlikely((data_len_blks >= mrioc->io_throttle_data_length) && ··· 5113 5101 mpi3mr_init_drv_cmd(&mrioc->evtack_cmds[i], 5114 5102 MPI3MR_HOSTTAG_EVTACKCMD_MIN + i); 5115 5103 5116 - if (pdev->revision) 5104 + if ((pdev->device == MPI3_MFGPAGE_DEVID_SAS4116) && 5105 + !pdev->revision) 5106 + mrioc->enable_segqueue = false; 5107 + else 5117 5108 mrioc->enable_segqueue = true; 5118 5109 5119 5110 init_waitqueue_head(&mrioc->reset_waitq); ··· 5444 5429 { 5445 5430 PCI_DEVICE_SUB(MPI3_MFGPAGE_VENDORID_BROADCOM, 5446 5431 MPI3_MFGPAGE_DEVID_SAS4116, PCI_ANY_ID, PCI_ANY_ID) 5432 + }, 5433 + { 5434 + PCI_DEVICE_SUB(MPI3_MFGPAGE_VENDORID_BROADCOM, 5435 + MPI3_MFGPAGE_DEVID_SAS5116_MPI, PCI_ANY_ID, PCI_ANY_ID) 5436 + }, 5437 + { 5438 + PCI_DEVICE_SUB(MPI3_MFGPAGE_VENDORID_BROADCOM, 5439 + MPI3_MFGPAGE_DEVID_SAS5116_MPI_MGMT, PCI_ANY_ID, PCI_ANY_ID) 5447 5440 }, 5448 5441 { 0 } 5449 5442 };
+8 -8
drivers/scsi/mpi3mr/mpi3mr_transport.c
··· 1587 1587 */ 1588 1588 struct host_port { 1589 1589 u64 sas_address; 1590 - u32 phy_mask; 1590 + u64 phy_mask; 1591 1591 u16 handle; 1592 1592 u8 iounit_port_id; 1593 1593 u8 used; ··· 1611 1611 struct mpi3mr_sas_port *mr_sas_port) 1612 1612 { 1613 1613 struct mpi3mr_sas_phy *mr_sas_phy; 1614 - u32 phy_mask_xor; 1614 + u64 phy_mask_xor; 1615 1615 u64 phys_to_be_added, phys_to_be_removed; 1616 1616 int i; 1617 1617 ··· 1619 1619 mr_sas_port->marked_responding = 1; 1620 1620 1621 1621 dev_info(&mr_sas_port->port->dev, 1622 - "sas_address(0x%016llx), old: port_id %d phy_mask 0x%x, new: port_id %d phy_mask:0x%x\n", 1622 + "sas_address(0x%016llx), old: port_id %d phy_mask 0x%llx, new: port_id %d phy_mask:0x%llx\n", 1623 1623 mr_sas_port->remote_identify.sas_address, 1624 1624 mr_sas_port->hba_port->port_id, mr_sas_port->phy_mask, 1625 1625 h_port->iounit_port_id, h_port->phy_mask); ··· 1637 1637 * if these phys are previously registered with another port 1638 1638 * then delete these phys from that port first. 1639 1639 */ 1640 - for_each_set_bit(i, (ulong *) &phys_to_be_added, BITS_PER_TYPE(u32)) { 1640 + for_each_set_bit(i, (ulong *) &phys_to_be_added, BITS_PER_TYPE(u64)) { 1641 1641 mr_sas_phy = &mrioc->sas_hba.phy[i]; 1642 1642 if (mr_sas_phy->phy_belongs_to_port) 1643 1643 mpi3mr_del_phy_from_an_existing_port(mrioc, ··· 1649 1649 } 1650 1650 1651 1651 /* Delete the phys which are not part of current mr_sas_port's port. */ 1652 - for_each_set_bit(i, (ulong *) &phys_to_be_removed, BITS_PER_TYPE(u32)) { 1652 + for_each_set_bit(i, (ulong *) &phys_to_be_removed, BITS_PER_TYPE(u64)) { 1653 1653 mr_sas_phy = &mrioc->sas_hba.phy[i]; 1654 1654 if (mr_sas_phy->phy_belongs_to_port) 1655 1655 mpi3mr_del_phy_from_an_existing_port(mrioc, ··· 1671 1671 void 1672 1672 mpi3mr_refresh_sas_ports(struct mpi3mr_ioc *mrioc) 1673 1673 { 1674 - struct host_port h_port[32]; 1674 + struct host_port h_port[64]; 1675 1675 int i, j, found, host_port_count = 0, port_idx; 1676 1676 u16 sz, attached_handle, ioc_status; 1677 1677 struct mpi3_sas_io_unit_page0 *sas_io_unit_pg0 = NULL; ··· 1742 1742 list_for_each_entry(mr_sas_port, &mrioc->sas_hba.sas_port_list, 1743 1743 port_list) { 1744 1744 ioc_info(mrioc, 1745 - "port_id:%d, sas_address:(0x%016llx), phy_mask:(0x%x), lowest phy id:%d\n", 1745 + "port_id:%d, sas_address:(0x%016llx), phy_mask:(0x%llx), lowest phy id:%d\n", 1746 1746 mr_sas_port->hba_port->port_id, 1747 1747 mr_sas_port->remote_identify.sas_address, 1748 1748 mr_sas_port->phy_mask, mr_sas_port->lowest_phy); ··· 1751 1751 ioc_info(mrioc, "Host port details after reset\n"); 1752 1752 for (i = 0; i < host_port_count; i++) { 1753 1753 ioc_info(mrioc, 1754 - "port_id:%d, sas_address:(0x%016llx), phy_mask:(0x%x), lowest phy id:%d\n", 1754 + "port_id:%d, sas_address:(0x%016llx), phy_mask:(0x%llx), lowest phy id:%d\n", 1755 1755 h_port[i].iounit_port_id, h_port[i].sas_address, 1756 1756 h_port[i].phy_mask, h_port[i].lowest_phy); 1757 1757 }
+73 -158
drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
··· 643 643 /*Manufacturing Page 2 */ 644 644 645 645 /* 646 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 647 - *one and check Header.PageLength at runtime. 646 + *Host code (drivers, BIOS, utilities, etc.) should check Header.PageLength at 647 + *runtime before using HwSettings[]. 648 648 */ 649 - #ifndef MPI2_MAN_PAGE_2_HW_SETTINGS_WORDS 650 - #define MPI2_MAN_PAGE_2_HW_SETTINGS_WORDS (1) 651 - #endif 652 649 653 650 typedef struct _MPI2_CONFIG_PAGE_MAN_2 { 654 651 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ 655 652 MPI2_CHIP_REVISION_ID ChipId; /*0x04 */ 656 - U32 657 - HwSettings[MPI2_MAN_PAGE_2_HW_SETTINGS_WORDS];/*0x08 */ 653 + U32 HwSettings[]; /*0x08 */ 658 654 } MPI2_CONFIG_PAGE_MAN_2, 659 655 *PTR_MPI2_CONFIG_PAGE_MAN_2, 660 656 Mpi2ManufacturingPage2_t, ··· 662 666 /*Manufacturing Page 3 */ 663 667 664 668 /* 665 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 666 - *one and check Header.PageLength at runtime. 669 + *Host code (drivers, BIOS, utilities, etc.) should check Header.PageLength at 670 + *runtime before using Info[]. 667 671 */ 668 - #ifndef MPI2_MAN_PAGE_3_INFO_WORDS 669 - #define MPI2_MAN_PAGE_3_INFO_WORDS (1) 670 - #endif 671 672 672 673 typedef struct _MPI2_CONFIG_PAGE_MAN_3 { 673 674 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ 674 675 MPI2_CHIP_REVISION_ID ChipId; /*0x04 */ 675 - U32 676 - Info[MPI2_MAN_PAGE_3_INFO_WORDS];/*0x08 */ 676 + U32 Info[]; /*0x08 */ 677 677 } MPI2_CONFIG_PAGE_MAN_3, 678 678 *PTR_MPI2_CONFIG_PAGE_MAN_3, 679 679 Mpi2ManufacturingPage3_t, ··· 757 765 /*Manufacturing Page 5 */ 758 766 759 767 /* 760 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 761 - *one and check the value returned for NumPhys at runtime. 768 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 769 + *for NumPhys at runtime before using Phy[]. 762 770 */ 763 - #ifndef MPI2_MAN_PAGE_5_PHY_ENTRIES 764 - #define MPI2_MAN_PAGE_5_PHY_ENTRIES (1) 765 - #endif 766 771 767 772 typedef struct _MPI2_MANUFACTURING5_ENTRY { 768 773 U64 WWID; /*0x00 */ ··· 776 787 U16 Reserved2; /*0x06 */ 777 788 U32 Reserved3; /*0x08 */ 778 789 U32 Reserved4; /*0x0C */ 779 - MPI2_MANUFACTURING5_ENTRY 780 - Phy[MPI2_MAN_PAGE_5_PHY_ENTRIES];/*0x08 */ 790 + MPI2_MANUFACTURING5_ENTRY Phy[]; /*0x10 */ 781 791 } MPI2_CONFIG_PAGE_MAN_5, 782 792 *PTR_MPI2_CONFIG_PAGE_MAN_5, 783 793 Mpi2ManufacturingPage5_t, ··· 852 864 #define MPI2_MANPAGE7_SLOT_UNKNOWN (0xFFFF) 853 865 854 866 /* 855 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 856 - *one and check the value returned for NumPhys at runtime. 867 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 868 + *for NumPhys at runtime before using ConnectorInfo[]. 857 869 */ 858 - #ifndef MPI2_MANPAGE7_CONNECTOR_INFO_MAX 859 - #define MPI2_MANPAGE7_CONNECTOR_INFO_MAX (1) 860 - #endif 861 870 862 871 typedef struct _MPI2_CONFIG_PAGE_MAN_7 { 863 872 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 865 880 U8 NumPhys; /*0x20 */ 866 881 U8 Reserved3; /*0x21 */ 867 882 U16 Reserved4; /*0x22 */ 868 - MPI2_MANPAGE7_CONNECTOR_INFO 869 - ConnectorInfo[MPI2_MANPAGE7_CONNECTOR_INFO_MAX]; /*0x24 */ 883 + MPI2_MANPAGE7_CONNECTOR_INFO ConnectorInfo[]; /*0x24 */ 870 884 } MPI2_CONFIG_PAGE_MAN_7, 871 885 *PTR_MPI2_CONFIG_PAGE_MAN_7, 872 886 Mpi2ManufacturingPage7_t, ··· 974 990 975 991 /* 976 992 *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 977 - *one and check the value returned for GPIOCount at runtime. 993 + *36 and check the value returned for GPIOCount at runtime. 978 994 */ 979 995 #ifndef MPI2_IO_UNIT_PAGE_3_GPIO_VAL_MAX 980 996 #define MPI2_IO_UNIT_PAGE_3_GPIO_VAL_MAX (36) ··· 1003 1019 /*IO Unit Page 5 */ 1004 1020 1005 1021 /* 1006 - *Upper layer code (drivers, utilities, etc.) should leave this define set to 1007 - *one and check the value returned for NumDmaEngines at runtime. 1022 + *Upper layer code (drivers, utilities, etc.) should check the value returned 1023 + *for NumDmaEngines at runtime before using DmaEngineCapabilities[]. 1008 1024 */ 1009 - #ifndef MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES 1010 - #define MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES (1) 1011 - #endif 1012 1025 1013 1026 typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_5 { 1014 1027 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 1023 1042 U32 Reserved2; /*0x24 */ 1024 1043 U32 Reserved3; /*0x28 */ 1025 1044 U32 1026 - DmaEngineCapabilities[MPI2_IOUNITPAGE5_DMAENGINE_ENTRIES]; /*0x2C */ 1045 + DmaEngineCapabilities[]; /*0x2C */ 1027 1046 } MPI2_CONFIG_PAGE_IO_UNIT_5, 1028 1047 *PTR_MPI2_CONFIG_PAGE_IO_UNIT_5, 1029 1048 Mpi2IOUnitPage5_t, *pMpi2IOUnitPage5_t; ··· 1200 1219 #define MPI2_IOUNIT8_SENSOR_FLAGS_T0_ENABLE (0x0001) 1201 1220 1202 1221 /* 1203 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1204 - *one and check the value returned for NumSensors at runtime. 1222 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 1223 + *for NumSensors at runtime before using Sensor[]. 1205 1224 */ 1206 - #ifndef MPI2_IOUNITPAGE8_SENSOR_ENTRIES 1207 - #define MPI2_IOUNITPAGE8_SENSOR_ENTRIES (1) 1208 - #endif 1209 1225 1210 1226 typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_8 { 1211 1227 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 1211 1233 U8 NumSensors; /*0x0C */ 1212 1234 U8 PollingInterval; /*0x0D */ 1213 1235 U16 Reserved3; /*0x0E */ 1214 - MPI2_IOUNIT8_SENSOR 1215 - Sensor[MPI2_IOUNITPAGE8_SENSOR_ENTRIES];/*0x10 */ 1236 + MPI2_IOUNIT8_SENSOR Sensor[]; /*0x10 */ 1216 1237 } MPI2_CONFIG_PAGE_IO_UNIT_8, 1217 1238 *PTR_MPI2_CONFIG_PAGE_IO_UNIT_8, 1218 1239 Mpi2IOUnitPage8_t, *pMpi2IOUnitPage8_t; ··· 1236 1259 #define MPI2_IOUNIT9_SENSOR_FLAGS_TEMP_VALID (0x01) 1237 1260 1238 1261 /* 1239 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1240 - *one and check the value returned for NumSensors at runtime. 1262 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 1263 + *for NumSensors at runtime before using Sensor[]. 1241 1264 */ 1242 - #ifndef MPI2_IOUNITPAGE9_SENSOR_ENTRIES 1243 - #define MPI2_IOUNITPAGE9_SENSOR_ENTRIES (1) 1244 - #endif 1245 1265 1246 1266 typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_9 { 1247 1267 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 1247 1273 U8 NumSensors; /*0x0C */ 1248 1274 U8 Reserved4; /*0x0D */ 1249 1275 U16 Reserved3; /*0x0E */ 1250 - MPI2_IOUNIT9_SENSOR 1251 - Sensor[MPI2_IOUNITPAGE9_SENSOR_ENTRIES];/*0x10 */ 1276 + MPI2_IOUNIT9_SENSOR Sensor[]; /*0x10 */ 1252 1277 } MPI2_CONFIG_PAGE_IO_UNIT_9, 1253 1278 *PTR_MPI2_CONFIG_PAGE_IO_UNIT_9, 1254 1279 Mpi2IOUnitPage9_t, *pMpi2IOUnitPage9_t; ··· 1267 1294 *pMpi2IOUnit10Function_t; 1268 1295 1269 1296 /* 1270 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1271 - *one and check the value returned for NumFunctions at runtime. 1297 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 1298 + *for NumFunctions at runtime before using Function[]. 1272 1299 */ 1273 - #ifndef MPI2_IOUNITPAGE10_FUNCTION_ENTRIES 1274 - #define MPI2_IOUNITPAGE10_FUNCTION_ENTRIES (1) 1275 - #endif 1276 1300 1277 1301 typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_10 { 1278 1302 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 1278 1308 U16 Reserved2; /*0x06 */ 1279 1309 U32 Reserved3; /*0x08 */ 1280 1310 U32 Reserved4; /*0x0C */ 1281 - MPI2_IOUNIT10_FUNCTION 1282 - Function[MPI2_IOUNITPAGE10_FUNCTION_ENTRIES];/*0x10 */ 1311 + MPI2_IOUNIT10_FUNCTION Function[]; /*0x10 */ 1283 1312 } MPI2_CONFIG_PAGE_IO_UNIT_10, 1284 1313 *PTR_MPI2_CONFIG_PAGE_IO_UNIT_10, 1285 1314 Mpi2IOUnitPage10_t, *pMpi2IOUnitPage10_t; ··· 1733 1764 /*BIOS Page 4 */ 1734 1765 1735 1766 /* 1736 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1737 - *one and check the value returned for NumPhys at runtime. 1767 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 1768 + *for NumPhys at runtime before using Phy[]. 1738 1769 */ 1739 - #ifndef MPI2_BIOS_PAGE_4_PHY_ENTRIES 1740 - #define MPI2_BIOS_PAGE_4_PHY_ENTRIES (1) 1741 - #endif 1742 1770 1743 1771 typedef struct _MPI2_BIOS4_ENTRY { 1744 1772 U64 ReassignmentWWID; /*0x00 */ ··· 1748 1782 U8 NumPhys; /*0x04 */ 1749 1783 U8 Reserved1; /*0x05 */ 1750 1784 U16 Reserved2; /*0x06 */ 1751 - MPI2_BIOS4_ENTRY 1752 - Phy[MPI2_BIOS_PAGE_4_PHY_ENTRIES]; /*0x08 */ 1785 + MPI2_BIOS4_ENTRY Phy[]; /*0x08 */ 1753 1786 } MPI2_CONFIG_PAGE_BIOS_4, *PTR_MPI2_CONFIG_PAGE_BIOS_4, 1754 1787 Mpi2BiosPage4_t, *pMpi2BiosPage4_t; 1755 1788 ··· 1801 1836 #define MPI2_RAIDVOL0_SETTING_ENABLE_WRITE_CACHING (0x0002) 1802 1837 1803 1838 /* 1804 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1805 - *one and check the value returned for NumPhysDisks at runtime. 1839 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 1840 + *for NumPhysDisks at runtime before using PhysDisk[]. 1806 1841 */ 1807 - #ifndef MPI2_RAID_VOL_PAGE_0_PHYSDISK_MAX 1808 - #define MPI2_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) 1809 - #endif 1810 1842 1811 1843 typedef struct _MPI2_CONFIG_PAGE_RAID_VOL_0 { 1812 1844 MPI2_CONFIG_PAGE_HEADER Header; /*0x00 */ ··· 1823 1861 U8 Reserved2; /*0x25 */ 1824 1862 U8 Reserved3; /*0x26 */ 1825 1863 U8 InactiveStatus; /*0x27 */ 1826 - MPI2_RAIDVOL0_PHYS_DISK 1827 - PhysDisk[MPI2_RAID_VOL_PAGE_0_PHYSDISK_MAX]; /*0x28 */ 1864 + MPI2_RAIDVOL0_PHYS_DISK PhysDisk[]; /*0x28 */ 1828 1865 } MPI2_CONFIG_PAGE_RAID_VOL_0, 1829 1866 *PTR_MPI2_CONFIG_PAGE_RAID_VOL_0, 1830 1867 Mpi2RaidVolPage0_t, *pMpi2RaidVolPage0_t; ··· 2006 2045 /*RAID Physical Disk Page 1 */ 2007 2046 2008 2047 /* 2009 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2010 - *one and check the value returned for NumPhysDiskPaths at runtime. 2048 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2049 + *for NumPhysDiskPaths at runtime before using PhysicalDiskPath[]. 2011 2050 */ 2012 - #ifndef MPI2_RAID_PHYS_DISK1_PATH_MAX 2013 - #define MPI2_RAID_PHYS_DISK1_PATH_MAX (1) 2014 - #endif 2015 2051 2016 2052 typedef struct _MPI2_RAIDPHYSDISK1_PATH { 2017 2053 U16 DevHandle; /*0x00 */ ··· 2033 2075 U8 PhysDiskNum; /*0x05 */ 2034 2076 U16 Reserved1; /*0x06 */ 2035 2077 U32 Reserved2; /*0x08 */ 2036 - MPI2_RAIDPHYSDISK1_PATH 2037 - PhysicalDiskPath[MPI2_RAID_PHYS_DISK1_PATH_MAX];/*0x0C */ 2078 + MPI2_RAIDPHYSDISK1_PATH PhysicalDiskPath[]; /*0x0C */ 2038 2079 } MPI2_CONFIG_PAGE_RD_PDISK_1, 2039 2080 *PTR_MPI2_CONFIG_PAGE_RD_PDISK_1, 2040 2081 Mpi2RaidPhysDiskPage1_t, ··· 2178 2221 *pMpi2SasIOUnit0PhyData_t; 2179 2222 2180 2223 /* 2181 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2182 - *one and check the value returned for NumPhys at runtime. 2224 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2225 + *for NumPhys at runtime before using PhyData[]. 2183 2226 */ 2184 - #ifndef MPI2_SAS_IOUNIT0_PHY_MAX 2185 - #define MPI2_SAS_IOUNIT0_PHY_MAX (1) 2186 - #endif 2187 2227 2188 2228 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_0 { 2189 2229 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 2188 2234 U8 NumPhys; /*0x0C */ 2189 2235 U8 Reserved2;/*0x0D */ 2190 2236 U16 Reserved3;/*0x0E */ 2191 - MPI2_SAS_IO_UNIT0_PHY_DATA 2192 - PhyData[MPI2_SAS_IOUNIT0_PHY_MAX]; /*0x10 */ 2237 + MPI2_SAS_IO_UNIT0_PHY_DATA PhyData[];/*0x10 */ 2193 2238 } MPI2_CONFIG_PAGE_SASIOUNIT_0, 2194 2239 *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_0, 2195 2240 Mpi2SasIOUnitPage0_t, *pMpi2SasIOUnitPage0_t; ··· 2249 2296 *pMpi2SasIOUnit1PhyData_t; 2250 2297 2251 2298 /* 2252 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2253 - *one and check the value returned for NumPhys at runtime. 2299 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2300 + *for NumPhys at runtime before using PhyData[]. 2254 2301 */ 2255 - #ifndef MPI2_SAS_IOUNIT1_PHY_MAX 2256 - #define MPI2_SAS_IOUNIT1_PHY_MAX (1) 2257 - #endif 2258 2302 2259 2303 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_1 { 2260 2304 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 2272 2322 U8 2273 2323 IODeviceMissingDelay; /*0x13 */ 2274 2324 MPI2_SAS_IO_UNIT1_PHY_DATA 2275 - PhyData[MPI2_SAS_IOUNIT1_PHY_MAX]; /*0x14 */ 2325 + PhyData[]; /*0x14 */ 2276 2326 } MPI2_CONFIG_PAGE_SASIOUNIT_1, 2277 2327 *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_1, 2278 2328 Mpi2SasIOUnitPage1_t, *pMpi2SasIOUnitPage1_t; ··· 2452 2502 #define MPI2_SASIOUNIT5_ITE_ONE_MICROSECOND (0) 2453 2503 2454 2504 /* 2455 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2456 - *one and check the value returned for NumPhys at runtime. 2505 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2506 + *for NumPhys at runtime before using SASPhyPowerManagementSettings[]. 2457 2507 */ 2458 - #ifndef MPI2_SAS_IOUNIT5_PHY_MAX 2459 - #define MPI2_SAS_IOUNIT5_PHY_MAX (1) 2460 - #endif 2461 2508 2462 2509 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_5 { 2463 2510 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 2463 2516 U16 Reserved2;/*0x0A */ 2464 2517 U32 Reserved3;/*0x0C */ 2465 2518 MPI2_SAS_IO_UNIT5_PHY_PM_SETTINGS 2466 - SASPhyPowerManagementSettings[MPI2_SAS_IOUNIT5_PHY_MAX];/*0x10 */ 2519 + SASPhyPowerManagementSettings[]; /*0x10 */ 2467 2520 } MPI2_CONFIG_PAGE_SASIOUNIT_5, 2468 2521 *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_5, 2469 2522 Mpi2SasIOUnitPage5_t, *pMpi2SasIOUnitPage5_t; ··· 2501 2554 #define MPI2_SASIOUNIT6_MODULATION_100_PERCENT (0x03) 2502 2555 2503 2556 /* 2504 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2505 - *one and check the value returned for NumGroups at runtime. 2557 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2558 + *for NumGroups at runtime before using PortWidthModulationGroupStatus[]. 2506 2559 */ 2507 - #ifndef MPI2_SAS_IOUNIT6_GROUP_MAX 2508 - #define MPI2_SAS_IOUNIT6_GROUP_MAX (1) 2509 - #endif 2510 2560 2511 2561 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_6 { 2512 2562 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 2513 2569 U8 Reserved3; /*0x11 */ 2514 2570 U16 Reserved4; /*0x12 */ 2515 2571 MPI2_SAS_IO_UNIT6_PORT_WIDTH_MOD_GROUP_STATUS 2516 - PortWidthModulationGroupStatus[MPI2_SAS_IOUNIT6_GROUP_MAX]; /*0x14 */ 2572 + PortWidthModulationGroupStatus[]; /*0x14 */ 2517 2573 } MPI2_CONFIG_PAGE_SASIOUNIT_6, 2518 2574 *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_6, 2519 2575 Mpi2SasIOUnitPage6_t, *pMpi2SasIOUnitPage6_t; ··· 2541 2597 2542 2598 2543 2599 /* 2544 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 2545 - *one and check the value returned for NumGroups at runtime. 2600 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 2601 + *for NumGroups at runtime before using PortWidthModulationGroupSettings[]. 2546 2602 */ 2547 - #ifndef MPI2_SAS_IOUNIT7_GROUP_MAX 2548 - #define MPI2_SAS_IOUNIT7_GROUP_MAX (1) 2549 - #endif 2550 2603 2551 2604 typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_7 { 2552 2605 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 2556 2615 U8 Reserved4; /*0x15 */ 2557 2616 U16 Reserved5; /*0x16 */ 2558 2617 MPI2_SAS_IO_UNIT7_PORT_WIDTH_MOD_GROUP_SETTINGS 2559 - PortWidthModulationGroupSettings[MPI2_SAS_IOUNIT7_GROUP_MAX];/*0x18 */ 2618 + PortWidthModulationGroupSettings[]; /*0x18 */ 2560 2619 } MPI2_CONFIG_PAGE_SASIOUNIT_7, 2561 2620 *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_7, 2562 2621 Mpi2SasIOUnitPage7_t, *pMpi2SasIOUnitPage7_t; ··· 3027 3086 3028 3087 3029 3088 /* 3030 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3031 - *one and check the value returned for NumPhyEvents at runtime. 3089 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3090 + *for NumPhyEvents at runtime before using PhyEvent[]. 3032 3091 */ 3033 - #ifndef MPI2_SASPHY2_PHY_EVENT_MAX 3034 - #define MPI2_SASPHY2_PHY_EVENT_MAX (1) 3035 - #endif 3036 3092 3037 3093 typedef struct _MPI2_CONFIG_PAGE_SAS_PHY_2 { 3038 3094 MPI2_CONFIG_EXTENDED_PAGE_HEADER ··· 3043 3105 U16 3044 3106 Reserved3; /*0x0E */ 3045 3107 MPI2_SASPHY2_PHY_EVENT 3046 - PhyEvent[MPI2_SASPHY2_PHY_EVENT_MAX]; /*0x10 */ 3108 + PhyEvent[]; /*0x10 */ 3047 3109 } MPI2_CONFIG_PAGE_SAS_PHY_2, 3048 3110 *PTR_MPI2_CONFIG_PAGE_SAS_PHY_2, 3049 3111 Mpi2SasPhyPage2_t, ··· 3138 3200 #define MPI2_SASPHY3_TFLAGS_EVENT_NOTIFY (0x0001) 3139 3201 3140 3202 /* 3141 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3142 - *one and check the value returned for NumPhyEvents at runtime. 3203 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3204 + *for NumPhyEvents at runtime before using PhyEventConfig[]. 3143 3205 */ 3144 - #ifndef MPI2_SASPHY3_PHY_EVENT_MAX 3145 - #define MPI2_SASPHY3_PHY_EVENT_MAX (1) 3146 - #endif 3147 3206 3148 3207 typedef struct _MPI2_CONFIG_PAGE_SAS_PHY_3 { 3149 3208 MPI2_CONFIG_EXTENDED_PAGE_HEADER ··· 3154 3219 U16 3155 3220 Reserved3; /*0x0E */ 3156 3221 MPI2_SASPHY3_PHY_EVENT_CONFIG 3157 - PhyEventConfig[MPI2_SASPHY3_PHY_EVENT_MAX]; /*0x10 */ 3222 + PhyEventConfig[]; /*0x10 */ 3158 3223 } MPI2_CONFIG_PAGE_SAS_PHY_3, 3159 3224 *PTR_MPI2_CONFIG_PAGE_SAS_PHY_3, 3160 3225 Mpi2SasPhyPage3_t, *pMpi2SasPhyPage3_t; ··· 3293 3358 /*Log Page 0 */ 3294 3359 3295 3360 /* 3296 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3297 - *one and check the value returned for NumLogEntries at runtime. 3361 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3362 + *for NumLogEntries at runtime before using LogEntry[]. 3298 3363 */ 3299 - #ifndef MPI2_LOG_0_NUM_LOG_ENTRIES 3300 - #define MPI2_LOG_0_NUM_LOG_ENTRIES (1) 3301 - #endif 3302 3364 3303 3365 #define MPI2_LOG_0_LOG_DATA_LENGTH (0x1C) 3304 3366 ··· 3325 3393 U32 Reserved2; /*0x0C */ 3326 3394 U16 NumLogEntries;/*0x10 */ 3327 3395 U16 Reserved3; /*0x12 */ 3328 - MPI2_LOG_0_ENTRY 3329 - LogEntry[MPI2_LOG_0_NUM_LOG_ENTRIES]; /*0x14 */ 3396 + MPI2_LOG_0_ENTRY LogEntry[]; /*0x14 */ 3330 3397 } MPI2_CONFIG_PAGE_LOG_0, *PTR_MPI2_CONFIG_PAGE_LOG_0, 3331 3398 Mpi2LogPage0_t, *pMpi2LogPage0_t; 3332 3399 ··· 3339 3408 /*RAID Page 0 */ 3340 3409 3341 3410 /* 3342 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3343 - *one and check the value returned for NumElements at runtime. 3411 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3412 + *for NumElements at runtime before using ConfigElement[]. 3344 3413 */ 3345 - #ifndef MPI2_RAIDCONFIG0_MAX_ELEMENTS 3346 - #define MPI2_RAIDCONFIG0_MAX_ELEMENTS (1) 3347 - #endif 3348 3414 3349 3415 typedef struct _MPI2_RAIDCONFIG0_CONFIG_ELEMENT { 3350 3416 U16 ElementFlags; /*0x00 */ ··· 3374 3446 U8 NumElements; /*0x2C */ 3375 3447 U8 Reserved2; /*0x2D */ 3376 3448 U16 Reserved3; /*0x2E */ 3377 - MPI2_RAIDCONFIG0_CONFIG_ELEMENT 3378 - ConfigElement[MPI2_RAIDCONFIG0_MAX_ELEMENTS]; /*0x30 */ 3449 + MPI2_RAIDCONFIG0_CONFIG_ELEMENT ConfigElement[];/*0x30 */ 3379 3450 } MPI2_CONFIG_PAGE_RAID_CONFIGURATION_0, 3380 3451 *PTR_MPI2_CONFIG_PAGE_RAID_CONFIGURATION_0, 3381 3452 Mpi2RaidConfigurationPage0_t, ··· 3614 3687 Mpi26PCIeIOUnit0PhyData_t, *pMpi26PCIeIOUnit0PhyData_t; 3615 3688 3616 3689 /* 3617 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3618 - *one and check the value returned for NumPhys at runtime. 3690 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3691 + *for NumPhys at runtime before using PhyData[]. 3619 3692 */ 3620 - #ifndef MPI26_PCIE_IOUNIT0_PHY_MAX 3621 - #define MPI26_PCIE_IOUNIT0_PHY_MAX (1) 3622 - #endif 3623 3693 3624 3694 typedef struct _MPI26_CONFIG_PAGE_PIOUNIT_0 { 3625 3695 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 3625 3701 U8 InitStatus; /*0x0D */ 3626 3702 U16 Reserved3; /*0x0E */ 3627 3703 MPI26_PCIE_IO_UNIT0_PHY_DATA 3628 - PhyData[MPI26_PCIE_IOUNIT0_PHY_MAX]; /*0x10 */ 3704 + PhyData[]; /*0x10 */ 3629 3705 } MPI26_CONFIG_PAGE_PIOUNIT_0, 3630 3706 *PTR_MPI26_CONFIG_PAGE_PIOUNIT_0, 3631 3707 Mpi26PCIeIOUnitPage0_t, *pMpi26PCIeIOUnitPage0_t; ··· 3668 3744 #define MPI26_PCIEIOUNIT1_LINKFLAGS_SRNS_EN (0x02) 3669 3745 3670 3746 /* 3671 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3672 - *one and check the value returned for NumPhys at runtime. 3747 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3748 + *for NumPhys at runtime before using PhyData[]. 3673 3749 */ 3674 - #ifndef MPI26_PCIE_IOUNIT1_PHY_MAX 3675 - #define MPI26_PCIE_IOUNIT1_PHY_MAX (1) 3676 - #endif 3677 3750 3678 3751 typedef struct _MPI26_CONFIG_PAGE_PIOUNIT_1 { 3679 3752 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 3682 3761 U8 DMDReportPCIe; /*0x11 */ 3683 3762 U16 Reserved2; /*0x12 */ 3684 3763 MPI26_PCIE_IO_UNIT1_PHY_DATA 3685 - PhyData[MPI26_PCIE_IOUNIT1_PHY_MAX];/*0x14 */ 3764 + PhyData[]; /*0x14 */ 3686 3765 } MPI26_CONFIG_PAGE_PIOUNIT_1, 3687 3766 *PTR_MPI26_CONFIG_PAGE_PIOUNIT_1, 3688 3767 Mpi26PCIeIOUnitPage1_t, *pMpi26PCIeIOUnitPage1_t; ··· 3914 3993 3915 3994 3916 3995 /* 3917 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3918 - *one and check the value returned for NumLinkEvents at runtime. 3996 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 3997 + *for NumLinkEvents at runtime before using LinkEvent[]. 3919 3998 */ 3920 - #ifndef MPI26_PCIELINK2_LINK_EVENT_MAX 3921 - #define MPI26_PCIELINK2_LINK_EVENT_MAX (1) 3922 - #endif 3923 3999 3924 4000 typedef struct _MPI26_CONFIG_PAGE_PCIELINK_2 { 3925 4001 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 3927 4009 U8 Reserved3; /*0x0D */ 3928 4010 U16 Reserved4; /*0x0E */ 3929 4011 MPI26_PCIELINK2_LINK_EVENT 3930 - LinkEvent[MPI26_PCIELINK2_LINK_EVENT_MAX]; /*0x10 */ 4012 + LinkEvent[]; /*0x10 */ 3931 4013 } MPI26_CONFIG_PAGE_PCIELINK_2, *PTR_MPI26_CONFIG_PAGE_PCIELINK_2, 3932 4014 Mpi26PcieLinkPage2_t, *pMpi26PcieLinkPage2_t; 3933 4015 ··· 3985 4067 #define MPI26_PCIELINK3_TFLAGS_EVENT_NOTIFY (0x0001) 3986 4068 3987 4069 /* 3988 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 3989 - *one and check the value returned for NumLinkEvents at runtime. 4070 + *Host code (drivers, BIOS, utilities, etc.) should check the value returned 4071 + *for NumLinkEvents at runtime before using LinkEventConfig[]. 3990 4072 */ 3991 - #ifndef MPI26_PCIELINK3_LINK_EVENT_MAX 3992 - #define MPI26_PCIELINK3_LINK_EVENT_MAX (1) 3993 - #endif 3994 4073 3995 4074 typedef struct _MPI26_CONFIG_PAGE_PCIELINK_3 { 3996 4075 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ ··· 3998 4083 U8 Reserved3; /*0x0D */ 3999 4084 U16 Reserved4; /*0x0E */ 4000 4085 MPI26_PCIELINK3_LINK_EVENT_CONFIG 4001 - LinkEventConfig[MPI26_PCIELINK3_LINK_EVENT_MAX]; /*0x10 */ 4086 + LinkEventConfig[]; /*0x10 */ 4002 4087 } MPI26_CONFIG_PAGE_PCIELINK_3, *PTR_MPI26_CONFIG_PAGE_PCIELINK_3, 4003 4088 Mpi26PcieLinkPage3_t, *pMpi26PcieLinkPage3_t; 4004 4089
+9 -23
drivers/scsi/mpt3sas/mpi/mpi2_image.h
··· 295 295 /*FLASH Layout Extended Image Data */ 296 296 297 297 /* 298 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 299 - *one and check RegionsPerLayout at runtime. 298 + *Host code (drivers, BIOS, utilities, etc.) should check NumberOfLayouts and 299 + *RegionsPerLayout at runtime before using Layout[] and Region[]. 300 300 */ 301 - #ifndef MPI2_FLASH_NUMBER_OF_REGIONS 302 - #define MPI2_FLASH_NUMBER_OF_REGIONS (1) 303 - #endif 304 - 305 - /* 306 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 307 - *one and check NumberOfLayouts at runtime. 308 - */ 309 - #ifndef MPI2_FLASH_NUMBER_OF_LAYOUTS 310 - #define MPI2_FLASH_NUMBER_OF_LAYOUTS (1) 311 - #endif 312 301 313 302 typedef struct _MPI2_FLASH_REGION { 314 303 U8 RegionType; /*0x00 */ ··· 314 325 U32 Reserved1; /*0x04 */ 315 326 U32 Reserved2; /*0x08 */ 316 327 U32 Reserved3; /*0x0C */ 317 - MPI2_FLASH_REGION Region[MPI2_FLASH_NUMBER_OF_REGIONS]; /*0x10 */ 328 + MPI2_FLASH_REGION Region[]; /*0x10 */ 318 329 } MPI2_FLASH_LAYOUT, *PTR_MPI2_FLASH_LAYOUT, 319 330 Mpi2FlashLayout_t, *pMpi2FlashLayout_t; 320 331 ··· 328 339 U16 MinimumSectorAlignment; /*0x08 */ 329 340 U16 Reserved3; /*0x0A */ 330 341 U32 Reserved4; /*0x0C */ 331 - MPI2_FLASH_LAYOUT Layout[MPI2_FLASH_NUMBER_OF_LAYOUTS]; /*0x10 */ 342 + MPI2_FLASH_LAYOUT Layout[]; /*0x10 */ 332 343 } MPI2_FLASH_LAYOUT_DATA, *PTR_MPI2_FLASH_LAYOUT_DATA, 333 344 Mpi2FlashLayoutData_t, *pMpi2FlashLayoutData_t; 334 345 ··· 362 373 /*Supported Devices Extended Image Data */ 363 374 364 375 /* 365 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 366 - *one and check NumberOfDevices at runtime. 376 + *Host code (drivers, BIOS, utilities, etc.) should check NumberOfDevices at 377 + *runtime before using SupportedDevice[]. 367 378 */ 368 - #ifndef MPI2_SUPPORTED_DEVICES_IMAGE_NUM_DEVICES 369 - #define MPI2_SUPPORTED_DEVICES_IMAGE_NUM_DEVICES (1) 370 - #endif 371 379 372 380 typedef struct _MPI2_SUPPORTED_DEVICE { 373 381 U16 DeviceID; /*0x00 */ ··· 385 399 U8 Reserved2; /*0x03 */ 386 400 U32 Reserved3; /*0x04 */ 387 401 MPI2_SUPPORTED_DEVICE 388 - SupportedDevice[MPI2_SUPPORTED_DEVICES_IMAGE_NUM_DEVICES];/*0x08 */ 402 + SupportedDevice[]; /*0x08 */ 389 403 } MPI2_SUPPORTED_DEVICES_DATA, *PTR_MPI2_SUPPORTED_DEVICES_DATA, 390 404 Mpi2SupportedDevicesData_t, *pMpi2SupportedDevicesData_t; 391 405 ··· 450 464 U8 EncryptionAlgorithm; /*0x02 */ 451 465 U8 Reserved1; /*0x03 */ 452 466 U32 Reserved2; /*0x04 */ 453 - U32 EncryptedHash[1]; /*0x08 */ /* variable length */ 467 + U32 EncryptedHash[]; /*0x08 */ 454 468 } MPI25_ENCRYPTED_HASH_ENTRY, *PTR_MPI25_ENCRYPTED_HASH_ENTRY, 455 469 Mpi25EncryptedHashEntry_t, *pMpi25EncryptedHashEntry_t; 456 470 ··· 494 508 U8 NumHash; /*0x01 */ 495 509 U16 Reserved1; /*0x02 */ 496 510 U32 Reserved2; /*0x04 */ 497 - MPI25_ENCRYPTED_HASH_ENTRY EncryptedHashEntry[1]; /*0x08 */ 511 + MPI25_ENCRYPTED_HASH_ENTRY EncryptedHashEntry[]; /*0x08 */ 498 512 } MPI25_ENCRYPTED_HASH_DATA, *PTR_MPI25_ENCRYPTED_HASH_DATA, 499 513 Mpi25EncryptedHashData_t, *pMpi25EncryptedHashData_t; 500 514
+9 -18
drivers/scsi/mpt3sas/mpi/mpi2_ioc.h
··· 808 808 /*Integrated RAID Configuration Change List Event data */ 809 809 810 810 /* 811 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 812 - *one and check NumElements at runtime. 811 + *Host code (drivers, BIOS, utilities, etc.) should check NumElements at 812 + *runtime before using ConfigElement[]. 813 813 */ 814 - #ifndef MPI2_EVENT_IR_CONFIG_ELEMENT_COUNT 815 - #define MPI2_EVENT_IR_CONFIG_ELEMENT_COUNT (1) 816 - #endif 817 814 818 815 typedef struct _MPI2_EVENT_IR_CONFIG_ELEMENT { 819 816 U16 ElementFlags; /*0x00 */ ··· 845 848 U8 ConfigNum; /*0x03 */ 846 849 U32 Flags; /*0x04 */ 847 850 MPI2_EVENT_IR_CONFIG_ELEMENT 848 - ConfigElement[MPI2_EVENT_IR_CONFIG_ELEMENT_COUNT];/*0x08 */ 851 + ConfigElement[];/*0x08 */ 849 852 } MPI2_EVENT_DATA_IR_CONFIG_CHANGE_LIST, 850 853 *PTR_MPI2_EVENT_DATA_IR_CONFIG_CHANGE_LIST, 851 854 Mpi2EventDataIrConfigChangeList_t, ··· 966 969 /*SAS Topology Change List Event data */ 967 970 968 971 /* 969 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 970 - *one and check NumEntries at runtime. 972 + *Host code (drivers, BIOS, utilities, etc.) should check NumEntries at 973 + *runtime before using PHY[]. 971 974 */ 972 - #ifndef MPI2_EVENT_SAS_TOPO_PHY_COUNT 973 - #define MPI2_EVENT_SAS_TOPO_PHY_COUNT (1) 974 - #endif 975 975 976 976 typedef struct _MPI2_EVENT_SAS_TOPO_PHY_ENTRY { 977 977 U16 AttachedDevHandle; /*0x00 */ ··· 988 994 U8 ExpStatus; /*0x0A */ 989 995 U8 PhysicalPort; /*0x0B */ 990 996 MPI2_EVENT_SAS_TOPO_PHY_ENTRY 991 - PHY[MPI2_EVENT_SAS_TOPO_PHY_COUNT]; /*0x0C */ 997 + PHY[]; /*0x0C */ 992 998 } MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST, 993 999 *PTR_MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST, 994 1000 Mpi2EventDataSasTopologyChangeList_t, ··· 1223 1229 /*PCIe Topology Change List Event data (MPI v2.6 and later) */ 1224 1230 1225 1231 /* 1226 - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to 1227 - *one and check NumEntries at runtime. 1232 + *Host code (drivers, BIOS, utilities, etc.) should check NumEntries at 1233 + *runtime before using PortEntry[]. 1228 1234 */ 1229 - #ifndef MPI26_EVENT_PCIE_TOPO_PORT_COUNT 1230 - #define MPI26_EVENT_PCIE_TOPO_PORT_COUNT (1) 1231 - #endif 1232 1235 1233 1236 typedef struct _MPI26_EVENT_PCIE_TOPO_PORT_ENTRY { 1234 1237 U16 AttachedDevHandle; /*0x00 */ ··· 1277 1286 U8 SwitchStatus; /*0x0A */ 1278 1287 U8 PhysicalPort; /*0x0B */ 1279 1288 MPI26_EVENT_PCIE_TOPO_PORT_ENTRY 1280 - PortEntry[MPI26_EVENT_PCIE_TOPO_PORT_COUNT]; /*0x0C */ 1289 + PortEntry[]; /*0x0C */ 1281 1290 } MPI26_EVENT_DATA_PCIE_TOPOLOGY_CHANGE_LIST, 1282 1291 *PTR_MPI26_EVENT_DATA_PCIE_TOPOLOGY_CHANGE_LIST, 1283 1292 Mpi26EventDataPCIeTopologyChangeList_t,
+13 -22
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 4893 4893 if (!num_phys) 4894 4894 return; 4895 4895 4896 - sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (num_phys * 4897 - sizeof(Mpi2SasIOUnit1PhyData_t)); 4896 + sz = struct_size(sas_iounit_pg1, PhyData, num_phys); 4898 4897 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); 4899 4898 if (!sas_iounit_pg1) { 4900 4899 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 5043 5044 { 5044 5045 Mpi26DriverTriggerPage2_t trigger_pg2; 5045 5046 struct SL_WH_EVENT_TRIGGER_T *event_tg; 5046 - MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY *mpi_event_tg; 5047 + MPI26_DRIVER_MPI_EVENT_TRIGGER_ENTRY *mpi_event_tg; 5047 5048 Mpi2ConfigReply_t mpi_reply; 5048 5049 int r = 0, i = 0; 5049 5050 u16 count = 0; ··· 5095 5096 { 5096 5097 Mpi26DriverTriggerPage3_t trigger_pg3; 5097 5098 struct SL_WH_SCSI_TRIGGER_T *scsi_tg; 5098 - MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY *mpi_scsi_tg; 5099 + MPI26_DRIVER_SCSI_SENSE_TRIGGER_ENTRY *mpi_scsi_tg; 5099 5100 Mpi2ConfigReply_t mpi_reply; 5100 5101 int r = 0, i = 0; 5101 5102 u16 count = 0; ··· 5147 5148 { 5148 5149 Mpi26DriverTriggerPage4_t trigger_pg4; 5149 5150 struct SL_WH_MPI_TRIGGER_T *status_tg; 5150 - MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY *mpi_status_tg; 5151 + MPI26_DRIVER_IOCSTATUS_LOGINFO_TRIGGER_ENTRY *mpi_status_tg; 5151 5152 Mpi2ConfigReply_t mpi_reply; 5152 5153 int r = 0, i = 0; 5153 5154 u16 count = 0; ··· 5378 5379 static int _base_assign_fw_reported_qd(struct MPT3SAS_ADAPTER *ioc) 5379 5380 { 5380 5381 Mpi2ConfigReply_t mpi_reply; 5381 - Mpi2SasIOUnitPage1_t *sas_iounit_pg1 = NULL; 5382 + Mpi2SasIOUnitPage1_t sas_iounit_pg1; 5382 5383 Mpi26PCIeIOUnitPage1_t pcie_iounit_pg1; 5383 5384 u16 depth; 5384 - int sz; 5385 5385 int rc = 0; 5386 5386 5387 5387 ioc->max_wideport_qd = MPT3SAS_SAS_QUEUE_DEPTH; ··· 5390 5392 if (!ioc->is_gen35_ioc) 5391 5393 goto out; 5392 5394 /* sas iounit page 1 */ 5393 - sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData); 5394 - sas_iounit_pg1 = kzalloc(sizeof(Mpi2SasIOUnitPage1_t), GFP_KERNEL); 5395 - if (!sas_iounit_pg1) { 5396 - pr_err("%s: failure at %s:%d/%s()!\n", 5397 - ioc->name, __FILE__, __LINE__, __func__); 5398 - return rc; 5399 - } 5400 5395 rc = mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply, 5401 - sas_iounit_pg1, sz); 5396 + &sas_iounit_pg1, sizeof(Mpi2SasIOUnitPage1_t)); 5402 5397 if (rc) { 5403 5398 pr_err("%s: failure at %s:%d/%s()!\n", 5404 5399 ioc->name, __FILE__, __LINE__, __func__); 5405 5400 goto out; 5406 5401 } 5407 5402 5408 - depth = le16_to_cpu(sas_iounit_pg1->SASWideMaxQueueDepth); 5403 + depth = le16_to_cpu(sas_iounit_pg1.SASWideMaxQueueDepth); 5409 5404 ioc->max_wideport_qd = (depth ? depth : MPT3SAS_SAS_QUEUE_DEPTH); 5410 5405 5411 - depth = le16_to_cpu(sas_iounit_pg1->SASNarrowMaxQueueDepth); 5406 + depth = le16_to_cpu(sas_iounit_pg1.SASNarrowMaxQueueDepth); 5412 5407 ioc->max_narrowport_qd = (depth ? depth : MPT3SAS_SAS_QUEUE_DEPTH); 5413 5408 5414 - depth = sas_iounit_pg1->SATAMaxQDepth; 5409 + depth = sas_iounit_pg1.SATAMaxQDepth; 5415 5410 ioc->max_sata_qd = (depth ? depth : MPT3SAS_SATA_QUEUE_DEPTH); 5416 5411 5417 5412 /* pcie iounit page 1 */ ··· 5423 5432 "MaxWidePortQD: 0x%x MaxNarrowPortQD: 0x%x MaxSataQD: 0x%x MaxNvmeQD: 0x%x\n", 5424 5433 ioc->max_wideport_qd, ioc->max_narrowport_qd, 5425 5434 ioc->max_sata_qd, ioc->max_nvme_qd)); 5426 - kfree(sas_iounit_pg1); 5427 5435 return rc; 5428 5436 } 5429 5437 ··· 5578 5588 static int 5579 5589 _base_static_config_pages(struct MPT3SAS_ADAPTER *ioc) 5580 5590 { 5591 + Mpi2IOUnitPage8_t iounit_pg8; 5581 5592 Mpi2ConfigReply_t mpi_reply; 5582 5593 u32 iounit_pg1_flags; 5583 5594 int tg_flags = 0; ··· 5675 5684 rc = mpt3sas_config_get_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); 5676 5685 if (rc) 5677 5686 return rc; 5678 - rc = mpt3sas_config_get_iounit_pg8(ioc, &mpi_reply, &ioc->iounit_pg8); 5687 + rc = mpt3sas_config_get_iounit_pg8(ioc, &mpi_reply, &iounit_pg8); 5679 5688 if (rc) 5680 5689 return rc; 5681 5690 _base_display_ioc_capabilities(ioc); ··· 5697 5706 if (rc) 5698 5707 return rc; 5699 5708 5700 - if (ioc->iounit_pg8.NumSensors) 5701 - ioc->temp_sensors_count = ioc->iounit_pg8.NumSensors; 5709 + if (iounit_pg8.NumSensors) 5710 + ioc->temp_sensors_count = iounit_pg8.NumSensors; 5702 5711 if (ioc->is_aero_ioc) { 5703 5712 rc = _base_update_ioc_page1_inlinewith_perf_mode(ioc); 5704 5713 if (rc)
+1 -2
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 1237 1237 * @ioc_pg8: static ioc page 8 1238 1238 * @iounit_pg0: static iounit page 0 1239 1239 * @iounit_pg1: static iounit page 1 1240 - * @iounit_pg8: static iounit page 8 1241 1240 * @sas_hba: sas host object 1242 1241 * @sas_expander_list: expander object list 1243 1242 * @enclosure_list: enclosure object list ··· 1464 1465 Mpi2IOCPage8_t ioc_pg8; 1465 1466 Mpi2IOUnitPage0_t iounit_pg0; 1466 1467 Mpi2IOUnitPage1_t iounit_pg1; 1467 - Mpi2IOUnitPage8_t iounit_pg8; 1468 1468 Mpi2IOCPage1_t ioc_pg1_copy; 1469 1469 1470 1470 struct _boot_device req_boot_device; ··· 1981 1983 extern const struct attribute_group *mpt3sas_dev_groups[]; 1982 1984 void mpt3sas_ctl_init(ushort hbas_to_enumerate); 1983 1985 void mpt3sas_ctl_exit(ushort hbas_to_enumerate); 1986 + void mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc); 1984 1987 u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, 1985 1988 u32 reply); 1986 1989 void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
+3 -3
drivers/scsi/mpt3sas/mpt3sas_config.c
··· 2334 2334 tg_pg2.NumMPIEventTrigger = 0; 2335 2335 memset(&tg_pg2.MPIEventTriggers[0], 0, 2336 2336 NUM_VALID_ENTRIES * sizeof( 2337 - MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY)); 2337 + MPI26_DRIVER_MPI_EVENT_TRIGGER_ENTRY)); 2338 2338 } 2339 2339 2340 2340 rc = _config_set_driver_trigger_pg2(ioc, &mpi_reply, &tg_pg2); ··· 2493 2493 tg_pg3.NumSCSISenseTrigger = 0; 2494 2494 memset(&tg_pg3.SCSISenseTriggers[0], 0, 2495 2495 NUM_VALID_ENTRIES * sizeof( 2496 - MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY)); 2496 + MPI26_DRIVER_SCSI_SENSE_TRIGGER_ENTRY)); 2497 2497 } 2498 2498 2499 2499 rc = _config_set_driver_trigger_pg3(ioc, &mpi_reply, &tg_pg3); ··· 2649 2649 tg_pg4.NumIOCStatusLogInfoTrigger = 0; 2650 2650 memset(&tg_pg4.IOCStatusLoginfoTriggers[0], 0, 2651 2651 NUM_VALID_ENTRIES * sizeof( 2652 - MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY)); 2652 + MPI26_DRIVER_IOCSTATUS_LOGINFO_TRIGGER_ENTRY)); 2653 2653 } 2654 2654 2655 2655 rc = _config_set_driver_trigger_pg4(ioc, &mpi_reply, &tg_pg4);
+24 -18
drivers/scsi/mpt3sas/mpt3sas_ctl.c
··· 4157 4157 } 4158 4158 4159 4159 /** 4160 + * mpt3sas_ctl_release - release dma for ctl 4161 + * @ioc: per adapter object 4162 + */ 4163 + void 4164 + mpt3sas_ctl_release(struct MPT3SAS_ADAPTER *ioc) 4165 + { 4166 + int i; 4167 + 4168 + /* free memory associated to diag buffers */ 4169 + for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { 4170 + if (!ioc->diag_buffer[i]) 4171 + continue; 4172 + dma_free_coherent(&ioc->pdev->dev, 4173 + ioc->diag_buffer_sz[i], 4174 + ioc->diag_buffer[i], 4175 + ioc->diag_buffer_dma[i]); 4176 + ioc->diag_buffer[i] = NULL; 4177 + ioc->diag_buffer_status[i] = 0; 4178 + } 4179 + 4180 + kfree(ioc->event_log); 4181 + } 4182 + 4183 + /** 4160 4184 * mpt3sas_ctl_exit - exit point for ctl 4161 4185 * @hbas_to_enumerate: ? 4162 4186 */ 4163 4187 void 4164 4188 mpt3sas_ctl_exit(ushort hbas_to_enumerate) 4165 4189 { 4166 - struct MPT3SAS_ADAPTER *ioc; 4167 - int i; 4168 4190 4169 - list_for_each_entry(ioc, &mpt3sas_ioc_list, list) { 4170 - 4171 - /* free memory associated to diag buffers */ 4172 - for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { 4173 - if (!ioc->diag_buffer[i]) 4174 - continue; 4175 - dma_free_coherent(&ioc->pdev->dev, 4176 - ioc->diag_buffer_sz[i], 4177 - ioc->diag_buffer[i], 4178 - ioc->diag_buffer_dma[i]); 4179 - ioc->diag_buffer[i] = NULL; 4180 - ioc->diag_buffer_status[i] = 0; 4181 - } 4182 - 4183 - kfree(ioc->event_log); 4184 - } 4185 4191 if (hbas_to_enumerate != 1) 4186 4192 misc_deregister(&ctl_dev); 4187 4193 if (hbas_to_enumerate != 2)
+19 -37
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 2431 2431 } 2432 2432 2433 2433 raid_device->num_pds = num_pds; 2434 - sz = offsetof(Mpi2RaidVolPage0_t, PhysDisk) + (num_pds * 2435 - sizeof(Mpi2RaidVol0PhysDisk_t)); 2434 + sz = struct_size(vol_pg0, PhysDisk, num_pds); 2436 2435 vol_pg0 = kzalloc(sz, GFP_KERNEL); 2437 2436 if (!vol_pg0) { 2438 2437 dfailprintk(ioc, ··· 5965 5966 /* 5966 5967 * Read SASIOUnitPage0 to get each HBA Phy's data. 5967 5968 */ 5968 - sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + 5969 - (ioc->sas_hba.num_phys * sizeof(Mpi2SasIOUnit0PhyData_t)); 5969 + sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); 5970 5970 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL); 5971 5971 if (!sas_iounit_pg0) { 5972 5972 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 6143 6145 u64 attached_sas_addr; 6144 6146 u8 found = 0, port_count = 0, port_id; 6145 6147 6146 - sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys 6147 - * sizeof(Mpi2SasIOUnit0PhyData_t)); 6148 + sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); 6148 6149 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL); 6149 6150 if (!sas_iounit_pg0) { 6150 6151 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 6576 6579 ioc_info(ioc, "updating handles for sas_host(0x%016llx)\n", 6577 6580 (u64)ioc->sas_hba.sas_address)); 6578 6581 6579 - sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys 6580 - * sizeof(Mpi2SasIOUnit0PhyData_t)); 6582 + sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); 6581 6583 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL); 6582 6584 if (!sas_iounit_pg0) { 6583 6585 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 6727 6731 ioc->sas_hba.num_phys = num_phys; 6728 6732 6729 6733 /* sas_iounit page 0 */ 6730 - sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * 6731 - sizeof(Mpi2SasIOUnit0PhyData_t)); 6734 + sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); 6732 6735 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL); 6733 6736 if (!sas_iounit_pg0) { 6734 6737 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 6749 6754 } 6750 6755 6751 6756 /* sas_iounit page 1 */ 6752 - sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * 6753 - sizeof(Mpi2SasIOUnit1PhyData_t)); 6757 + sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); 6754 6758 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); 6755 6759 if (!sas_iounit_pg1) { 6756 6760 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 10370 10376 Mpi2ExpanderPage0_t expander_pg0; 10371 10377 Mpi2SasDevicePage0_t sas_device_pg0; 10372 10378 Mpi26PCIeDevicePage0_t pcie_device_pg0; 10373 - Mpi2RaidVolPage1_t *volume_pg1; 10374 - Mpi2RaidVolPage0_t *volume_pg0; 10379 + Mpi2RaidVolPage1_t volume_pg1; 10380 + Mpi2RaidVolPage0_t volume_pg0; 10375 10381 Mpi2RaidPhysDiskPage0_t pd_pg0; 10376 10382 Mpi2EventIrConfigElement_t element; 10377 10383 Mpi2ConfigReply_t mpi_reply; ··· 10385 10391 static struct _raid_device *raid_device; 10386 10392 u8 retry_count; 10387 10393 unsigned long flags; 10388 - 10389 - volume_pg0 = kzalloc(sizeof(*volume_pg0), GFP_KERNEL); 10390 - if (!volume_pg0) 10391 - return; 10392 - 10393 - volume_pg1 = kzalloc(sizeof(*volume_pg1), GFP_KERNEL); 10394 - if (!volume_pg1) { 10395 - kfree(volume_pg0); 10396 - return; 10397 - } 10398 10394 10399 10395 ioc_info(ioc, "scan devices: start\n"); 10400 10396 ··· 10495 10511 /* volumes */ 10496 10512 handle = 0xFFFF; 10497 10513 while (!(mpt3sas_config_get_raid_volume_pg1(ioc, &mpi_reply, 10498 - volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { 10514 + &volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) { 10499 10515 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & 10500 10516 MPI2_IOCSTATUS_MASK; 10501 10517 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { ··· 10503 10519 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo)); 10504 10520 break; 10505 10521 } 10506 - handle = le16_to_cpu(volume_pg1->DevHandle); 10522 + handle = le16_to_cpu(volume_pg1.DevHandle); 10507 10523 spin_lock_irqsave(&ioc->raid_device_lock, flags); 10508 10524 raid_device = _scsih_raid_device_find_by_wwid(ioc, 10509 - le64_to_cpu(volume_pg1->WWID)); 10525 + le64_to_cpu(volume_pg1.WWID)); 10510 10526 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); 10511 10527 if (raid_device) 10512 10528 continue; 10513 10529 if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply, 10514 - volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, 10530 + &volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle, 10515 10531 sizeof(Mpi2RaidVolPage0_t))) 10516 10532 continue; 10517 10533 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & ··· 10521 10537 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo)); 10522 10538 break; 10523 10539 } 10524 - if (volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL || 10525 - volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_ONLINE || 10526 - volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) { 10540 + if (volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL || 10541 + volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_ONLINE || 10542 + volume_pg0.VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) { 10527 10543 memset(&element, 0, sizeof(Mpi2EventIrConfigElement_t)); 10528 10544 element.ReasonCode = MPI2_EVENT_IR_CHANGE_RC_ADDED; 10529 - element.VolDevHandle = volume_pg1->DevHandle; 10545 + element.VolDevHandle = volume_pg1.DevHandle; 10530 10546 ioc_info(ioc, "\tBEFORE adding volume: handle (0x%04x)\n", 10531 - volume_pg1->DevHandle); 10547 + volume_pg1.DevHandle); 10532 10548 _scsih_sas_volume_add(ioc, &element); 10533 10549 ioc_info(ioc, "\tAFTER adding volume: handle (0x%04x)\n", 10534 - volume_pg1->DevHandle); 10550 + volume_pg1.DevHandle); 10535 10551 } 10536 10552 } 10537 10553 ··· 10619 10635 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n", 10620 10636 handle, (u64)le64_to_cpu(pcie_device_pg0.WWID)); 10621 10637 } 10622 - 10623 - kfree(volume_pg0); 10624 - kfree(volume_pg1); 10625 10638 10626 10639 ioc_info(ioc, "\tpcie devices: pcie end devices complete\n"); 10627 10640 ioc_info(ioc, "scan devices: complete\n"); ··· 11331 11350 } 11332 11351 11333 11352 mpt3sas_base_detach(ioc); 11353 + mpt3sas_ctl_release(ioc); 11334 11354 spin_lock(&gioc_lock); 11335 11355 list_del(&ioc->list); 11336 11356 spin_unlock(&gioc_lock);
+3 -6
drivers/scsi/mpt3sas/mpt3sas_transport.c
··· 1792 1792 /* handle hba phys */ 1793 1793 1794 1794 /* read sas_iounit page 0 */ 1795 - sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * 1796 - sizeof(Mpi2SasIOUnit0PhyData_t)); 1795 + sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); 1797 1796 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL); 1798 1797 if (!sas_iounit_pg0) { 1799 1798 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 1832 1833 } 1833 1834 1834 1835 /* read sas_iounit page 1 */ 1835 - sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * 1836 - sizeof(Mpi2SasIOUnit1PhyData_t)); 1836 + sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); 1837 1837 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); 1838 1838 if (!sas_iounit_pg1) { 1839 1839 ioc_err(ioc, "failure at %s:%d/%s()!\n", ··· 1942 1944 /* handle hba phys */ 1943 1945 1944 1946 /* sas_iounit page 1 */ 1945 - sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * 1946 - sizeof(Mpi2SasIOUnit1PhyData_t)); 1947 + sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); 1947 1948 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL); 1948 1949 if (!sas_iounit_pg1) { 1949 1950 ioc_err(ioc, "failure at %s:%d/%s()!\n",
+22 -22
drivers/scsi/mpt3sas/mpt3sas_trigger_pages.h
··· 20 20 21 21 #define MPI2_CONFIG_EXTPAGETYPE_DRIVER_PERSISTENT_TRIGGER (0xE0) 22 22 #define MPI26_DRIVER_TRIGGER_PAGE0_PAGEVERSION (0x01) 23 - typedef struct _MPI26_CONFIG_PAGE_DRIVER_TIGGER_0 { 23 + typedef struct _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_0 { 24 24 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */ 25 25 U16 TriggerFlags; /* 0x08 */ 26 26 U16 Reserved0xA; /* 0x0A */ 27 27 U32 Reserved0xC[61]; /* 0x0C */ 28 - } _MPI26_CONFIG_PAGE_DRIVER_TIGGER_0, Mpi26DriverTriggerPage0_t; 28 + } _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_0, Mpi26DriverTriggerPage0_t; 29 29 30 30 /* Trigger Flags */ 31 31 #define MPI26_DRIVER_TRIGGER0_FLAG_MASTER_TRIGGER_VALID (0x0001) ··· 34 34 #define MPI26_DRIVER_TRIGGER0_FLAG_LOGINFO_TRIGGER_VALID (0x0008) 35 35 36 36 #define MPI26_DRIVER_TRIGGER_PAGE1_PAGEVERSION (0x01) 37 - typedef struct _MPI26_DRIVER_MASTER_TIGGER_ENTRY { 37 + typedef struct _MPI26_DRIVER_MASTER_TRIGGER_ENTRY { 38 38 U32 MasterTriggerFlags; 39 - } MPI26_DRIVER_MASTER_TIGGER_ENTRY; 39 + } MPI26_DRIVER_MASTER_TRIGGER_ENTRY; 40 40 41 41 #define MPI26_MAX_MASTER_TRIGGERS (1) 42 - typedef struct _MPI26_CONFIG_PAGE_DRIVER_TIGGER_1 { 42 + typedef struct _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_1 { 43 43 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */ 44 44 U16 NumMasterTrigger; /* 0x08 */ 45 45 U16 Reserved0xA; /* 0x0A */ 46 - MPI26_DRIVER_MASTER_TIGGER_ENTRY MasterTriggers[MPI26_MAX_MASTER_TRIGGERS]; /* 0x0C */ 47 - } MPI26_CONFIG_PAGE_DRIVER_TIGGER_1, Mpi26DriverTriggerPage1_t; 46 + MPI26_DRIVER_MASTER_TRIGGER_ENTRY MasterTriggers[MPI26_MAX_MASTER_TRIGGERS]; /* 0x0C */ 47 + } MPI26_CONFIG_PAGE_DRIVER_TRIGGER_1, Mpi26DriverTriggerPage1_t; 48 48 49 49 #define MPI26_DRIVER_TRIGGER_PAGE2_PAGEVERSION (0x01) 50 - typedef struct _MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY { 50 + typedef struct _MPI26_DRIVER_MPI_EVENT_TRIGGER_ENTRY { 51 51 U16 MPIEventCode; /* 0x00 */ 52 52 U16 MPIEventCodeSpecific; /* 0x02 */ 53 - } MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY; 53 + } MPI26_DRIVER_MPI_EVENT_TRIGGER_ENTRY; 54 54 55 55 #define MPI26_MAX_MPI_EVENT_TRIGGERS (20) 56 - typedef struct _MPI26_CONFIG_PAGE_DRIVER_TIGGER_2 { 56 + typedef struct _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_2 { 57 57 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */ 58 58 U16 NumMPIEventTrigger; /* 0x08 */ 59 59 U16 Reserved0xA; /* 0x0A */ 60 - MPI26_DRIVER_MPI_EVENT_TIGGER_ENTRY MPIEventTriggers[MPI26_MAX_MPI_EVENT_TRIGGERS]; /* 0x0C */ 61 - } MPI26_CONFIG_PAGE_DRIVER_TIGGER_2, Mpi26DriverTriggerPage2_t; 60 + MPI26_DRIVER_MPI_EVENT_TRIGGER_ENTRY MPIEventTriggers[MPI26_MAX_MPI_EVENT_TRIGGERS]; /* 0x0C */ 61 + } MPI26_CONFIG_PAGE_DRIVER_TRIGGER_2, Mpi26DriverTriggerPage2_t; 62 62 63 63 #define MPI26_DRIVER_TRIGGER_PAGE3_PAGEVERSION (0x01) 64 - typedef struct _MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY { 64 + typedef struct _MPI26_DRIVER_SCSI_SENSE_TRIGGER_ENTRY { 65 65 U8 ASCQ; /* 0x00 */ 66 66 U8 ASC; /* 0x01 */ 67 67 U8 SenseKey; /* 0x02 */ 68 68 U8 Reserved; /* 0x03 */ 69 - } MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY; 69 + } MPI26_DRIVER_SCSI_SENSE_TRIGGER_ENTRY; 70 70 71 71 #define MPI26_MAX_SCSI_SENSE_TRIGGERS (20) 72 - typedef struct _MPI26_CONFIG_PAGE_DRIVER_TIGGER_3 { 72 + typedef struct _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_3 { 73 73 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */ 74 74 U16 NumSCSISenseTrigger; /* 0x08 */ 75 75 U16 Reserved0xA; /* 0x0A */ 76 - MPI26_DRIVER_SCSI_SENSE_TIGGER_ENTRY SCSISenseTriggers[MPI26_MAX_SCSI_SENSE_TRIGGERS]; /* 0x0C */ 77 - } MPI26_CONFIG_PAGE_DRIVER_TIGGER_3, Mpi26DriverTriggerPage3_t; 76 + MPI26_DRIVER_SCSI_SENSE_TRIGGER_ENTRY SCSISenseTriggers[MPI26_MAX_SCSI_SENSE_TRIGGERS]; /* 0x0C */ 77 + } MPI26_CONFIG_PAGE_DRIVER_TRIGGER_3, Mpi26DriverTriggerPage3_t; 78 78 79 79 #define MPI26_DRIVER_TRIGGER_PAGE4_PAGEVERSION (0x01) 80 - typedef struct _MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY { 80 + typedef struct _MPI26_DRIVER_IOCSTATUS_LOGINFO_TRIGGER_ENTRY { 81 81 U16 IOCStatus; /* 0x00 */ 82 82 U16 Reserved; /* 0x02 */ 83 83 U32 LogInfo; /* 0x04 */ 84 - } MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY; 84 + } MPI26_DRIVER_IOCSTATUS_LOGINFO_TRIGGER_ENTRY; 85 85 86 86 #define MPI26_MAX_LOGINFO_TRIGGERS (20) 87 - typedef struct _MPI26_CONFIG_PAGE_DRIVER_TIGGER_4 { 87 + typedef struct _MPI26_CONFIG_PAGE_DRIVER_TRIGGER_4 { 88 88 MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /* 0x00 */ 89 89 U16 NumIOCStatusLogInfoTrigger; /* 0x08 */ 90 90 U16 Reserved0xA; /* 0x0A */ 91 - MPI26_DRIVER_IOCSTATUS_LOGINFO_TIGGER_ENTRY IOCStatusLoginfoTriggers[MPI26_MAX_LOGINFO_TRIGGERS]; /* 0x0C */ 92 - } MPI26_CONFIG_PAGE_DRIVER_TIGGER_4, Mpi26DriverTriggerPage4_t; 91 + MPI26_DRIVER_IOCSTATUS_LOGINFO_TRIGGER_ENTRY IOCStatusLoginfoTriggers[MPI26_MAX_LOGINFO_TRIGGERS]; /* 0x0C */ 92 + } MPI26_CONFIG_PAGE_DRIVER_TRIGGER_4, Mpi26DriverTriggerPage4_t; 93 93 94 94 #endif
+1 -2
drivers/scsi/mpt3sas/mpt3sas_warpdrive.c
··· 141 141 return; 142 142 } 143 143 144 - sz = offsetof(Mpi2RaidVolPage0_t, PhysDisk) + (num_pds * 145 - sizeof(Mpi2RaidVol0PhysDisk_t)); 144 + sz = struct_size(vol_pg0, PhysDisk, num_pds); 146 145 vol_pg0 = kzalloc(sz, GFP_KERNEL); 147 146 if (!vol_pg0) { 148 147 ioc_info(ioc, "WarpDrive : Direct IO is disabled Memory allocation failure for RVPG0\n");
+2 -4
drivers/scsi/mvme16x_scsi.c
··· 103 103 return -ENODEV; 104 104 } 105 105 106 - static int mvme16x_device_remove(struct platform_device *dev) 106 + static void mvme16x_device_remove(struct platform_device *dev) 107 107 { 108 108 struct Scsi_Host *host = platform_get_drvdata(dev); 109 109 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); ··· 120 120 NCR_700_release(host); 121 121 kfree(hostdata); 122 122 free_irq(host->irq, host); 123 - 124 - return 0; 125 123 } 126 124 127 125 static struct platform_driver mvme16x_scsi_driver = { ··· 127 129 .name = "mvme16x-scsi", 128 130 }, 129 131 .probe = mvme16x_probe, 130 - .remove = mvme16x_device_remove, 132 + .remove_new = mvme16x_device_remove, 131 133 }; 132 134 133 135 static int __init mvme16x_scsi_init(void)
+2 -4
drivers/scsi/qlogicpti.c
··· 1409 1409 return -ENODEV; 1410 1410 } 1411 1411 1412 - static int qpti_sbus_remove(struct platform_device *op) 1412 + static void qpti_sbus_remove(struct platform_device *op) 1413 1413 { 1414 1414 struct qlogicpti *qpti = dev_get_drvdata(&op->dev); 1415 1415 ··· 1438 1438 of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char)); 1439 1439 1440 1440 scsi_host_put(qpti->qhost); 1441 - 1442 - return 0; 1443 1441 } 1444 1442 1445 1443 static const struct of_device_id qpti_match[] = { ··· 1463 1465 .of_match_table = qpti_match, 1464 1466 }, 1465 1467 .probe = qpti_sbus_probe, 1466 - .remove = qpti_sbus_remove, 1468 + .remove_new = qpti_sbus_remove, 1467 1469 }; 1468 1470 module_platform_driver(qpti_sbus_driver); 1469 1471
+1
drivers/scsi/scsi_error.c
··· 301 301 int ret; 302 302 303 303 WARN_ON_ONCE(!shost->ehandler); 304 + WARN_ON_ONCE(!test_bit(SCMD_STATE_INFLIGHT, &scmd->state)); 304 305 305 306 spin_lock_irqsave(shost->host_lock, flags); 306 307 if (scsi_host_set_state(shost, SHOST_RECOVERY)) {
+2 -3
drivers/scsi/sgiwd93.c
··· 291 291 return err; 292 292 } 293 293 294 - static int sgiwd93_remove(struct platform_device *pdev) 294 + static void sgiwd93_remove(struct platform_device *pdev) 295 295 { 296 296 struct Scsi_Host *host = platform_get_drvdata(pdev); 297 297 struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata; ··· 302 302 dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma, 303 303 DMA_TO_DEVICE); 304 304 scsi_host_put(host); 305 - return 0; 306 305 } 307 306 308 307 static struct platform_driver sgiwd93_driver = { 309 308 .probe = sgiwd93_probe, 310 - .remove = sgiwd93_remove, 309 + .remove_new = sgiwd93_remove, 311 310 .driver = { 312 311 .name = "sgiwd93", 313 312 }
+2 -4
drivers/scsi/sni_53c710.c
··· 104 104 return -ENODEV; 105 105 } 106 106 107 - static int snirm710_driver_remove(struct platform_device *dev) 107 + static void snirm710_driver_remove(struct platform_device *dev) 108 108 { 109 109 struct Scsi_Host *host = dev_get_drvdata(&dev->dev); 110 110 struct NCR_700_Host_Parameters *hostdata = ··· 115 115 free_irq(host->irq, host); 116 116 iounmap(hostdata->base); 117 117 kfree(hostdata); 118 - 119 - return 0; 120 118 } 121 119 122 120 static struct platform_driver snirm710_driver = { 123 121 .probe = snirm710_probe, 124 - .remove = snirm710_driver_remove, 122 + .remove_new = snirm710_driver_remove, 125 123 .driver = { 126 124 .name = "snirm_53c710", 127 125 },
+2 -3
drivers/scsi/sun3_scsi.c
··· 641 641 return error; 642 642 } 643 643 644 - static int __exit sun3_scsi_remove(struct platform_device *pdev) 644 + static void __exit sun3_scsi_remove(struct platform_device *pdev) 645 645 { 646 646 struct Scsi_Host *instance = platform_get_drvdata(pdev); 647 647 struct NCR5380_hostdata *hostdata = shost_priv(instance); ··· 654 654 if (udc_regs) 655 655 dvma_free(udc_regs); 656 656 iounmap(ioaddr); 657 - return 0; 658 657 } 659 658 660 659 static struct platform_driver sun3_scsi_driver = { 661 - .remove = __exit_p(sun3_scsi_remove), 660 + .remove_new = __exit_p(sun3_scsi_remove), 662 661 .driver = { 663 662 .name = DRV_MODULE_NAME, 664 663 },
+2 -4
drivers/scsi/sun3x_esp.c
··· 243 243 return err; 244 244 } 245 245 246 - static int esp_sun3x_remove(struct platform_device *dev) 246 + static void esp_sun3x_remove(struct platform_device *dev) 247 247 { 248 248 struct esp *esp = dev_get_drvdata(&dev->dev); 249 249 unsigned int irq = esp->host->irq; ··· 261 261 esp->command_block_dma); 262 262 263 263 scsi_host_put(esp->host); 264 - 265 - return 0; 266 264 } 267 265 268 266 static struct platform_driver esp_sun3x_driver = { 269 267 .probe = esp_sun3x_probe, 270 - .remove = esp_sun3x_remove, 268 + .remove_new = esp_sun3x_remove, 271 269 .driver = { 272 270 .name = "sun3x_esp", 273 271 },
+2 -4
drivers/scsi/sun_esp.c
··· 550 550 return ret; 551 551 } 552 552 553 - static int esp_sbus_remove(struct platform_device *op) 553 + static void esp_sbus_remove(struct platform_device *op) 554 554 { 555 555 struct esp *esp = dev_get_drvdata(&op->dev); 556 556 struct platform_device *dma_of = esp->dma; ··· 581 581 dev_set_drvdata(&op->dev, NULL); 582 582 583 583 put_device(&dma_of->dev); 584 - 585 - return 0; 586 584 } 587 585 588 586 static const struct of_device_id esp_match[] = { ··· 603 605 .of_match_table = esp_match, 604 606 }, 605 607 .probe = esp_sbus_probe, 606 - .remove = esp_sbus_remove, 608 + .remove_new = esp_sbus_remove, 607 609 }; 608 610 module_platform_driver(esp_sbus_driver); 609 611
+1
drivers/target/target_core_pr.c
··· 470 470 case INQUIRY: 471 471 case LOG_SENSE: 472 472 case SERVICE_ACTION_IN_12: 473 + case READ_CAPACITY: 473 474 case REPORT_LUNS: 474 475 case REQUEST_SENSE: 475 476 case PERSISTENT_RESERVE_IN:
+15 -4
drivers/ufs/core/ufs-fault-injection.c
··· 4 4 #include <linux/types.h> 5 5 #include <linux/fault-inject.h> 6 6 #include <linux/module.h> 7 + #include <ufs/ufshcd.h> 7 8 #include "ufs-fault-injection.h" 8 9 9 10 static int ufs_fault_get(char *buffer, const struct kernel_param *kp); ··· 60 59 return 0; 61 60 } 62 61 63 - bool ufs_trigger_eh(void) 62 + void ufs_fault_inject_hba_init(struct ufs_hba *hba) 64 63 { 65 - return should_fail(&ufs_trigger_eh_attr, 1); 64 + hba->trigger_eh_attr = ufs_trigger_eh_attr; 65 + hba->timeout_attr = ufs_timeout_attr; 66 + #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 67 + fault_create_debugfs_attr("trigger_eh_inject", hba->debugfs_root, &hba->trigger_eh_attr); 68 + fault_create_debugfs_attr("timeout_inject", hba->debugfs_root, &hba->timeout_attr); 69 + #endif 66 70 } 67 71 68 - bool ufs_fail_completion(void) 72 + bool ufs_trigger_eh(struct ufs_hba *hba) 69 73 { 70 - return should_fail(&ufs_timeout_attr, 1); 74 + return should_fail(&hba->trigger_eh_attr, 1); 75 + } 76 + 77 + bool ufs_fail_completion(struct ufs_hba *hba) 78 + { 79 + return should_fail(&hba->timeout_attr, 1); 71 80 }
+9 -4
drivers/ufs/core/ufs-fault-injection.h
··· 7 7 #include <linux/types.h> 8 8 9 9 #ifdef CONFIG_SCSI_UFS_FAULT_INJECTION 10 - bool ufs_trigger_eh(void); 11 - bool ufs_fail_completion(void); 10 + void ufs_fault_inject_hba_init(struct ufs_hba *hba); 11 + bool ufs_trigger_eh(struct ufs_hba *hba); 12 + bool ufs_fail_completion(struct ufs_hba *hba); 12 13 #else 13 - static inline bool ufs_trigger_eh(void) 14 + static inline void ufs_fault_inject_hba_init(struct ufs_hba *hba) 15 + { 16 + } 17 + 18 + static inline bool ufs_trigger_eh(struct ufs_hba *hba) 14 19 { 15 20 return false; 16 21 } 17 22 18 - static inline bool ufs_fail_completion(void) 23 + static inline bool ufs_fail_completion(struct ufs_hba *hba) 19 24 { 20 25 return false; 21 26 }
+151
drivers/ufs/core/ufs-sysfs.c
··· 7 7 #include <asm/unaligned.h> 8 8 9 9 #include <ufs/ufs.h> 10 + #include <ufs/unipro.h> 10 11 #include "ufs-sysfs.h" 11 12 #include "ufshcd-priv.h" 13 + 14 + static const char *ufs_pa_pwr_mode_to_string(enum ufs_pa_pwr_mode mode) 15 + { 16 + switch (mode) { 17 + case FAST_MODE: return "FAST_MODE"; 18 + case SLOW_MODE: return "SLOW_MODE"; 19 + case FASTAUTO_MODE: return "FASTAUTO_MODE"; 20 + case SLOWAUTO_MODE: return "SLOWAUTO_MODE"; 21 + default: return "UNKNOWN"; 22 + } 23 + } 24 + 25 + static const char *ufs_hs_gear_rate_to_string(enum ufs_hs_gear_rate rate) 26 + { 27 + switch (rate) { 28 + case PA_HS_MODE_A: return "HS_RATE_A"; 29 + case PA_HS_MODE_B: return "HS_RATE_B"; 30 + default: return "UNKNOWN"; 31 + } 32 + } 33 + 34 + static const char *ufs_pwm_gear_to_string(enum ufs_pwm_gear_tag gear) 35 + { 36 + switch (gear) { 37 + case UFS_PWM_G1: return "PWM_GEAR1"; 38 + case UFS_PWM_G2: return "PWM_GEAR2"; 39 + case UFS_PWM_G3: return "PWM_GEAR3"; 40 + case UFS_PWM_G4: return "PWM_GEAR4"; 41 + case UFS_PWM_G5: return "PWM_GEAR5"; 42 + case UFS_PWM_G6: return "PWM_GEAR6"; 43 + case UFS_PWM_G7: return "PWM_GEAR7"; 44 + default: return "UNKNOWN"; 45 + } 46 + } 47 + 48 + static const char *ufs_hs_gear_to_string(enum ufs_hs_gear_tag gear) 49 + { 50 + switch (gear) { 51 + case UFS_HS_G1: return "HS_GEAR1"; 52 + case UFS_HS_G2: return "HS_GEAR2"; 53 + case UFS_HS_G3: return "HS_GEAR3"; 54 + case UFS_HS_G4: return "HS_GEAR4"; 55 + case UFS_HS_G5: return "HS_GEAR5"; 56 + default: return "UNKNOWN"; 57 + } 58 + } 12 59 13 60 static const char *ufshcd_uic_link_state_to_string( 14 61 enum uic_link_state state) ··· 302 255 return res < 0 ? res : count; 303 256 } 304 257 258 + static ssize_t rtc_update_ms_show(struct device *dev, struct device_attribute *attr, 259 + char *buf) 260 + { 261 + struct ufs_hba *hba = dev_get_drvdata(dev); 262 + 263 + return sysfs_emit(buf, "%d\n", hba->dev_info.rtc_update_period); 264 + } 265 + 266 + static ssize_t rtc_update_ms_store(struct device *dev, struct device_attribute *attr, 267 + const char *buf, size_t count) 268 + { 269 + struct ufs_hba *hba = dev_get_drvdata(dev); 270 + unsigned int ms; 271 + bool resume_period_update = false; 272 + 273 + if (kstrtouint(buf, 0, &ms)) 274 + return -EINVAL; 275 + 276 + if (!hba->dev_info.rtc_update_period && ms > 0) 277 + resume_period_update = true; 278 + /* Minimum and maximum update frequency should be synchronized with all UFS vendors */ 279 + hba->dev_info.rtc_update_period = ms; 280 + 281 + if (resume_period_update) 282 + schedule_delayed_work(&hba->ufs_rtc_update_work, 283 + msecs_to_jiffies(hba->dev_info.rtc_update_period)); 284 + return count; 285 + } 286 + 305 287 static ssize_t enable_wb_buf_flush_show(struct device *dev, 306 288 struct device_attribute *attr, 307 289 char *buf) ··· 415 339 static DEVICE_ATTR_RW(wb_on); 416 340 static DEVICE_ATTR_RW(enable_wb_buf_flush); 417 341 static DEVICE_ATTR_RW(wb_flush_threshold); 342 + static DEVICE_ATTR_RW(rtc_update_ms); 418 343 419 344 static struct attribute *ufs_sysfs_ufshcd_attrs[] = { 420 345 &dev_attr_rpm_lvl.attr, ··· 428 351 &dev_attr_wb_on.attr, 429 352 &dev_attr_enable_wb_buf_flush.attr, 430 353 &dev_attr_wb_flush_threshold.attr, 354 + &dev_attr_rtc_update_ms.attr, 431 355 NULL 432 356 }; 433 357 ··· 704 626 static const struct attribute_group ufs_sysfs_monitor_group = { 705 627 .name = "monitor", 706 628 .attrs = ufs_sysfs_monitor_attrs, 629 + }; 630 + 631 + static ssize_t lane_show(struct device *dev, struct device_attribute *attr, 632 + char *buf) 633 + { 634 + struct ufs_hba *hba = dev_get_drvdata(dev); 635 + 636 + return sysfs_emit(buf, "%u\n", hba->pwr_info.lane_rx); 637 + } 638 + 639 + static ssize_t mode_show(struct device *dev, struct device_attribute *attr, 640 + char *buf) 641 + { 642 + struct ufs_hba *hba = dev_get_drvdata(dev); 643 + 644 + return sysfs_emit(buf, "%s\n", ufs_pa_pwr_mode_to_string(hba->pwr_info.pwr_rx)); 645 + } 646 + 647 + static ssize_t rate_show(struct device *dev, struct device_attribute *attr, 648 + char *buf) 649 + { 650 + struct ufs_hba *hba = dev_get_drvdata(dev); 651 + 652 + return sysfs_emit(buf, "%s\n", ufs_hs_gear_rate_to_string(hba->pwr_info.hs_rate)); 653 + } 654 + 655 + static ssize_t gear_show(struct device *dev, struct device_attribute *attr, 656 + char *buf) 657 + { 658 + struct ufs_hba *hba = dev_get_drvdata(dev); 659 + 660 + return sysfs_emit(buf, "%s\n", hba->pwr_info.hs_rate ? 661 + ufs_hs_gear_to_string(hba->pwr_info.gear_rx) : 662 + ufs_pwm_gear_to_string(hba->pwr_info.gear_rx)); 663 + } 664 + 665 + static ssize_t dev_pm_show(struct device *dev, struct device_attribute *attr, 666 + char *buf) 667 + { 668 + struct ufs_hba *hba = dev_get_drvdata(dev); 669 + 670 + return sysfs_emit(buf, "%s\n", ufshcd_ufs_dev_pwr_mode_to_string(hba->curr_dev_pwr_mode)); 671 + } 672 + 673 + static ssize_t link_state_show(struct device *dev, 674 + struct device_attribute *attr, char *buf) 675 + { 676 + struct ufs_hba *hba = dev_get_drvdata(dev); 677 + 678 + return sysfs_emit(buf, "%s\n", ufshcd_uic_link_state_to_string(hba->uic_link_state)); 679 + } 680 + 681 + static DEVICE_ATTR_RO(lane); 682 + static DEVICE_ATTR_RO(mode); 683 + static DEVICE_ATTR_RO(rate); 684 + static DEVICE_ATTR_RO(gear); 685 + static DEVICE_ATTR_RO(dev_pm); 686 + static DEVICE_ATTR_RO(link_state); 687 + 688 + static struct attribute *ufs_power_info_attrs[] = { 689 + &dev_attr_lane.attr, 690 + &dev_attr_mode.attr, 691 + &dev_attr_rate.attr, 692 + &dev_attr_gear.attr, 693 + &dev_attr_dev_pm.attr, 694 + &dev_attr_link_state.attr, 695 + NULL 696 + }; 697 + 698 + static const struct attribute_group ufs_sysfs_power_info_group = { 699 + .name = "power_info", 700 + .attrs = ufs_power_info_attrs, 707 701 }; 708 702 709 703 static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba, ··· 1383 1233 &ufs_sysfs_default_group, 1384 1234 &ufs_sysfs_capabilities_group, 1385 1235 &ufs_sysfs_monitor_group, 1236 + &ufs_sysfs_power_info_group, 1386 1237 &ufs_sysfs_device_descriptor_group, 1387 1238 &ufs_sysfs_interconnect_descriptor_group, 1388 1239 &ufs_sysfs_geometry_descriptor_group,
+125 -41
drivers/ufs/core/ufshcd.c
··· 99 99 /* Polling time to wait for fDeviceInit */ 100 100 #define FDEVICEINIT_COMPL_TIMEOUT 1500 /* millisecs */ 101 101 102 + /* Default RTC update every 10 seconds */ 103 + #define UFS_RTC_UPDATE_INTERVAL_MS (10 * MSEC_PER_SEC) 104 + 102 105 /* UFSHC 4.0 compliant HC support this mode. */ 103 106 static bool use_mcq_mode = true; 104 107 ··· 238 235 return UFS_PM_LVL_0; 239 236 } 240 237 238 + static bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba) 239 + { 240 + return (hba->clk_gating.active_reqs || hba->outstanding_reqs || hba->outstanding_tasks || 241 + hba->active_uic_cmd || hba->uic_async_done); 242 + } 243 + 241 244 static const struct ufs_dev_quirk ufs_fixups[] = { 242 245 /* UFS cards deviations table */ 243 246 { .wmanufacturerid = UFS_VENDOR_MICRON, ··· 298 289 static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba); 299 290 static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba); 300 291 301 - static inline void ufshcd_enable_irq(struct ufs_hba *hba) 292 + void ufshcd_enable_irq(struct ufs_hba *hba) 302 293 { 303 294 if (!hba->is_irq_enabled) { 304 295 enable_irq(hba->irq); 305 296 hba->is_irq_enabled = true; 306 297 } 307 298 } 299 + EXPORT_SYMBOL_GPL(ufshcd_enable_irq); 308 300 309 - static inline void ufshcd_disable_irq(struct ufs_hba *hba) 301 + void ufshcd_disable_irq(struct ufs_hba *hba) 310 302 { 311 303 if (hba->is_irq_enabled) { 312 304 disable_irq(hba->irq); 313 305 hba->is_irq_enabled = false; 314 306 } 315 307 } 308 + EXPORT_SYMBOL_GPL(ufshcd_disable_irq); 316 309 317 310 static void ufshcd_configure_wb(struct ufs_hba *hba) 318 311 { ··· 688 677 hba->dev_info.wb_enabled = false; 689 678 hba->dev_info.wb_buf_flush_enabled = false; 690 679 } 680 + if (hba->dev_info.rtc_type == UFS_RTC_RELATIVE) 681 + hba->dev_info.rtc_time_baseline = 0; 691 682 } 692 683 if (err != -EOPNOTSUPP) 693 684 ufshcd_update_evt_hist(hba, UFS_EVT_DEV_RESET, err); ··· 1930 1917 goto rel_lock; 1931 1918 } 1932 1919 1933 - if (hba->clk_gating.active_reqs 1934 - || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL 1935 - || hba->outstanding_reqs || hba->outstanding_tasks 1936 - || hba->active_uic_cmd || hba->uic_async_done) 1920 + if (ufshcd_is_ufs_dev_busy(hba) || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) 1937 1921 goto rel_lock; 1938 1922 1939 1923 spin_unlock_irqrestore(hba->host->host_lock, flags); ··· 2731 2721 .command_set_type = UPIU_COMMAND_SET_TYPE_SCSI, 2732 2722 }; 2733 2723 2724 + WARN_ON_ONCE(ucd_req_ptr->header.task_tag != lrbp->task_tag); 2725 + 2734 2726 ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length); 2735 2727 2736 2728 cdb_len = min_t(unsigned short, cmd->cmd_len, UFS_CDB_SIZE); ··· 3005 2993 ufshcd_send_command(hba, tag, hwq); 3006 2994 3007 2995 out: 3008 - if (ufs_trigger_eh()) { 2996 + if (ufs_trigger_eh(hba)) { 3009 2997 unsigned long flags; 3010 2998 3011 2999 spin_lock_irqsave(hba->host->host_lock, flags); ··· 4414 4402 } 4415 4403 EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_exit); 4416 4404 4417 - void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) 4418 - { 4419 - unsigned long flags; 4420 - bool update = false; 4421 - 4422 - if (!ufshcd_is_auto_hibern8_supported(hba)) 4423 - return; 4424 - 4425 - spin_lock_irqsave(hba->host->host_lock, flags); 4426 - if (hba->ahit != ahit) { 4427 - hba->ahit = ahit; 4428 - update = true; 4429 - } 4430 - spin_unlock_irqrestore(hba->host->host_lock, flags); 4431 - 4432 - if (update && 4433 - !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { 4434 - ufshcd_rpm_get_sync(hba); 4435 - ufshcd_hold(hba); 4436 - ufshcd_auto_hibern8_enable(hba); 4437 - ufshcd_release(hba); 4438 - ufshcd_rpm_put_sync(hba); 4439 - } 4440 - } 4441 - EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); 4442 - 4443 - void ufshcd_auto_hibern8_enable(struct ufs_hba *hba) 4405 + static void ufshcd_configure_auto_hibern8(struct ufs_hba *hba) 4444 4406 { 4445 4407 if (!ufshcd_is_auto_hibern8_supported(hba)) 4446 4408 return; 4447 4409 4448 4410 ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER); 4449 4411 } 4412 + 4413 + void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) 4414 + { 4415 + const u32 cur_ahit = READ_ONCE(hba->ahit); 4416 + 4417 + if (!ufshcd_is_auto_hibern8_supported(hba) || cur_ahit == ahit) 4418 + return; 4419 + 4420 + WRITE_ONCE(hba->ahit, ahit); 4421 + if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { 4422 + ufshcd_rpm_get_sync(hba); 4423 + ufshcd_hold(hba); 4424 + ufshcd_configure_auto_hibern8(hba); 4425 + ufshcd_release(hba); 4426 + ufshcd_rpm_put_sync(hba); 4427 + } 4428 + } 4429 + EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); 4450 4430 4451 4431 /** 4452 4432 * ufshcd_init_pwr_info - setting the POR (power on reset) ··· 5654 5650 !(hba->quirks & UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR)) 5655 5651 ufshcd_reset_intr_aggr(hba); 5656 5652 5657 - if (ufs_fail_completion()) 5653 + if (ufs_fail_completion(hba)) 5658 5654 return IRQ_HANDLED; 5659 5655 5660 5656 /* ··· 8203 8199 ufshcd_vops_fixup_dev_quirks(hba); 8204 8200 } 8205 8201 8202 + static void ufshcd_update_rtc(struct ufs_hba *hba) 8203 + { 8204 + struct timespec64 ts64; 8205 + int err; 8206 + u32 val; 8207 + 8208 + ktime_get_real_ts64(&ts64); 8209 + 8210 + if (ts64.tv_sec < hba->dev_info.rtc_time_baseline) { 8211 + dev_warn_once(hba->dev, "%s: Current time precedes previous setting!\n", __func__); 8212 + return; 8213 + } 8214 + 8215 + /* 8216 + * The Absolute RTC mode has a 136-year limit, spanning from 2010 to 2146. If a time beyond 8217 + * 2146 is required, it is recommended to choose the relative RTC mode. 8218 + */ 8219 + val = ts64.tv_sec - hba->dev_info.rtc_time_baseline; 8220 + 8221 + ufshcd_rpm_get_sync(hba); 8222 + err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, QUERY_ATTR_IDN_SECONDS_PASSED, 8223 + 0, 0, &val); 8224 + ufshcd_rpm_put_sync(hba); 8225 + 8226 + if (err) 8227 + dev_err(hba->dev, "%s: Failed to update rtc %d\n", __func__, err); 8228 + else if (hba->dev_info.rtc_type == UFS_RTC_RELATIVE) 8229 + hba->dev_info.rtc_time_baseline = ts64.tv_sec; 8230 + } 8231 + 8232 + static void ufshcd_rtc_work(struct work_struct *work) 8233 + { 8234 + struct ufs_hba *hba; 8235 + 8236 + hba = container_of(to_delayed_work(work), struct ufs_hba, ufs_rtc_update_work); 8237 + 8238 + /* Update RTC only when there are no requests in progress and UFSHCI is operational */ 8239 + if (!ufshcd_is_ufs_dev_busy(hba) && hba->ufshcd_state == UFSHCD_STATE_OPERATIONAL) 8240 + ufshcd_update_rtc(hba); 8241 + 8242 + if (ufshcd_is_ufs_dev_active(hba) && hba->dev_info.rtc_update_period) 8243 + schedule_delayed_work(&hba->ufs_rtc_update_work, 8244 + msecs_to_jiffies(hba->dev_info.rtc_update_period)); 8245 + } 8246 + 8247 + static void ufs_init_rtc(struct ufs_hba *hba, u8 *desc_buf) 8248 + { 8249 + u16 periodic_rtc_update = get_unaligned_be16(&desc_buf[DEVICE_DESC_PARAM_FRQ_RTC]); 8250 + struct ufs_dev_info *dev_info = &hba->dev_info; 8251 + 8252 + if (periodic_rtc_update & UFS_RTC_TIME_BASELINE) { 8253 + dev_info->rtc_type = UFS_RTC_ABSOLUTE; 8254 + 8255 + /* 8256 + * The concept of measuring time in Linux as the number of seconds elapsed since 8257 + * 00:00:00 UTC on January 1, 1970, and UFS ABS RTC is elapsed from January 1st 8258 + * 2010 00:00, here we need to adjust ABS baseline. 8259 + */ 8260 + dev_info->rtc_time_baseline = mktime64(2010, 1, 1, 0, 0, 0) - 8261 + mktime64(1970, 1, 1, 0, 0, 0); 8262 + } else { 8263 + dev_info->rtc_type = UFS_RTC_RELATIVE; 8264 + dev_info->rtc_time_baseline = 0; 8265 + } 8266 + 8267 + /* 8268 + * We ignore TIME_PERIOD defined in wPeriodicRTCUpdate because Spec does not clearly state 8269 + * how to calculate the specific update period for each time unit. And we disable periodic 8270 + * RTC update work, let user configure by sysfs node according to specific circumstance. 8271 + */ 8272 + dev_info->rtc_update_period = 0; 8273 + } 8274 + 8206 8275 static int ufs_get_device_desc(struct ufs_hba *hba) 8207 8276 { 8208 8277 int err; ··· 8327 8250 ufshcd_wb_probe(hba, desc_buf); 8328 8251 8329 8252 ufshcd_temp_notif_probe(hba, desc_buf); 8253 + 8254 + ufs_init_rtc(hba, desc_buf); 8330 8255 8331 8256 if (hba->ext_iid_sup) 8332 8257 ufshcd_ext_iid_probe(hba, desc_buf); ··· 8883 8804 ufshcd_force_reset_auto_bkops(hba); 8884 8805 8885 8806 ufshcd_set_timestamp_attr(hba); 8807 + schedule_delayed_work(&hba->ufs_rtc_update_work, 8808 + msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); 8886 8809 8887 8810 /* Gear up to HS gear if supported */ 8888 8811 if (hba->max_pwr_info.is_valid) { ··· 8959 8878 8960 8879 if (hba->ee_usr_mask) 8961 8880 ufshcd_write_ee_control(hba); 8962 - /* Enable Auto-Hibernate if configured */ 8963 - ufshcd_auto_hibern8_enable(hba); 8881 + ufshcd_configure_auto_hibern8(hba); 8964 8882 8965 8883 out: 8966 8884 spin_lock_irqsave(hba->host->host_lock, flags); ··· 9442 9362 goto out_disable_vreg; 9443 9363 9444 9364 ufs_debugfs_hba_init(hba); 9365 + ufs_fault_inject_hba_init(hba); 9445 9366 9446 9367 hba->is_powered = true; 9447 9368 goto out; ··· 9841 9760 ret = ufshcd_vops_suspend(hba, pm_op, POST_CHANGE); 9842 9761 if (ret) 9843 9762 goto set_link_active; 9763 + 9764 + cancel_delayed_work_sync(&hba->ufs_rtc_update_work); 9844 9765 goto out; 9845 9766 9846 9767 set_link_active: ··· 9937 9854 if (ret) 9938 9855 goto set_old_link_state; 9939 9856 ufshcd_set_timestamp_attr(hba); 9857 + schedule_delayed_work(&hba->ufs_rtc_update_work, 9858 + msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); 9940 9859 } 9941 9860 9942 9861 if (ufshcd_keep_autobkops_enabled_except_suspend(hba)) ··· 9961 9876 cancel_delayed_work(&hba->rpm_dev_flush_recheck_work); 9962 9877 } 9963 9878 9964 - /* Enable Auto-Hibernate if configured */ 9965 - ufshcd_auto_hibern8_enable(hba); 9879 + ufshcd_configure_auto_hibern8(hba); 9966 9880 9967 9881 goto out; 9968 9882 ··· 10634 10550 UFS_SLEEP_PWR_MODE, 10635 10551 UIC_LINK_HIBERN8_STATE); 10636 10552 10637 - INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, 10638 - ufshcd_rpm_dev_flush_recheck_work); 10553 + INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work); 10554 + INIT_DELAYED_WORK(&hba->ufs_rtc_update_work, ufshcd_rtc_work); 10639 10555 10640 10556 /* Set the default auto-hiberate idle timer value to 150 ms */ 10641 10557 if (ufshcd_is_auto_hibern8_supported(hba) && !hba->ahit) {
+3 -4
drivers/ufs/host/ufs-exynos.c
··· 765 765 { 766 766 struct exynos_ufs *ufs = ufshcd_get_variant(hba); 767 767 struct phy *generic_phy = ufs->phy; 768 - struct ufs_dev_params ufs_exynos_cap; 768 + struct ufs_host_params host_params; 769 769 int ret; 770 770 771 771 if (!dev_req_params) { ··· 774 774 goto out; 775 775 } 776 776 777 - ufshcd_init_pwr_dev_param(&ufs_exynos_cap); 777 + ufshcd_init_host_params(&host_params); 778 778 779 - ret = ufshcd_get_pwr_dev_param(&ufs_exynos_cap, 780 - dev_max_params, dev_req_params); 779 + ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params); 781 780 if (ret) { 782 781 pr_err("%s: failed to determine capabilities\n", __func__); 783 782 goto out;
+5 -6
drivers/ufs/host/ufs-hisi.c
··· 293 293 return err; 294 294 } 295 295 296 - static void ufs_hisi_set_dev_cap(struct ufs_dev_params *hisi_param) 296 + static void ufs_hisi_set_dev_cap(struct ufs_host_params *host_params) 297 297 { 298 - ufshcd_init_pwr_dev_param(hisi_param); 298 + ufshcd_init_host_params(host_params); 299 299 } 300 300 301 301 static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba) ··· 365 365 struct ufs_pa_layer_attr *dev_max_params, 366 366 struct ufs_pa_layer_attr *dev_req_params) 367 367 { 368 - struct ufs_dev_params ufs_hisi_cap; 368 + struct ufs_host_params host_params; 369 369 int ret = 0; 370 370 371 371 if (!dev_req_params) { ··· 377 377 378 378 switch (status) { 379 379 case PRE_CHANGE: 380 - ufs_hisi_set_dev_cap(&ufs_hisi_cap); 381 - ret = ufshcd_get_pwr_dev_param(&ufs_hisi_cap, 382 - dev_max_params, dev_req_params); 380 + ufs_hisi_set_dev_cap(&host_params); 381 + ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params); 383 382 if (ret) { 384 383 dev_err(hba->dev, 385 384 "%s: failed to determine capabilities\n", __func__);
+5 -7
drivers/ufs/host/ufs-mediatek.c
··· 996 996 struct ufs_pa_layer_attr *dev_req_params) 997 997 { 998 998 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 999 - struct ufs_dev_params host_cap; 999 + struct ufs_host_params host_params; 1000 1000 int ret; 1001 1001 1002 - ufshcd_init_pwr_dev_param(&host_cap); 1003 - host_cap.hs_rx_gear = UFS_HS_G5; 1004 - host_cap.hs_tx_gear = UFS_HS_G5; 1002 + ufshcd_init_host_params(&host_params); 1003 + host_params.hs_rx_gear = UFS_HS_G5; 1004 + host_params.hs_tx_gear = UFS_HS_G5; 1005 1005 1006 - ret = ufshcd_get_pwr_dev_param(&host_cap, 1007 - dev_max_params, 1008 - dev_req_params); 1006 + ret = ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req_params); 1009 1007 if (ret) { 1010 1008 pr_info("%s: failed to determine capabilities\n", 1011 1009 __func__);
+130 -344
drivers/ufs/host/ufs-qcom.c
··· 4 4 */ 5 5 6 6 #include <linux/acpi.h> 7 - #include <linux/time.h> 8 7 #include <linux/clk.h> 9 8 #include <linux/delay.h> 9 + #include <linux/devfreq.h> 10 + #include <linux/gpio/consumer.h> 10 11 #include <linux/interconnect.h> 11 12 #include <linux/module.h> 12 13 #include <linux/of.h> 13 - #include <linux/platform_device.h> 14 14 #include <linux/phy/phy.h> 15 - #include <linux/gpio/consumer.h> 15 + #include <linux/platform_device.h> 16 16 #include <linux/reset-controller.h> 17 - #include <linux/devfreq.h> 17 + #include <linux/time.h> 18 18 19 19 #include <soc/qcom/ice.h> 20 20 21 21 #include <ufs/ufshcd.h> 22 - #include "ufshcd-pltfrm.h" 23 - #include <ufs/unipro.h> 24 - #include "ufs-qcom.h" 25 22 #include <ufs/ufshci.h> 26 23 #include <ufs/ufs_quirks.h> 24 + #include <ufs/unipro.h> 25 + #include "ufshcd-pltfrm.h" 26 + #include "ufs-qcom.h" 27 27 28 28 #define MCQ_QCFGPTR_MASK GENMASK(7, 0) 29 29 #define MCQ_QCFGPTR_UNIT 0x200 ··· 89 89 [MODE_HS_RB][UFS_HS_G4][UFS_LANE_2] = { 2915200, 409600 }, 90 90 [MODE_MAX][0][0] = { 7643136, 307200 }, 91 91 }; 92 - 93 - static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS]; 94 92 95 93 static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host); 96 94 static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up); ··· 156 158 cap = hba->crypto_cap_array[cfg->crypto_cap_idx]; 157 159 if (cap.algorithm_id != UFS_CRYPTO_ALG_AES_XTS || 158 160 cap.key_size != UFS_CRYPTO_KEY_SIZE_256) 159 - return -EINVAL; 161 + return -EOPNOTSUPP; 160 162 161 163 if (config_enable) 162 164 return qcom_ice_program_key(host->ice, ··· 192 194 } 193 195 #endif 194 196 195 - static int ufs_qcom_host_clk_get(struct device *dev, 196 - const char *name, struct clk **clk_out, bool optional) 197 - { 198 - struct clk *clk; 199 - int err = 0; 200 - 201 - clk = devm_clk_get(dev, name); 202 - if (!IS_ERR(clk)) { 203 - *clk_out = clk; 204 - return 0; 205 - } 206 - 207 - err = PTR_ERR(clk); 208 - 209 - if (optional && err == -ENOENT) { 210 - *clk_out = NULL; 211 - return 0; 212 - } 213 - 214 - if (err != -EPROBE_DEFER) 215 - dev_err(dev, "failed to get %s err %d\n", name, err); 216 - 217 - return err; 218 - } 219 - 220 - static int ufs_qcom_host_clk_enable(struct device *dev, 221 - const char *name, struct clk *clk) 222 - { 223 - int err = 0; 224 - 225 - err = clk_prepare_enable(clk); 226 - if (err) 227 - dev_err(dev, "%s: %s enable failed %d\n", __func__, name, err); 228 - 229 - return err; 230 - } 231 - 232 197 static void ufs_qcom_disable_lane_clks(struct ufs_qcom_host *host) 233 198 { 234 199 if (!host->is_lane_clks_enabled) 235 200 return; 236 201 237 - clk_disable_unprepare(host->tx_l1_sync_clk); 238 - clk_disable_unprepare(host->tx_l0_sync_clk); 239 - clk_disable_unprepare(host->rx_l1_sync_clk); 240 - clk_disable_unprepare(host->rx_l0_sync_clk); 202 + clk_bulk_disable_unprepare(host->num_clks, host->clks); 241 203 242 204 host->is_lane_clks_enabled = false; 243 205 } ··· 205 247 static int ufs_qcom_enable_lane_clks(struct ufs_qcom_host *host) 206 248 { 207 249 int err; 208 - struct device *dev = host->hba->dev; 209 250 210 - if (host->is_lane_clks_enabled) 211 - return 0; 212 - 213 - err = ufs_qcom_host_clk_enable(dev, "rx_lane0_sync_clk", 214 - host->rx_l0_sync_clk); 251 + err = clk_bulk_prepare_enable(host->num_clks, host->clks); 215 252 if (err) 216 253 return err; 217 - 218 - err = ufs_qcom_host_clk_enable(dev, "tx_lane0_sync_clk", 219 - host->tx_l0_sync_clk); 220 - if (err) 221 - goto disable_rx_l0; 222 - 223 - err = ufs_qcom_host_clk_enable(dev, "rx_lane1_sync_clk", 224 - host->rx_l1_sync_clk); 225 - if (err) 226 - goto disable_tx_l0; 227 - 228 - err = ufs_qcom_host_clk_enable(dev, "tx_lane1_sync_clk", 229 - host->tx_l1_sync_clk); 230 - if (err) 231 - goto disable_rx_l1; 232 254 233 255 host->is_lane_clks_enabled = true; 234 256 235 257 return 0; 236 - 237 - disable_rx_l1: 238 - clk_disable_unprepare(host->rx_l1_sync_clk); 239 - disable_tx_l0: 240 - clk_disable_unprepare(host->tx_l0_sync_clk); 241 - disable_rx_l0: 242 - clk_disable_unprepare(host->rx_l0_sync_clk); 243 - 244 - return err; 245 258 } 246 259 247 260 static int ufs_qcom_init_lane_clks(struct ufs_qcom_host *host) 248 261 { 249 - int err = 0; 262 + int err; 250 263 struct device *dev = host->hba->dev; 251 264 252 265 if (has_acpi_companion(dev)) 253 266 return 0; 254 267 255 - err = ufs_qcom_host_clk_get(dev, "rx_lane0_sync_clk", 256 - &host->rx_l0_sync_clk, false); 257 - if (err) 268 + err = devm_clk_bulk_get_all(dev, &host->clks); 269 + if (err <= 0) 258 270 return err; 259 271 260 - err = ufs_qcom_host_clk_get(dev, "tx_lane0_sync_clk", 261 - &host->tx_l0_sync_clk, false); 262 - if (err) 263 - return err; 264 - 265 - /* In case of single lane per direction, don't read lane1 clocks */ 266 - if (host->hba->lanes_per_direction > 1) { 267 - err = ufs_qcom_host_clk_get(dev, "rx_lane1_sync_clk", 268 - &host->rx_l1_sync_clk, false); 269 - if (err) 270 - return err; 271 - 272 - err = ufs_qcom_host_clk_get(dev, "tx_lane1_sync_clk", 273 - &host->tx_l1_sync_clk, true); 274 - } 272 + host->num_clks = err; 275 273 276 274 return 0; 277 275 } ··· 235 321 static int ufs_qcom_check_hibern8(struct ufs_hba *hba) 236 322 { 237 323 int err; 238 - u32 tx_fsm_val = 0; 324 + u32 tx_fsm_val; 239 325 unsigned long timeout = jiffies + msecs_to_jiffies(HBRN8_POLL_TOUT_MS); 240 326 241 327 do { ··· 274 360 275 361 static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) 276 362 { 277 - ufshcd_rmwl(host->hba, QUNIPRO_SEL, 278 - ufs_qcom_cap_qunipro(host) ? QUNIPRO_SEL : 0, 279 - REG_UFS_CFG1); 363 + ufshcd_rmwl(host->hba, QUNIPRO_SEL, QUNIPRO_SEL, REG_UFS_CFG1); 280 364 281 365 if (host->hw_ver.major >= 0x05) 282 366 ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); ··· 288 376 */ 289 377 static int ufs_qcom_host_reset(struct ufs_hba *hba) 290 378 { 291 - int ret = 0; 379 + int ret; 292 380 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 293 - bool reenable_intr = false; 381 + bool reenable_intr; 294 382 295 - if (!host->core_reset) { 296 - dev_warn(hba->dev, "%s: reset control not set\n", __func__); 383 + if (!host->core_reset) 297 384 return 0; 298 - } 299 385 300 386 reenable_intr = hba->is_irq_enabled; 301 - disable_irq(hba->irq); 302 - hba->is_irq_enabled = false; 387 + ufshcd_disable_irq(hba); 303 388 304 389 ret = reset_control_assert(host->core_reset); 305 390 if (ret) { ··· 313 404 usleep_range(200, 210); 314 405 315 406 ret = reset_control_deassert(host->core_reset); 316 - if (ret) 407 + if (ret) { 317 408 dev_err(hba->dev, "%s: core_reset deassert failed, err = %d\n", 318 409 __func__, ret); 410 + return ret; 411 + } 319 412 320 413 usleep_range(1000, 1100); 321 414 322 - if (reenable_intr) { 323 - enable_irq(hba->irq); 324 - hba->is_irq_enabled = true; 325 - } 415 + if (reenable_intr) 416 + ufshcd_enable_irq(hba); 326 417 327 418 return 0; 328 419 } ··· 331 422 { 332 423 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 333 424 334 - if (host->hw_ver.major == 0x1) { 335 - /* 336 - * HS-G3 operations may not reliably work on legacy QCOM 337 - * UFS host controller hardware even though capability 338 - * exchange during link startup phase may end up 339 - * negotiating maximum supported gear as G3. 340 - * Hence downgrade the maximum supported gear to HS-G2. 341 - */ 342 - return UFS_HS_G2; 343 - } else if (host->hw_ver.major >= 0x4) { 425 + if (host->hw_ver.major >= 0x4) 344 426 return UFS_QCOM_MAX_GEAR(ufshcd_readl(hba, REG_UFS_PARAM0)); 345 - } 346 427 347 428 /* Default is HS-G3 */ 348 429 return UFS_HS_G3; ··· 341 442 static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) 342 443 { 343 444 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 445 + struct ufs_host_params *host_params = &host->host_params; 344 446 struct phy *phy = host->generic_phy; 447 + enum phy_mode mode; 345 448 int ret; 449 + 450 + /* 451 + * HW ver 5 can only support up to HS-G5 Rate-A due to HW limitations. 452 + * If the HS-G5 PHY gear is used, update host_params->hs_rate to Rate-A, 453 + * so that the subsequent power mode change shall stick to Rate-A. 454 + */ 455 + if (host->hw_ver.major == 0x5) { 456 + if (host->phy_gear == UFS_HS_G5) 457 + host_params->hs_rate = PA_HS_MODE_A; 458 + else 459 + host_params->hs_rate = PA_HS_MODE_B; 460 + } 461 + 462 + mode = host_params->hs_rate == PA_HS_MODE_B ? PHY_MODE_UFS_HS_B : PHY_MODE_UFS_HS_A; 346 463 347 464 /* Reset UFS Host Controller and PHY */ 348 465 ret = ufs_qcom_host_reset(hba); 349 466 if (ret) 350 - dev_warn(hba->dev, "%s: host reset returned %d\n", 351 - __func__, ret); 467 + return ret; 352 468 353 469 /* phy initialization - calibrate the phy */ 354 470 ret = phy_init(phy); ··· 373 459 return ret; 374 460 } 375 461 376 - phy_set_mode_ext(phy, PHY_MODE_UFS_HS_B, host->phy_gear); 462 + ret = phy_set_mode_ext(phy, mode, host->phy_gear); 463 + if (ret) 464 + goto out_disable_phy; 377 465 378 466 /* power on phy - start serdes and phy's power and clocks */ 379 467 ret = phy_power_on(phy); ··· 405 489 */ 406 490 static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) 407 491 { 408 - ufshcd_writel(hba, 409 - ufshcd_readl(hba, REG_UFS_CFG2) | REG_UFS_CFG2_CGC_EN_ALL, 410 - REG_UFS_CFG2); 492 + ufshcd_rmwl(hba, REG_UFS_CFG2_CGC_EN_ALL, REG_UFS_CFG2_CGC_EN_ALL, 493 + REG_UFS_CFG2); 411 494 412 495 /* Ensure that HW clock gating is enabled before next operations */ 413 496 mb(); ··· 416 501 enum ufs_notify_change_status status) 417 502 { 418 503 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 419 - int err = 0; 504 + int err; 420 505 421 506 switch (status) { 422 507 case PRE_CHANGE: 423 - ufs_qcom_power_up_sequence(hba); 508 + err = ufs_qcom_power_up_sequence(hba); 509 + if (err) 510 + return err; 511 + 424 512 /* 425 513 * The PHY PLL output is the source of tx/rx lane symbol 426 514 * clocks, hence, enable the lane clocks only after PHY ··· 462 544 { 463 545 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 464 546 struct ufs_clk_info *clki; 465 - u32 core_clk_period_in_ns; 466 - u32 tx_clk_cycles_per_us = 0; 467 547 unsigned long core_clk_rate = 0; 468 - u32 core_clk_cycles_per_us = 0; 469 - 470 - static u32 pwm_fr_table[][2] = { 471 - {UFS_PWM_G1, 0x1}, 472 - {UFS_PWM_G2, 0x1}, 473 - {UFS_PWM_G3, 0x1}, 474 - {UFS_PWM_G4, 0x1}, 475 - }; 476 - 477 - static u32 hs_fr_table_rA[][2] = { 478 - {UFS_HS_G1, 0x1F}, 479 - {UFS_HS_G2, 0x3e}, 480 - {UFS_HS_G3, 0x7D}, 481 - }; 482 - 483 - static u32 hs_fr_table_rB[][2] = { 484 - {UFS_HS_G1, 0x24}, 485 - {UFS_HS_G2, 0x49}, 486 - {UFS_HS_G3, 0x92}, 487 - }; 548 + u32 core_clk_cycles_per_us; 488 549 489 550 /* 490 - * The Qunipro controller does not use following registers: 491 - * SYS1CLK_1US_REG, TX_SYMBOL_CLK_1US_REG, CLK_NS_REG & 492 - * UFS_REG_PA_LINK_STARTUP_TIMER. 493 - * However UTP controller uses SYS1CLK_1US_REG register for Interrupt 551 + * UTP controller uses SYS1CLK_1US_REG register for Interrupt 494 552 * Aggregation logic. 495 553 * It is mandatory to write SYS1CLK_1US_REG register on UFS host 496 554 * controller V4.0.0 onwards. 497 555 */ 498 - if (host->hw_ver.major < 4 && ufs_qcom_cap_qunipro(host) && 499 - !ufshcd_is_intr_aggr_allowed(hba)) 556 + if (host->hw_ver.major < 4 && !ufshcd_is_intr_aggr_allowed(hba)) 500 557 return 0; 501 558 502 559 if (gear == 0) { ··· 504 611 mb(); 505 612 } 506 613 507 - if (ufs_qcom_cap_qunipro(host)) 508 - return 0; 509 - 510 - core_clk_period_in_ns = NSEC_PER_SEC / core_clk_rate; 511 - core_clk_period_in_ns <<= OFFSET_CLK_NS_REG; 512 - core_clk_period_in_ns &= MASK_CLK_NS_REG; 513 - 514 - switch (hs) { 515 - case FASTAUTO_MODE: 516 - case FAST_MODE: 517 - if (rate == PA_HS_MODE_A) { 518 - if (gear > ARRAY_SIZE(hs_fr_table_rA)) { 519 - dev_err(hba->dev, 520 - "%s: index %d exceeds table size %zu\n", 521 - __func__, gear, 522 - ARRAY_SIZE(hs_fr_table_rA)); 523 - return -EINVAL; 524 - } 525 - tx_clk_cycles_per_us = hs_fr_table_rA[gear-1][1]; 526 - } else if (rate == PA_HS_MODE_B) { 527 - if (gear > ARRAY_SIZE(hs_fr_table_rB)) { 528 - dev_err(hba->dev, 529 - "%s: index %d exceeds table size %zu\n", 530 - __func__, gear, 531 - ARRAY_SIZE(hs_fr_table_rB)); 532 - return -EINVAL; 533 - } 534 - tx_clk_cycles_per_us = hs_fr_table_rB[gear-1][1]; 535 - } else { 536 - dev_err(hba->dev, "%s: invalid rate = %d\n", 537 - __func__, rate); 538 - return -EINVAL; 539 - } 540 - break; 541 - case SLOWAUTO_MODE: 542 - case SLOW_MODE: 543 - if (gear > ARRAY_SIZE(pwm_fr_table)) { 544 - dev_err(hba->dev, 545 - "%s: index %d exceeds table size %zu\n", 546 - __func__, gear, 547 - ARRAY_SIZE(pwm_fr_table)); 548 - return -EINVAL; 549 - } 550 - tx_clk_cycles_per_us = pwm_fr_table[gear-1][1]; 551 - break; 552 - case UNCHANGED: 553 - default: 554 - dev_err(hba->dev, "%s: invalid mode = %d\n", __func__, hs); 555 - return -EINVAL; 556 - } 557 - 558 - if (ufshcd_readl(hba, REG_UFS_TX_SYMBOL_CLK_NS_US) != 559 - (core_clk_period_in_ns | tx_clk_cycles_per_us)) { 560 - /* this register 2 fields shall be written at once */ 561 - ufshcd_writel(hba, core_clk_period_in_ns | tx_clk_cycles_per_us, 562 - REG_UFS_TX_SYMBOL_CLK_NS_US); 563 - /* 564 - * make sure above write gets applied before we return from 565 - * this function. 566 - */ 567 - mb(); 568 - } 569 - 570 - if (update_link_startup_timer && host->hw_ver.major != 0x5) { 571 - ufshcd_writel(hba, ((core_clk_rate / MSEC_PER_SEC) * 100), 572 - REG_UFS_CFG0); 573 - /* 574 - * make sure that this configuration is applied before 575 - * we return 576 - */ 577 - mb(); 578 - } 579 - 580 614 return 0; 581 615 } 582 616 ··· 511 691 enum ufs_notify_change_status status) 512 692 { 513 693 int err = 0; 514 - struct ufs_qcom_host *host = ufshcd_get_variant(hba); 515 694 516 695 switch (status) { 517 696 case PRE_CHANGE: ··· 521 702 return -EINVAL; 522 703 } 523 704 524 - if (ufs_qcom_cap_qunipro(host)) { 525 - err = ufs_qcom_set_core_clk_ctrl(hba, true); 526 - if (err) 527 - dev_err(hba->dev, "cfg core clk ctrl failed\n"); 528 - } 705 + err = ufs_qcom_set_core_clk_ctrl(hba, true); 706 + if (err) 707 + dev_err(hba->dev, "cfg core clk ctrl failed\n"); 529 708 /* 530 709 * Some UFS devices (and may be host) have issues if LCC is 531 710 * enabled. So we are setting PA_Local_TX_LCC_Enable to 0 ··· 715 898 struct ufs_pa_layer_attr *dev_req_params) 716 899 { 717 900 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 718 - struct ufs_dev_params ufs_qcom_cap; 901 + struct ufs_host_params *host_params = &host->host_params; 719 902 int ret = 0; 720 903 721 904 if (!dev_req_params) { ··· 725 908 726 909 switch (status) { 727 910 case PRE_CHANGE: 728 - ufshcd_init_pwr_dev_param(&ufs_qcom_cap); 729 - ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE; 730 - 731 - /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */ 732 - ufs_qcom_cap.hs_tx_gear = ufs_qcom_cap.hs_rx_gear = ufs_qcom_get_hs_gear(hba); 733 - 734 - ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap, 735 - dev_max_params, 736 - dev_req_params); 911 + ret = ufshcd_negotiate_pwr_params(host_params, dev_max_params, dev_req_params); 737 912 if (ret) { 738 913 dev_err(hba->dev, "%s: failed to determine capabilities\n", 739 914 __func__); ··· 733 924 } 734 925 735 926 /* 736 - * Update phy_gear only when the gears are scaled to a higher value. This is 737 - * because, the PHY gear settings are backwards compatible and we only need to 738 - * change the PHY gear settings while scaling to higher gears. 927 + * During UFS driver probe, always update the PHY gear to match the negotiated 928 + * gear, so that, if quirk UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is enabled, 929 + * the second init can program the optimal PHY settings. This allows one to start 930 + * the first init with either the minimum or the maximum support gear. 739 931 */ 740 - if (dev_req_params->gear_tx > host->phy_gear) 932 + if (hba->ufshcd_state == UFSHCD_STATE_RESET) 741 933 host->phy_gear = dev_req_params->gear_tx; 742 934 743 935 /* enable the device ref clock before changing to HS mode */ ··· 815 1005 816 1006 static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba) 817 1007 { 818 - struct ufs_qcom_host *host = ufshcd_get_variant(hba); 819 - 820 - if (host->hw_ver.major == 0x1) 821 - return ufshci_version(1, 1); 822 - else 823 - return ufshci_version(2, 0); 1008 + return ufshci_version(2, 0); 824 1009 } 825 1010 826 1011 /** ··· 831 1026 { 832 1027 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 833 1028 834 - if (host->hw_ver.major == 0x01) { 835 - hba->quirks |= UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS 836 - | UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP 837 - | UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE; 838 - 839 - if (host->hw_ver.minor == 0x0001 && host->hw_ver.step == 0x0001) 840 - hba->quirks |= UFSHCD_QUIRK_BROKEN_INTR_AGGR; 841 - 842 - hba->quirks |= UFSHCD_QUIRK_BROKEN_LCC; 843 - } 844 - 845 - if (host->hw_ver.major == 0x2) { 1029 + if (host->hw_ver.major == 0x2) 846 1030 hba->quirks |= UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION; 847 - 848 - if (!ufs_qcom_cap_qunipro(host)) 849 - /* Legacy UniPro mode still need following quirks */ 850 - hba->quirks |= (UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS 851 - | UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE 852 - | UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP); 853 - } 854 1031 855 1032 if (host->hw_ver.major > 0x3) 856 1033 hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; 857 1034 } 858 1035 859 - static void ufs_qcom_set_caps(struct ufs_hba *hba) 1036 + static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host) 1037 + { 1038 + struct ufs_host_params *host_params = &host->host_params; 1039 + u32 val, dev_major; 1040 + 1041 + host->phy_gear = host_params->hs_tx_gear; 1042 + 1043 + if (host->hw_ver.major < 0x4) { 1044 + /* 1045 + * For controllers whose major HW version is < 4, power up the 1046 + * PHY using minimum supported gear (UFS_HS_G2). Switching to 1047 + * max gear will be performed during reinit if supported. 1048 + * For newer controllers, whose major HW version is >= 4, power 1049 + * up the PHY using max supported gear. 1050 + */ 1051 + host->phy_gear = UFS_HS_G2; 1052 + } else if (host->hw_ver.major >= 0x5) { 1053 + val = ufshcd_readl(host->hba, REG_UFS_DEBUG_SPARE_CFG); 1054 + dev_major = FIELD_GET(UFS_DEV_VER_MAJOR_MASK, val); 1055 + 1056 + /* 1057 + * Since the UFS device version is populated, let's remove the 1058 + * REINIT quirk as the negotiated gear won't change during boot. 1059 + * So there is no need to do reinit. 1060 + */ 1061 + if (dev_major != 0x0) 1062 + host->hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH; 1063 + 1064 + /* 1065 + * For UFS 3.1 device and older, power up the PHY using HS-G4 1066 + * PHY gear to save power. 1067 + */ 1068 + if (dev_major > 0x0 && dev_major < 0x4) 1069 + host->phy_gear = UFS_HS_G4; 1070 + } 1071 + } 1072 + 1073 + static void ufs_qcom_set_host_params(struct ufs_hba *hba) 860 1074 { 861 1075 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1076 + struct ufs_host_params *host_params = &host->host_params; 862 1077 1078 + ufshcd_init_host_params(host_params); 1079 + 1080 + /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */ 1081 + host_params->hs_tx_gear = host_params->hs_rx_gear = ufs_qcom_get_hs_gear(hba); 1082 + } 1083 + 1084 + static void ufs_qcom_set_caps(struct ufs_hba *hba) 1085 + { 863 1086 hba->caps |= UFSHCD_CAP_CLK_GATING | UFSHCD_CAP_HIBERN8_WITH_CLK_GATING; 864 1087 hba->caps |= UFSHCD_CAP_CLK_SCALING | UFSHCD_CAP_WB_WITH_CLK_SCALING; 865 1088 hba->caps |= UFSHCD_CAP_AUTO_BKOPS_SUSPEND; 866 1089 hba->caps |= UFSHCD_CAP_WB_EN; 867 1090 hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE; 868 1091 hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND; 869 - 870 - if (host->hw_ver.major >= 0x2) { 871 - host->caps = UFS_QCOM_CAP_QUNIPRO | 872 - UFS_QCOM_CAP_RETAIN_SEC_CFG_AFTER_PWR_COLLAPSE; 873 - } 874 1092 } 875 1093 876 1094 /** ··· 1016 1188 { 1017 1189 int err; 1018 1190 struct device *dev = hba->dev; 1019 - struct platform_device *pdev = to_platform_device(dev); 1020 1191 struct ufs_qcom_host *host; 1021 - struct resource *res; 1022 1192 struct ufs_clk_info *clki; 1023 1193 1024 1194 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); 1025 - if (!host) { 1026 - dev_err(dev, "%s: no memory for qcom ufs host\n", __func__); 1195 + if (!host) 1027 1196 return -ENOMEM; 1028 - } 1029 1197 1030 1198 /* Make a two way bind between the qcom host and the hba */ 1031 1199 host->hba = hba; ··· 1059 1235 host->device_reset = devm_gpiod_get_optional(dev, "reset", 1060 1236 GPIOD_OUT_HIGH); 1061 1237 if (IS_ERR(host->device_reset)) { 1062 - err = PTR_ERR(host->device_reset); 1063 - if (err != -EPROBE_DEFER) 1064 - dev_err(dev, "failed to acquire reset gpio: %d\n", err); 1238 + err = dev_err_probe(dev, PTR_ERR(host->device_reset), 1239 + "Failed to acquire device reset gpio\n"); 1065 1240 goto out_variant_clear; 1066 1241 } 1067 1242 1068 1243 ufs_qcom_get_controller_revision(hba, &host->hw_ver.major, 1069 1244 &host->hw_ver.minor, &host->hw_ver.step); 1070 1245 1071 - /* 1072 - * for newer controllers, device reference clock control bit has 1073 - * moved inside UFS controller register address space itself. 1074 - */ 1075 - if (host->hw_ver.major >= 0x02) { 1076 - host->dev_ref_clk_ctrl_mmio = hba->mmio_base + REG_UFS_CFG1; 1077 - host->dev_ref_clk_en_mask = BIT(26); 1078 - } else { 1079 - /* "dev_ref_clk_ctrl_mem" is optional resource */ 1080 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 1081 - "dev_ref_clk_ctrl_mem"); 1082 - if (res) { 1083 - host->dev_ref_clk_ctrl_mmio = 1084 - devm_ioremap_resource(dev, res); 1085 - if (IS_ERR(host->dev_ref_clk_ctrl_mmio)) 1086 - host->dev_ref_clk_ctrl_mmio = NULL; 1087 - host->dev_ref_clk_en_mask = BIT(5); 1088 - } 1089 - } 1246 + host->dev_ref_clk_ctrl_mmio = hba->mmio_base + REG_UFS_CFG1; 1247 + host->dev_ref_clk_en_mask = BIT(26); 1090 1248 1091 1249 list_for_each_entry(clki, &hba->clk_list_head, list) { 1092 1250 if (!strcmp(clki->name, "core_clk_unipro")) ··· 1081 1275 1082 1276 ufs_qcom_set_caps(hba); 1083 1277 ufs_qcom_advertise_quirks(hba); 1278 + ufs_qcom_set_host_params(hba); 1279 + ufs_qcom_set_phy_gear(host); 1084 1280 1085 1281 err = ufs_qcom_ice_init(host); 1086 1282 if (err) ··· 1090 1282 1091 1283 ufs_qcom_setup_clocks(hba, true, POST_CHANGE); 1092 1284 1093 - if (hba->dev->id < MAX_UFS_QCOM_HOSTS) 1094 - ufs_qcom_hosts[hba->dev->id] = host; 1095 - 1096 1285 ufs_qcom_get_default_testbus_cfg(host); 1097 1286 err = ufs_qcom_testbus_config(host); 1098 1287 if (err) 1099 1288 /* Failure is non-fatal */ 1100 1289 dev_warn(dev, "%s: failed to configure the testbus %d\n", 1101 1290 __func__, err); 1102 - 1103 - /* 1104 - * Power up the PHY using the minimum supported gear (UFS_HS_G2). 1105 - * Switching to max gear will be performed during reinit if supported. 1106 - */ 1107 - host->phy_gear = UFS_HS_G2; 1108 1291 1109 1292 return 0; 1110 1293 ··· 1190 1391 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1191 1392 struct list_head *head = &hba->clk_list_head; 1192 1393 struct ufs_clk_info *clki; 1193 - u32 cycles_in_1us; 1394 + u32 cycles_in_1us = 0; 1194 1395 u32 core_clk_ctrl_reg; 1195 1396 int err; 1196 1397 ··· 1243 1444 struct ufs_pa_layer_attr *attr = &host->dev_req_params; 1244 1445 int ret; 1245 1446 1246 - if (!ufs_qcom_cap_qunipro(host)) 1247 - return 0; 1248 - 1249 1447 ret = ufs_qcom_cfg_timers(hba, attr->gear_rx, attr->pwr_rx, 1250 1448 attr->hs_rate, false, true); 1251 1449 if (ret) { ··· 1260 1464 1261 1465 static int ufs_qcom_clk_scale_down_pre_change(struct ufs_hba *hba) 1262 1466 { 1263 - struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1264 1467 int err; 1265 1468 u32 core_clk_ctrl_reg; 1266 - 1267 - if (!ufs_qcom_cap_qunipro(host)) 1268 - return 0; 1269 1469 1270 1470 err = ufshcd_dme_get(hba, 1271 1471 UIC_ARG_MIB(DME_VS_CORE_CLK_CTRL), ··· 1281 1489 1282 1490 static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba) 1283 1491 { 1284 - struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1285 - 1286 - if (!ufs_qcom_cap_qunipro(host)) 1287 - return 0; 1288 - 1289 1492 /* set unipro core clock attributes and clear clock divider */ 1290 1493 return ufs_qcom_set_core_clk_ctrl(hba, false); 1291 1494 } ··· 1289 1502 bool scale_up, enum ufs_notify_change_status status) 1290 1503 { 1291 1504 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1292 - int err = 0; 1505 + int err; 1293 1506 1294 1507 /* check the host controller state before sending hibern8 cmd */ 1295 1508 if (!ufshcd_is_hba_active(hba)) ··· 1562 1775 struct platform_device *pdev = to_platform_device(hba->dev); 1563 1776 struct ufshcd_res_info *res; 1564 1777 struct resource *res_mem, *res_mcq; 1565 - int i, ret = 0; 1778 + int i, ret; 1566 1779 1567 1780 memcpy(hba->res, ufs_res_info, sizeof(ufs_res_info)); 1568 1781 ··· 1574 1787 if (!res->resource) { 1575 1788 dev_info(hba->dev, "Resource %s not provided\n", res->name); 1576 1789 if (i == RES_UFS) 1577 - return -ENOMEM; 1790 + return -ENODEV; 1578 1791 continue; 1579 1792 } else if (i == RES_UFS) { 1580 1793 res_mem = res->resource; ··· 1745 1958 platform_msi_domain_free_irqs(hba->dev); 1746 1959 } else { 1747 1960 if (host->hw_ver.major == 6 && host->hw_ver.minor == 0 && 1748 - host->hw_ver.step == 0) { 1749 - ufshcd_writel(hba, 1750 - ufshcd_readl(hba, REG_UFS_CFG3) | 0x1F000, 1751 - REG_UFS_CFG3); 1752 - } 1961 + host->hw_ver.step == 0) 1962 + ufshcd_rmwl(hba, ESI_VEC_MASK, 1963 + FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1), 1964 + REG_UFS_CFG3); 1753 1965 ufshcd_mcq_enable_esi(hba); 1754 1966 } 1755 1967
+12 -45
drivers/ufs/host/ufs-qcom.h
··· 10 10 #include <soc/qcom/ice.h> 11 11 #include <ufs/ufshcd.h> 12 12 13 - #define MAX_UFS_QCOM_HOSTS 1 14 - #define MAX_U32 (~(u32)0) 15 13 #define MPHY_TX_FSM_STATE 0x41 16 14 #define TX_FSM_HIBERN8 0x1 17 15 #define HBRN8_POLL_TOUT_MS 100 18 16 #define DEFAULT_CLK_RATE_HZ 1000000 19 - #define BUS_VECTOR_NAME_LEN 32 20 17 #define MAX_SUPP_MAC 64 18 + #define MAX_ESI_VEC 32 21 19 22 20 #define UFS_HW_VER_MAJOR_MASK GENMASK(31, 28) 23 21 #define UFS_HW_VER_MINOR_MASK GENMASK(27, 16) 24 22 #define UFS_HW_VER_STEP_MASK GENMASK(15, 0) 25 - 26 - /* vendor specific pre-defined parameters */ 27 - #define SLOW 1 28 - #define FAST 2 23 + #define UFS_DEV_VER_MAJOR_MASK GENMASK(7, 4) 29 24 30 25 #define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B 31 26 ··· 51 56 UFS_AH8_CFG = 0xFC, 52 57 53 58 REG_UFS_CFG3 = 0x271C, 59 + 60 + REG_UFS_DEBUG_SPARE_CFG = 0x284C, 54 61 }; 55 62 56 63 /* QCOM UFS host controller vendor specific debug registers */ ··· 90 93 #define TEST_BUS_SEL GENMASK(22, 19) 91 94 #define UFS_REG_TEST_BUS_EN BIT(30) 92 95 93 - #define UFS_PHY_RESET_ENABLE 1 94 - #define UFS_PHY_RESET_DISABLE 0 95 - 96 96 /* bit definitions for REG_UFS_CFG2 register */ 97 97 #define UAWM_HW_CGC_EN BIT(0) 98 98 #define UARM_HW_CGC_EN BIT(1) ··· 99 105 #define TRLUT_HW_CGC_EN BIT(5) 100 106 #define TMRLUT_HW_CGC_EN BIT(6) 101 107 #define OCSC_HW_CGC_EN BIT(7) 108 + 109 + /* bit definitions for REG_UFS_CFG3 register */ 110 + #define ESI_VEC_MASK GENMASK(22, 12) 102 111 103 112 /* bit definitions for REG_UFS_PARAM0 */ 104 113 #define MAX_HS_GEAR_MASK GENMASK(6, 4) ··· 114 117 TXUC_HW_CGC_EN | RXUC_HW_CGC_EN |\ 115 118 DFC_HW_CGC_EN | TRLUT_HW_CGC_EN |\ 116 119 TMRLUT_HW_CGC_EN | OCSC_HW_CGC_EN) 117 - 118 - /* bit offset */ 119 - #define OFFSET_CLK_NS_REG 0xa 120 - 121 - /* bit masks */ 122 - #define MASK_TX_SYMBOL_CLK_1US_REG GENMASK(9, 0) 123 - #define MASK_CLK_NS_REG GENMASK(23, 10) 124 120 125 121 /* QUniPro Vendor specific attributes */ 126 122 #define PA_VS_CONFIG_REG1 0x9000 ··· 148 158 149 159 static inline void ufs_qcom_assert_reset(struct ufs_hba *hba) 150 160 { 151 - ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, FIELD_PREP(UFS_PHY_SOFT_RESET, UFS_PHY_RESET_ENABLE), 152 - REG_UFS_CFG1); 161 + ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1); 153 162 154 163 /* 155 164 * Make sure assertion of ufs phy reset is written to ··· 159 170 160 171 static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) 161 172 { 162 - ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, FIELD_PREP(UFS_PHY_SOFT_RESET, UFS_PHY_RESET_DISABLE), 163 - REG_UFS_CFG1); 173 + ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, 0, REG_UFS_CFG1); 164 174 165 175 /* 166 176 * Make sure de-assertion of ufs phy reset is written to ··· 183 195 struct gpio_desc; 184 196 185 197 struct ufs_qcom_host { 186 - /* 187 - * Set this capability if host controller supports the QUniPro mode 188 - * and if driver wants the Host controller to operate in QUniPro mode. 189 - * Note: By default this capability will be kept enabled if host 190 - * controller supports the QUniPro mode. 191 - */ 192 - #define UFS_QCOM_CAP_QUNIPRO 0x1 193 - 194 - /* 195 - * Set this capability if host controller can retain the secure 196 - * configuration even after UFS controller core power collapse. 197 - */ 198 - #define UFS_QCOM_CAP_RETAIN_SEC_CFG_AFTER_PWR_COLLAPSE 0x2 199 - u32 caps; 200 - 201 198 struct phy *generic_phy; 202 199 struct ufs_hba *hba; 203 200 struct ufs_pa_layer_attr dev_req_params; 204 - struct clk *rx_l0_sync_clk; 205 - struct clk *tx_l0_sync_clk; 206 - struct clk *rx_l1_sync_clk; 207 - struct clk *tx_l1_sync_clk; 201 + struct clk_bulk_data *clks; 202 + u32 num_clks; 208 203 bool is_lane_clks_enabled; 209 204 210 205 struct icc_path *icc_ddr; ··· 211 240 212 241 struct gpio_desc *device_reset; 213 242 243 + struct ufs_host_params host_params; 214 244 u32 phy_gear; 215 245 216 246 bool esi_enabled; ··· 232 260 #define ceil(freq, div) ((freq) % (div) == 0 ? ((freq)/(div)) : ((freq)/(div) + 1)) 233 261 234 262 int ufs_qcom_testbus_config(struct ufs_qcom_host *host); 235 - 236 - static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host) 237 - { 238 - return host->caps & UFS_QCOM_CAP_QUNIPRO; 239 - } 240 263 241 264 #endif /* UFS_QCOM_H_ */
+34 -35
drivers/ufs/host/ufshcd-pltfrm.c
··· 339 339 } 340 340 341 341 /** 342 - * ufshcd_get_pwr_dev_param - get finally agreed attributes for 343 - * power mode change 344 - * @pltfrm_param: pointer to platform parameters 342 + * ufshcd_negotiate_pwr_params - find power mode settings that are supported by 343 + * both the controller and the device 344 + * @host_params: pointer to host parameters 345 345 * @dev_max: pointer to device attributes 346 346 * @agreed_pwr: returned agreed attributes 347 347 * 348 348 * Return: 0 on success, non-zero value on failure. 349 349 */ 350 - int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param, 351 - const struct ufs_pa_layer_attr *dev_max, 352 - struct ufs_pa_layer_attr *agreed_pwr) 350 + int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params, 351 + const struct ufs_pa_layer_attr *dev_max, 352 + struct ufs_pa_layer_attr *agreed_pwr) 353 353 { 354 - int min_pltfrm_gear; 354 + int min_host_gear; 355 355 int min_dev_gear; 356 356 bool is_dev_sup_hs = false; 357 - bool is_pltfrm_max_hs = false; 357 + bool is_host_max_hs = false; 358 358 359 359 if (dev_max->pwr_rx == FAST_MODE) 360 360 is_dev_sup_hs = true; 361 361 362 - if (pltfrm_param->desired_working_mode == UFS_HS_MODE) { 363 - is_pltfrm_max_hs = true; 364 - min_pltfrm_gear = min_t(u32, pltfrm_param->hs_rx_gear, 365 - pltfrm_param->hs_tx_gear); 362 + if (host_params->desired_working_mode == UFS_HS_MODE) { 363 + is_host_max_hs = true; 364 + min_host_gear = min_t(u32, host_params->hs_rx_gear, 365 + host_params->hs_tx_gear); 366 366 } else { 367 - min_pltfrm_gear = min_t(u32, pltfrm_param->pwm_rx_gear, 368 - pltfrm_param->pwm_tx_gear); 367 + min_host_gear = min_t(u32, host_params->pwm_rx_gear, 368 + host_params->pwm_tx_gear); 369 369 } 370 370 371 371 /* 372 - * device doesn't support HS but 373 - * pltfrm_param->desired_working_mode is HS, 374 - * thus device and pltfrm_param don't agree 372 + * device doesn't support HS but host_params->desired_working_mode is HS, 373 + * thus device and host_params don't agree 375 374 */ 376 - if (!is_dev_sup_hs && is_pltfrm_max_hs) { 375 + if (!is_dev_sup_hs && is_host_max_hs) { 377 376 pr_info("%s: device doesn't support HS\n", 378 377 __func__); 379 378 return -ENOTSUPP; 380 - } else if (is_dev_sup_hs && is_pltfrm_max_hs) { 379 + } else if (is_dev_sup_hs && is_host_max_hs) { 381 380 /* 382 381 * since device supports HS, it supports FAST_MODE. 383 - * since pltfrm_param->desired_working_mode is also HS 382 + * since host_params->desired_working_mode is also HS 384 383 * then final decision (FAST/FASTAUTO) is done according 385 384 * to pltfrm_params as it is the restricting factor 386 385 */ 387 - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_hs; 386 + agreed_pwr->pwr_rx = host_params->rx_pwr_hs; 388 387 agreed_pwr->pwr_tx = agreed_pwr->pwr_rx; 389 388 } else { 390 389 /* 391 - * here pltfrm_param->desired_working_mode is PWM. 390 + * here host_params->desired_working_mode is PWM. 392 391 * it doesn't matter whether device supports HS or PWM, 393 - * in both cases pltfrm_param->desired_working_mode will 392 + * in both cases host_params->desired_working_mode will 394 393 * determine the mode 395 394 */ 396 - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_pwm; 395 + agreed_pwr->pwr_rx = host_params->rx_pwr_pwm; 397 396 agreed_pwr->pwr_tx = agreed_pwr->pwr_rx; 398 397 } 399 398 ··· 402 403 * the same decision will be made for rx 403 404 */ 404 405 agreed_pwr->lane_tx = min_t(u32, dev_max->lane_tx, 405 - pltfrm_param->tx_lanes); 406 + host_params->tx_lanes); 406 407 agreed_pwr->lane_rx = min_t(u32, dev_max->lane_rx, 407 - pltfrm_param->rx_lanes); 408 + host_params->rx_lanes); 408 409 409 410 /* device maximum gear is the minimum between device rx and tx gears */ 410 411 min_dev_gear = min_t(u32, dev_max->gear_rx, dev_max->gear_tx); ··· 417 418 * what is the gear, as it is the one that also decided previously what 418 419 * pwr the device will be configured to. 419 420 */ 420 - if ((is_dev_sup_hs && is_pltfrm_max_hs) || 421 - (!is_dev_sup_hs && !is_pltfrm_max_hs)) { 421 + if ((is_dev_sup_hs && is_host_max_hs) || 422 + (!is_dev_sup_hs && !is_host_max_hs)) { 422 423 agreed_pwr->gear_rx = 423 - min_t(u32, min_dev_gear, min_pltfrm_gear); 424 + min_t(u32, min_dev_gear, min_host_gear); 424 425 } else if (!is_dev_sup_hs) { 425 426 agreed_pwr->gear_rx = min_dev_gear; 426 427 } else { 427 - agreed_pwr->gear_rx = min_pltfrm_gear; 428 + agreed_pwr->gear_rx = min_host_gear; 428 429 } 429 430 agreed_pwr->gear_tx = agreed_pwr->gear_rx; 430 431 431 - agreed_pwr->hs_rate = pltfrm_param->hs_rate; 432 + agreed_pwr->hs_rate = host_params->hs_rate; 432 433 433 434 return 0; 434 435 } 435 - EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param); 436 + EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_params); 436 437 437 - void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param) 438 + void ufshcd_init_host_params(struct ufs_host_params *host_params) 438 439 { 439 - *dev_param = (struct ufs_dev_params){ 440 + *host_params = (struct ufs_host_params){ 440 441 .tx_lanes = UFS_LANE_2, 441 442 .rx_lanes = UFS_LANE_2, 442 443 .hs_rx_gear = UFS_HS_G3, ··· 451 452 .desired_working_mode = UFS_HS_MODE, 452 453 }; 453 454 } 454 - EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param); 455 + EXPORT_SYMBOL_GPL(ufshcd_init_host_params); 455 456 456 457 /** 457 458 * ufshcd_pltfrm_init - probe routine of the driver
+5 -5
drivers/ufs/host/ufshcd-pltfrm.h
··· 10 10 #define UFS_PWM_MODE 1 11 11 #define UFS_HS_MODE 2 12 12 13 - struct ufs_dev_params { 13 + struct ufs_host_params { 14 14 u32 pwm_rx_gear; /* pwm rx gear to work in */ 15 15 u32 pwm_tx_gear; /* pwm tx gear to work in */ 16 16 u32 hs_rx_gear; /* hs rx gear to work in */ ··· 25 25 u32 desired_working_mode; 26 26 }; 27 27 28 - int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *dev_param, 29 - const struct ufs_pa_layer_attr *dev_max, 30 - struct ufs_pa_layer_attr *agreed_pwr); 31 - void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param); 28 + int ufshcd_negotiate_pwr_params(const struct ufs_host_params *host_params, 29 + const struct ufs_pa_layer_attr *dev_max, 30 + struct ufs_pa_layer_attr *agreed_pwr); 31 + void ufshcd_init_host_params(struct ufs_host_params *host_params); 32 32 int ufshcd_pltfrm_init(struct platform_device *pdev, 33 33 const struct ufs_hba_variant_ops *vops); 34 34 int ufshcd_populate_vreg(struct device *dev, const char *name,
+2
include/uapi/scsi/scsi_bsg_mpi3mr.h
··· 491 491 #define MPI3MR_NVME_DATA_FORMAT_PRP 0 492 492 #define MPI3MR_NVME_DATA_FORMAT_SGL1 1 493 493 #define MPI3MR_NVME_DATA_FORMAT_SGL2 2 494 + #define MPI3MR_NVMESGL_DATA_SEGMENT 0x00 495 + #define MPI3MR_NVMESGL_LAST_SEGMENT 0x03 494 496 495 497 /* MPI3: task management related definitions */ 496 498 struct mpi3_scsi_task_mgmt_request {
+14
include/ufs/ufs.h
··· 14 14 #include <linux/bitops.h> 15 15 #include <linux/types.h> 16 16 #include <uapi/scsi/scsi_bsg_ufs.h> 17 + #include <linux/time64.h> 17 18 18 19 /* 19 20 * Using static_assert() is not allowed in UAPI header files. Hence the check ··· 552 551 struct ufs_vreg *vdd_hba; 553 552 }; 554 553 554 + /* UFS device descriptor wPeriodicRTCUpdate bit9 defines RTC time baseline */ 555 + #define UFS_RTC_TIME_BASELINE BIT(9) 556 + 557 + enum ufs_rtc_time { 558 + UFS_RTC_RELATIVE, 559 + UFS_RTC_ABSOLUTE 560 + }; 561 + 555 562 struct ufs_dev_info { 556 563 bool f_power_on_wp_en; 557 564 /* Keeps information if any of the LU is power on write protected */ ··· 587 578 588 579 /* UFS EXT_IID Enable */ 589 580 bool b_ext_iid_en; 581 + 582 + /* UFS RTC */ 583 + enum ufs_rtc_time rtc_type; 584 + time64_t rtc_time_baseline; 585 + u32 rtc_update_period; 590 586 }; 591 587 592 588 /*
+11 -1
include/ufs/ufshcd.h
··· 16 16 #include <linux/blk-crypto-profile.h> 17 17 #include <linux/blk-mq.h> 18 18 #include <linux/devfreq.h> 19 + #include <linux/fault-inject.h> 19 20 #include <linux/msi.h> 20 21 #include <linux/pm_runtime.h> 21 22 #include <linux/dma-direction.h> ··· 912 911 * @mcq_base: Multi circular queue registers base address 913 912 * @uhq: array of supported hardware queues 914 913 * @dev_cmd_queue: Queue for issuing device management commands 914 + * @mcq_opr: MCQ operation and runtime registers 915 + * @ufs_rtc_update_work: A work for UFS RTC periodic update 915 916 */ 916 917 struct ufs_hba { 917 918 void __iomem *mmio_base; ··· 1061 1058 struct delayed_work debugfs_ee_work; 1062 1059 u32 debugfs_ee_rate_limit_ms; 1063 1060 #endif 1061 + #ifdef CONFIG_SCSI_UFS_FAULT_INJECTION 1062 + struct fault_attr trigger_eh_attr; 1063 + struct fault_attr timeout_attr; 1064 + #endif 1064 1065 u32 luns_avail; 1065 1066 unsigned int nr_hw_queues; 1066 1067 unsigned int nr_queues[HCTX_MAX_TYPES]; ··· 1078 1071 struct ufs_hw_queue *uhq; 1079 1072 struct ufs_hw_queue *dev_cmd_queue; 1080 1073 struct ufshcd_mcq_opr_info_t mcq_opr[OPR_MAX]; 1074 + 1075 + struct delayed_work ufs_rtc_update_work; 1081 1076 }; 1082 1077 1083 1078 /** ··· 1240 1231 ufshcd_writel(hba, tmp, reg); 1241 1232 } 1242 1233 1234 + void ufshcd_enable_irq(struct ufs_hba *hba); 1235 + void ufshcd_disable_irq(struct ufs_hba *hba); 1243 1236 int ufshcd_alloc_host(struct device *, struct ufs_hba **); 1244 1237 void ufshcd_dealloc_host(struct ufs_hba *); 1245 1238 int ufshcd_hba_enable(struct ufs_hba *hba); ··· 1371 1360 return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0); 1372 1361 } 1373 1362 1374 - void ufshcd_auto_hibern8_enable(struct ufs_hba *hba); 1375 1363 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); 1376 1364 void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, 1377 1365 const struct ufs_dev_quirk *fixups);
+2 -2
include/ufs/unipro.h
··· 193 193 #define DME_LocalAFC0ReqTimeOutVal 0xD043 194 194 195 195 /* PA power modes */ 196 - enum { 196 + enum ufs_pa_pwr_mode { 197 197 FAST_MODE = 1, 198 198 SLOW_MODE = 2, 199 199 FASTAUTO_MODE = 4, ··· 205 205 #define PWRMODE_RX_OFFSET 4 206 206 207 207 /* PA TX/RX Frequency Series */ 208 - enum { 208 + enum ufs_hs_gear_rate { 209 209 PA_HS_MODE_A = 1, 210 210 PA_HS_MODE_B = 2, 211 211 };