CC: [email protected]
In-Reply-To: 
<d1a6af736730b9d79f977100286c5d9325546ac2.1618426513.git.asuto...@codeaurora.org>
References: 
<d1a6af736730b9d79f977100286c5d9325546ac2.1618426513.git.asuto...@codeaurora.org>
TO: Asutosh Das <[email protected]>
TO: [email protected]
TO: [email protected]
TO: [email protected]
TO: [email protected]
CC: Asutosh Das <[email protected]>
CC: [email protected]
CC: Alim Akhtar <[email protected]>
CC: Avri Altman <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: Pedro Sousa <[email protected]>

Hi Asutosh,

I love your patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next next-20210415]
[cannot apply to tip/perf/core v5.12-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/0day-ci/linux/commits/Asutosh-Das/Enable-power-management-for-ufs-wlun/20210415-030146
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
:::::: branch date: 19 hours ago
:::::: commit date: 19 hours ago
config: i386-randconfig-m021-20210415 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

New smatch warnings:
drivers/scsi/ufs/ufshcd.c:9017 ufshcd_wl_resume() error: potentially 
dereferencing uninitialized 'hba'.
drivers/scsi/ufs/ufshcd.c:9141 ufshcd_system_suspend() error: uninitialized 
symbol 'ret'.
drivers/scsi/ufs/ufshcd.c:9166 ufshcd_system_resume() error: uninitialized 
symbol 'ret'.

Old smatch warnings:
drivers/scsi/ufs/ufshcd.c:5112 ufshcd_uic_cmd_compl() error: we previously 
assumed 'hba->active_uic_cmd' could be null (see line 5100)

vim +/hba +9017 drivers/scsi/ufs/ufshcd.c

9bad6c1c707d2a Asutosh Das        2021-04-14  8998  
9bad6c1c707d2a Asutosh Das        2021-04-14  8999  static int 
ufshcd_wl_resume(struct device *dev)
9bad6c1c707d2a Asutosh Das        2021-04-14  9000  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9001      struct scsi_device 
*sdev = to_scsi_device(dev);
9bad6c1c707d2a Asutosh Das        2021-04-14  9002      struct ufs_hba *hba;
9bad6c1c707d2a Asutosh Das        2021-04-14  9003      int ret = 0;
9bad6c1c707d2a Asutosh Das        2021-04-14  9004      ktime_t start = 
ktime_get();
9bad6c1c707d2a Asutosh Das        2021-04-14  9005  
9bad6c1c707d2a Asutosh Das        2021-04-14  9006      if 
(pm_runtime_suspended(dev))
9bad6c1c707d2a Asutosh Das        2021-04-14  9007              goto out;
9bad6c1c707d2a Asutosh Das        2021-04-14  9008  
9bad6c1c707d2a Asutosh Das        2021-04-14  9009      hba = 
shost_priv(sdev->host);
9bad6c1c707d2a Asutosh Das        2021-04-14  9010  
9bad6c1c707d2a Asutosh Das        2021-04-14  9011      ret = 
__ufshcd_wl_resume(hba, UFS_SYSTEM_PM);
9bad6c1c707d2a Asutosh Das        2021-04-14  9012      if (ret)
9bad6c1c707d2a Asutosh Das        2021-04-14  9013              
dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret);
9bad6c1c707d2a Asutosh Das        2021-04-14  9014  out:
9bad6c1c707d2a Asutosh Das        2021-04-14  9015      
trace_ufshcd_wl_resume(dev_name(dev), ret,
9bad6c1c707d2a Asutosh Das        2021-04-14  9016              
ktime_to_us(ktime_sub(ktime_get(), start)),
9bad6c1c707d2a Asutosh Das        2021-04-14 @9017              
hba->curr_dev_pwr_mode, hba->uic_link_state);
9bad6c1c707d2a Asutosh Das        2021-04-14  9018      if (!ret)
9bad6c1c707d2a Asutosh Das        2021-04-14  9019              
hba->is_sys_suspended = false;
9bad6c1c707d2a Asutosh Das        2021-04-14  9020      up(&hba->host_sem);
9bad6c1c707d2a Asutosh Das        2021-04-14  9021      return ret;
9bad6c1c707d2a Asutosh Das        2021-04-14  9022  }
9bad6c1c707d2a Asutosh Das        2021-04-14  9023  #endif
9bad6c1c707d2a Asutosh Das        2021-04-14  9024  
9bad6c1c707d2a Asutosh Das        2021-04-14  9025  static void 
ufshcd_wl_shutdown(struct device *dev)
9bad6c1c707d2a Asutosh Das        2021-04-14  9026  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9027      struct scsi_device 
*sdev = to_scsi_device(dev);
9bad6c1c707d2a Asutosh Das        2021-04-14  9028      struct ufs_hba *hba;
9bad6c1c707d2a Asutosh Das        2021-04-14  9029  
9bad6c1c707d2a Asutosh Das        2021-04-14  9030      hba = 
shost_priv(sdev->host);
9bad6c1c707d2a Asutosh Das        2021-04-14  9031  
9bad6c1c707d2a Asutosh Das        2021-04-14  9032      down(&hba->host_sem);
9bad6c1c707d2a Asutosh Das        2021-04-14  9033      hba->shutting_down = 
true;
9bad6c1c707d2a Asutosh Das        2021-04-14  9034      up(&hba->host_sem);
9bad6c1c707d2a Asutosh Das        2021-04-14  9035  
9bad6c1c707d2a Asutosh Das        2021-04-14  9036      /* Turn on everything 
while shutting down */
9bad6c1c707d2a Asutosh Das        2021-04-14  9037      
ufshcd_rpm_get_sync(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9038      
scsi_device_quiesce(sdev);
9bad6c1c707d2a Asutosh Das        2021-04-14  9039      
shost_for_each_device(sdev, hba->host) {
9bad6c1c707d2a Asutosh Das        2021-04-14  9040              if (sdev == 
hba->sdev_ufs_device)
9bad6c1c707d2a Asutosh Das        2021-04-14  9041                      
continue;
9bad6c1c707d2a Asutosh Das        2021-04-14  9042              
scsi_device_quiesce(sdev);
9bad6c1c707d2a Asutosh Das        2021-04-14  9043      }
9bad6c1c707d2a Asutosh Das        2021-04-14  9044      
__ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
9bad6c1c707d2a Asutosh Das        2021-04-14  9045  }
9bad6c1c707d2a Asutosh Das        2021-04-14  9046  
9bad6c1c707d2a Asutosh Das        2021-04-14  9047  /**
9bad6c1c707d2a Asutosh Das        2021-04-14  9048   * ufshcd_suspend - helper 
function for suspend operations
9bad6c1c707d2a Asutosh Das        2021-04-14  9049   * @hba: per adapter 
instance
9bad6c1c707d2a Asutosh Das        2021-04-14  9050   *
9bad6c1c707d2a Asutosh Das        2021-04-14  9051   * This function will put 
disable irqs, turn off clocks
9bad6c1c707d2a Asutosh Das        2021-04-14  9052   * and set vreg and 
hba-vreg in lpm mode.
9bad6c1c707d2a Asutosh Das        2021-04-14  9053   * Also check the 
description of __ufshcd_wl_suspend().
9bad6c1c707d2a Asutosh Das        2021-04-14  9054   */
9bad6c1c707d2a Asutosh Das        2021-04-14  9055  static int 
ufshcd_suspend(struct ufs_hba *hba)
9bad6c1c707d2a Asutosh Das        2021-04-14  9056  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9057      int ret;
9bad6c1c707d2a Asutosh Das        2021-04-14  9058  
9bad6c1c707d2a Asutosh Das        2021-04-14  9059      if (!hba->is_powered)
9bad6c1c707d2a Asutosh Das        2021-04-14  9060              return 0;
9bad6c1c707d2a Asutosh Das        2021-04-14  9061      /*
9bad6c1c707d2a Asutosh Das        2021-04-14  9062       * Disable the host irq 
as host controller as there won't be any
9bad6c1c707d2a Asutosh Das        2021-04-14  9063       * host controller 
transaction expected till resume.
9bad6c1c707d2a Asutosh Das        2021-04-14  9064       */
57d104c153d3d6 Subhash Jadavani   2014-09-25  9065      ufshcd_disable_irq(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9066      ret = 
ufshcd_setup_clocks(hba, false);
9bad6c1c707d2a Asutosh Das        2021-04-14  9067      if (ret) {
9bad6c1c707d2a Asutosh Das        2021-04-14  9068              
ufshcd_enable_irq(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9069              return ret;
9bad6c1c707d2a Asutosh Das        2021-04-14  9070      }
2dec9475a4028b Can Guo            2020-08-09  9071      if 
(ufshcd_is_clkgating_allowed(hba)) {
2dec9475a4028b Can Guo            2020-08-09  9072              
hba->clk_gating.state = CLKS_OFF;
2dec9475a4028b Can Guo            2020-08-09  9073              
trace_ufshcd_clk_gating(dev_name(hba->dev),
2dec9475a4028b Can Guo            2020-08-09  9074                              
        hba->clk_gating.state);
2dec9475a4028b Can Guo            2020-08-09  9075      }
9bad6c1c707d2a Asutosh Das        2021-04-14  9076  
9bad6c1c707d2a Asutosh Das        2021-04-14  9077      
ufshcd_vreg_set_lpm(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9078      /* Put the host 
controller in low power mode if possible */
9bad6c1c707d2a Asutosh Das        2021-04-14  9079      
ufshcd_hba_vreg_set_lpm(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9080      return ret;
9bad6c1c707d2a Asutosh Das        2021-04-14  9081  }
9bad6c1c707d2a Asutosh Das        2021-04-14  9082  
9bad6c1c707d2a Asutosh Das        2021-04-14  9083  /**
9bad6c1c707d2a Asutosh Das        2021-04-14  9084   * ufshcd_resume - helper 
function for resume operations
9bad6c1c707d2a Asutosh Das        2021-04-14  9085   * @hba: per adapter 
instance
9bad6c1c707d2a Asutosh Das        2021-04-14  9086   *
9bad6c1c707d2a Asutosh Das        2021-04-14  9087   * This function basically 
turns on the regulators, clocks and
9bad6c1c707d2a Asutosh Das        2021-04-14  9088   * irqs of the hba.
9bad6c1c707d2a Asutosh Das        2021-04-14  9089   * Also check the 
description of __ufshcd_wl_resume().
9bad6c1c707d2a Asutosh Das        2021-04-14  9090   *
9bad6c1c707d2a Asutosh Das        2021-04-14  9091   * Returns 0 for success 
and non-zero for failure
9bad6c1c707d2a Asutosh Das        2021-04-14  9092   */
9bad6c1c707d2a Asutosh Das        2021-04-14  9093  static int 
ufshcd_resume(struct ufs_hba *hba)
9bad6c1c707d2a Asutosh Das        2021-04-14  9094  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9095      int ret;
9bad6c1c707d2a Asutosh Das        2021-04-14  9096  
9bad6c1c707d2a Asutosh Das        2021-04-14  9097      if (!hba->is_powered)
9bad6c1c707d2a Asutosh Das        2021-04-14  9098              return 0;
9bad6c1c707d2a Asutosh Das        2021-04-14  9099  
9bad6c1c707d2a Asutosh Das        2021-04-14  9100      
ufshcd_hba_vreg_set_hpm(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9101      ret = 
ufshcd_vreg_set_hpm(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9102      if (ret)
9bad6c1c707d2a Asutosh Das        2021-04-14  9103              goto out;
9bad6c1c707d2a Asutosh Das        2021-04-14  9104  
9bad6c1c707d2a Asutosh Das        2021-04-14  9105      /* Make sure clocks are 
enabled before accessing controller */
9bad6c1c707d2a Asutosh Das        2021-04-14  9106      ret = 
ufshcd_setup_clocks(hba, true);
9bad6c1c707d2a Asutosh Das        2021-04-14  9107      if (ret)
9bad6c1c707d2a Asutosh Das        2021-04-14  9108              goto 
disable_vreg;
9bad6c1c707d2a Asutosh Das        2021-04-14  9109  
9bad6c1c707d2a Asutosh Das        2021-04-14  9110      /* enable the host irq 
as host controller would be active soon */
9bad6c1c707d2a Asutosh Das        2021-04-14  9111      ufshcd_enable_irq(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9112      goto out;
9bad6c1c707d2a Asutosh Das        2021-04-14  9113  
528db9e563d1cb Ziqi Chen          2021-01-08  9114  disable_vreg:
528db9e563d1cb Ziqi Chen          2021-01-08  9115      
ufshcd_vreg_set_lpm(hba);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9116  out:
8808b4e9dcdc90 Stanley Chu        2019-07-10  9117      if (ret)
e965e5e00b23c4 Stanley Chu        2020-12-05  9118              
ufshcd_update_evt_hist(hba, UFS_EVT_RESUME_ERR, (u32)ret);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9119      return ret;
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9120  }
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9121  
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9122  /**
57d104c153d3d6 Subhash Jadavani   2014-09-25  9123   * ufshcd_system_suspend - 
system suspend routine
3b1d05807a9a68 Vinayak Holikatti  2013-02-25  9124   * @hba: per adapter 
instance
57d104c153d3d6 Subhash Jadavani   2014-09-25  9125   *
57d104c153d3d6 Subhash Jadavani   2014-09-25  9126   * Check the description of 
ufshcd_suspend() function for more details.
9bad6c1c707d2a Asutosh Das        2021-04-14  9127   * Also check the 
description of __ufshcd_wl_suspend().
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9128   *
57d104c153d3d6 Subhash Jadavani   2014-09-25  9129   * Returns 0 for success 
and non-zero for failure
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9130   */
57d104c153d3d6 Subhash Jadavani   2014-09-25  9131  int 
ufshcd_system_suspend(struct ufs_hba *hba)
7a3e97b0dc4bba Santosh Yaraganavi 2012-02-29  9132  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9133      int ret;
7ff5ab47363334 Subhash Jadavani   2016-12-22  9134      ktime_t start = 
ktime_get();
57d104c153d3d6 Subhash Jadavani   2014-09-25  9135  
9bad6c1c707d2a Asutosh Das        2021-04-14  9136      if 
(pm_runtime_suspended(hba->dev))
57d104c153d3d6 Subhash Jadavani   2014-09-25  9137              goto out;
3b1d05807a9a68 Vinayak Holikatti  2013-02-25  9138  
9bad6c1c707d2a Asutosh Das        2021-04-14  9139      ret = 
ufshcd_suspend(hba);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9140  out:
7ff5ab47363334 Subhash Jadavani   2016-12-22 @9141      
trace_ufshcd_system_suspend(dev_name(hba->dev), ret,
7ff5ab47363334 Subhash Jadavani   2016-12-22  9142              
ktime_to_us(ktime_sub(ktime_get(), start)),
73eba2be9203c0 Subhash Jadavani   2017-01-10  9143              
hba->curr_dev_pwr_mode, hba->uic_link_state);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9144      return ret;
57d104c153d3d6 Subhash Jadavani   2014-09-25  9145  }
57d104c153d3d6 Subhash Jadavani   2014-09-25  9146  
EXPORT_SYMBOL(ufshcd_system_suspend);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9147  
57d104c153d3d6 Subhash Jadavani   2014-09-25  9148  /**
57d104c153d3d6 Subhash Jadavani   2014-09-25  9149   * ufshcd_system_resume - 
system resume routine
57d104c153d3d6 Subhash Jadavani   2014-09-25  9150   * @hba: per adapter 
instance
57d104c153d3d6 Subhash Jadavani   2014-09-25  9151   *
57d104c153d3d6 Subhash Jadavani   2014-09-25  9152   * Returns 0 for success 
and non-zero for failure
57d104c153d3d6 Subhash Jadavani   2014-09-25  9153   */
57d104c153d3d6 Subhash Jadavani   2014-09-25  9154  
57d104c153d3d6 Subhash Jadavani   2014-09-25  9155  int 
ufshcd_system_resume(struct ufs_hba *hba)
66ec6d59407baf Sujit Reddy Thumma 2013-07-30  9156  {
9bad6c1c707d2a Asutosh Das        2021-04-14  9157      int ret;
7ff5ab47363334 Subhash Jadavani   2016-12-22  9158      ktime_t start = 
ktime_get();
7ff5ab47363334 Subhash Jadavani   2016-12-22  9159  
9bad6c1c707d2a Asutosh Das        2021-04-14  9160      if 
(pm_runtime_suspended(hba->dev))
7ff5ab47363334 Subhash Jadavani   2016-12-22  9161              goto out;
9bad6c1c707d2a Asutosh Das        2021-04-14  9162  
9bad6c1c707d2a Asutosh Das        2021-04-14  9163      ret = 
ufshcd_resume(hba);
9bad6c1c707d2a Asutosh Das        2021-04-14  9164  
7ff5ab47363334 Subhash Jadavani   2016-12-22  9165  out:
7ff5ab47363334 Subhash Jadavani   2016-12-22 @9166      
trace_ufshcd_system_resume(dev_name(hba->dev), ret,
7ff5ab47363334 Subhash Jadavani   2016-12-22  9167              
ktime_to_us(ktime_sub(ktime_get(), start)),
73eba2be9203c0 Subhash Jadavani   2017-01-10  9168              
hba->curr_dev_pwr_mode, hba->uic_link_state);
9bad6c1c707d2a Asutosh Das        2021-04-14  9169  
7ff5ab47363334 Subhash Jadavani   2016-12-22  9170      return ret;
57d104c153d3d6 Subhash Jadavani   2014-09-25  9171  }
57d104c153d3d6 Subhash Jadavani   2014-09-25  9172  
EXPORT_SYMBOL(ufshcd_system_resume);
57d104c153d3d6 Subhash Jadavani   2014-09-25  9173  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to