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

Pull SCSI fixes from James Bottomley:
"This is a set of ten fixes: 8 for UFS including four static checker
warnings, a potential null deref in the voltage regulator code, a race
on module unload, a ref counting fix on the well known LUNs which made
it impossible to remove the ufs module and fix to correct the
information in pwr_info.

In addition to UFS, there's a blacklist for the Intel Multi-Flex array
which chokes on report supported operation codes and a fix to an oops
in bnx2fc caused by shared skbs"

[ For us non-SCSI people: "UFS" here is "Universal Flash Storage" not
the filesystem. - Linus ]

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
ufs: fix NULL dereference when no regulators are defined
ufs: ensure clk gating work is finished before module unloading
scsi: ufs: fix static checker warning in ufshcd_parse_clock_info
scsi: ufs: fix static checker warning in __ufshcd_setup_clocks
scsi: ufs: fix static checker warning in ufshcd_populate_vreg
scsi: ufs: fix static checker errors in ufshcd_system_suspend
ufs: fix power info after link start-up
ufs: fix reference counting of W-LUs
scsi: add Intel Multi-Flex to scsi scan blacklist
bnx2fc: do not add shared skbs to the fcoe_rx_list

Changed files
+77 -52
drivers
+7
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 412 412 struct fc_frame_header *fh; 413 413 struct fcoe_rcv_info *fr; 414 414 struct fcoe_percpu_s *bg; 415 + struct sk_buff *tmp_skb; 415 416 unsigned short oxid; 416 417 417 418 interface = container_of(ptype, struct bnx2fc_interface, ··· 424 423 printk(KERN_ERR PFX "bnx2fc_rcv: lport is NULL\n"); 425 424 goto err; 426 425 } 426 + 427 + tmp_skb = skb_share_check(skb, GFP_ATOMIC); 428 + if (!tmp_skb) 429 + goto err; 430 + 431 + skb = tmp_skb; 427 432 428 433 if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { 429 434 printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");
+1
drivers/scsi/scsi_devinfo.c
··· 202 202 {"IOMEGA", "Io20S *F", NULL, BLIST_KEY}, 203 203 {"INSITE", "Floptical F*8I", NULL, BLIST_KEY}, 204 204 {"INSITE", "I325VM", NULL, BLIST_KEY}, 205 + {"Intel", "Multi-Flex", NULL, BLIST_NO_RSOC}, 205 206 {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36}, 206 207 {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN}, 207 208 {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
+5 -10
drivers/scsi/ufs/ufshcd-pltfrm.c
··· 102 102 clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq), 103 103 GFP_KERNEL); 104 104 if (!clkfreq) { 105 - dev_err(dev, "%s: no memory\n", "freq-table-hz"); 106 105 ret = -ENOMEM; 107 106 goto out; 108 107 } ··· 111 112 if (ret && (ret != -EINVAL)) { 112 113 dev_err(dev, "%s: error reading array %d\n", 113 114 "freq-table-hz", ret); 114 - goto free_clkfreq; 115 + return ret; 115 116 } 116 117 117 118 for (i = 0; i < sz; i += 2) { 118 119 ret = of_property_read_string_index(np, 119 120 "clock-names", i/2, (const char **)&name); 120 121 if (ret) 121 - goto free_clkfreq; 122 + goto out; 122 123 123 124 clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL); 124 125 if (!clki) { 125 126 ret = -ENOMEM; 126 - goto free_clkfreq; 127 + goto out; 127 128 } 128 129 129 130 clki->min_freq = clkfreq[i]; ··· 133 134 clki->min_freq, clki->max_freq, clki->name); 134 135 list_add_tail(&clki->list, &hba->clk_list_head); 135 136 } 136 - free_clkfreq: 137 - kfree(clkfreq); 138 137 out: 139 138 return ret; 140 139 } ··· 159 162 } 160 163 161 164 vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); 162 - if (!vreg) { 163 - dev_err(dev, "No memory for %s regulator\n", name); 164 - goto out; 165 - } 165 + if (!vreg) 166 + return -ENOMEM; 166 167 167 168 vreg->name = kstrdup(name, GFP_KERNEL); 168 169
+64 -40
drivers/scsi/ufs/ufshcd.c
··· 744 744 if (!ufshcd_is_clkgating_allowed(hba)) 745 745 return; 746 746 device_remove_file(hba->dev, &hba->clk_gating.delay_attr); 747 + cancel_work_sync(&hba->clk_gating.ungate_work); 748 + cancel_delayed_work_sync(&hba->clk_gating.gate_work); 747 749 } 748 750 749 751 /* Must be called with host lock acquired */ ··· 2248 2246 return ret; 2249 2247 } 2250 2248 2249 + /** 2250 + * ufshcd_init_pwr_info - setting the POR (power on reset) 2251 + * values in hba power info 2252 + * @hba: per-adapter instance 2253 + */ 2254 + static void ufshcd_init_pwr_info(struct ufs_hba *hba) 2255 + { 2256 + hba->pwr_info.gear_rx = UFS_PWM_G1; 2257 + hba->pwr_info.gear_tx = UFS_PWM_G1; 2258 + hba->pwr_info.lane_rx = 1; 2259 + hba->pwr_info.lane_tx = 1; 2260 + hba->pwr_info.pwr_rx = SLOWAUTO_MODE; 2261 + hba->pwr_info.pwr_tx = SLOWAUTO_MODE; 2262 + hba->pwr_info.hs_rate = 0; 2263 + } 2264 + 2251 2265 /** 2252 2266 * ufshcd_get_max_pwr_mode - reads the max power mode negotiated with device 2253 2267 * @hba: per-adapter instance ··· 2862 2844 hba = shost_priv(sdev->host); 2863 2845 scsi_deactivate_tcq(sdev, hba->nutrs); 2864 2846 /* Drop the reference as it won't be needed anymore */ 2865 - if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) 2847 + if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) { 2848 + unsigned long flags; 2849 + 2850 + spin_lock_irqsave(hba->host->host_lock, flags); 2866 2851 hba->sdev_ufs_device = NULL; 2852 + spin_unlock_irqrestore(hba->host->host_lock, flags); 2853 + } 2867 2854 } 2868 2855 2869 2856 /** ··· 4085 4062 static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) 4086 4063 { 4087 4064 int ret = 0; 4065 + struct scsi_device *sdev_rpmb; 4066 + struct scsi_device *sdev_boot; 4088 4067 4089 4068 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0, 4090 4069 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL); ··· 4095 4070 hba->sdev_ufs_device = NULL; 4096 4071 goto out; 4097 4072 } 4073 + scsi_device_put(hba->sdev_ufs_device); 4098 4074 4099 - hba->sdev_boot = __scsi_add_device(hba->host, 0, 0, 4075 + sdev_boot = __scsi_add_device(hba->host, 0, 0, 4100 4076 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL); 4101 - if (IS_ERR(hba->sdev_boot)) { 4102 - ret = PTR_ERR(hba->sdev_boot); 4103 - hba->sdev_boot = NULL; 4077 + if (IS_ERR(sdev_boot)) { 4078 + ret = PTR_ERR(sdev_boot); 4104 4079 goto remove_sdev_ufs_device; 4105 4080 } 4081 + scsi_device_put(sdev_boot); 4106 4082 4107 - hba->sdev_rpmb = __scsi_add_device(hba->host, 0, 0, 4083 + sdev_rpmb = __scsi_add_device(hba->host, 0, 0, 4108 4084 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL); 4109 - if (IS_ERR(hba->sdev_rpmb)) { 4110 - ret = PTR_ERR(hba->sdev_rpmb); 4111 - hba->sdev_rpmb = NULL; 4085 + if (IS_ERR(sdev_rpmb)) { 4086 + ret = PTR_ERR(sdev_rpmb); 4112 4087 goto remove_sdev_boot; 4113 4088 } 4089 + scsi_device_put(sdev_rpmb); 4114 4090 goto out; 4115 4091 4116 4092 remove_sdev_boot: 4117 - scsi_remove_device(hba->sdev_boot); 4093 + scsi_remove_device(sdev_boot); 4118 4094 remove_sdev_ufs_device: 4119 4095 scsi_remove_device(hba->sdev_ufs_device); 4120 4096 out: 4121 4097 return ret; 4122 - } 4123 - 4124 - /** 4125 - * ufshcd_scsi_remove_wlus - Removes the W-LUs which were added by 4126 - * ufshcd_scsi_add_wlus() 4127 - * @hba: per-adapter instance 4128 - * 4129 - */ 4130 - static void ufshcd_scsi_remove_wlus(struct ufs_hba *hba) 4131 - { 4132 - if (hba->sdev_ufs_device) { 4133 - scsi_remove_device(hba->sdev_ufs_device); 4134 - hba->sdev_ufs_device = NULL; 4135 - } 4136 - 4137 - if (hba->sdev_boot) { 4138 - scsi_remove_device(hba->sdev_boot); 4139 - hba->sdev_boot = NULL; 4140 - } 4141 - 4142 - if (hba->sdev_rpmb) { 4143 - scsi_remove_device(hba->sdev_rpmb); 4144 - hba->sdev_rpmb = NULL; 4145 - } 4146 4098 } 4147 4099 4148 4100 /** ··· 4135 4133 ret = ufshcd_link_startup(hba); 4136 4134 if (ret) 4137 4135 goto out; 4136 + 4137 + ufshcd_init_pwr_info(hba); 4138 4138 4139 4139 /* UniPro link is active now */ 4140 4140 ufshcd_set_link_active(hba); ··· 4268 4264 static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, 4269 4265 struct ufs_vreg *vreg) 4270 4266 { 4267 + if (!vreg) 4268 + return 0; 4269 + 4271 4270 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA); 4272 4271 } 4273 4272 4274 4273 static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, 4275 4274 struct ufs_vreg *vreg) 4276 4275 { 4276 + if (!vreg) 4277 + return 0; 4278 + 4277 4279 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA); 4278 4280 } 4279 4281 ··· 4481 4471 if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled) 4482 4472 clk_disable_unprepare(clki->clk); 4483 4473 } 4484 - } else if (!ret && on) { 4474 + } else if (on) { 4485 4475 spin_lock_irqsave(hba->host->host_lock, flags); 4486 4476 hba->clk_gating.state = CLKS_ON; 4487 4477 spin_unlock_irqrestore(hba->host->host_lock, flags); ··· 4685 4675 { 4686 4676 unsigned char cmd[6] = { START_STOP }; 4687 4677 struct scsi_sense_hdr sshdr; 4688 - struct scsi_device *sdp = hba->sdev_ufs_device; 4678 + struct scsi_device *sdp; 4679 + unsigned long flags; 4689 4680 int ret; 4690 4681 4691 - if (!sdp || !scsi_device_online(sdp)) 4692 - return -ENODEV; 4682 + spin_lock_irqsave(hba->host->host_lock, flags); 4683 + sdp = hba->sdev_ufs_device; 4684 + if (sdp) { 4685 + ret = scsi_device_get(sdp); 4686 + if (!ret && !scsi_device_online(sdp)) { 4687 + ret = -ENODEV; 4688 + scsi_device_put(sdp); 4689 + } 4690 + } else { 4691 + ret = -ENODEV; 4692 + } 4693 + spin_unlock_irqrestore(hba->host->host_lock, flags); 4694 + 4695 + if (ret) 4696 + return ret; 4693 4697 4694 4698 /* 4695 4699 * If scsi commands fail, the scsi mid-layer schedules scsi error- ··· 4742 4718 if (!ret) 4743 4719 hba->curr_dev_pwr_mode = pwr_mode; 4744 4720 out: 4721 + scsi_device_put(sdp); 4745 4722 hba->host->eh_noresume = 0; 4746 4723 return ret; 4747 4724 } ··· 5112 5087 int ret = 0; 5113 5088 5114 5089 if (!hba || !hba->is_powered) 5115 - goto out; 5090 + return 0; 5116 5091 5117 5092 if (pm_runtime_suspended(hba->dev)) { 5118 5093 if (hba->rpm_lvl == hba->spm_lvl) ··· 5256 5231 void ufshcd_remove(struct ufs_hba *hba) 5257 5232 { 5258 5233 scsi_remove_host(hba->host); 5259 - ufshcd_scsi_remove_wlus(hba); 5260 5234 /* disable interrupts */ 5261 5235 ufshcd_disable_intr(hba, hba->intr_mask); 5262 5236 ufshcd_hba_stop(hba);
-2
drivers/scsi/ufs/ufshcd.h
··· 392 392 * "UFS device" W-LU. 393 393 */ 394 394 struct scsi_device *sdev_ufs_device; 395 - struct scsi_device *sdev_rpmb; 396 - struct scsi_device *sdev_boot; 397 395 398 396 enum ufs_dev_pwr_mode curr_dev_pwr_mode; 399 397 enum uic_link_state uic_link_state;