Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 28 Feb 2021 19:51:20 +0000 (11:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 28 Feb 2021 19:51:20 +0000 (11:51 -0800)
Pull more SCSI updates from James Bottomley:
 "This is a few driver updates (iscsi, mpt3sas) that were still in the
  staging queue when the merge window opened (all committed on or before
  8 Feb) and some small bug fixes which came in during the merge window
  (all committed on 22 Feb)"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (30 commits)
  scsi: hpsa: Correct dev cmds outstanding for retried cmds
  scsi: sd: Fix Opal support
  scsi: target: tcmu: Fix memory leak caused by wrong uio usage
  scsi: target: tcmu: Move some functions without code change
  scsi: sd: sd_zbc: Don't pass GFP_NOIO to kvcalloc
  scsi: aic7xxx: Remove unused function pointer typedef ahc_bus_suspend/resume_t
  scsi: bnx2fc: Fix Kconfig warning & CNIC build errors
  scsi: ufs: Fix a duplicate dev quirk number
  scsi: aic79xx: Fix spelling of version
  scsi: target: core: Prevent underflow for service actions
  scsi: target: core: Add cmd length set before cmd complete
  scsi: iscsi: Drop session lock in iscsi_session_chkready()
  scsi: qla4xxx: Use iscsi_is_session_online()
  scsi: libiscsi: Reset max/exp cmdsn during recovery
  scsi: iscsi_tcp: Fix shost can_queue initialization
  scsi: libiscsi: Add helper to calculate max SCSI cmds per session
  scsi: libiscsi: Fix iSCSI host workq destruction
  scsi: libiscsi: Fix iscsi_task use after free()
  scsi: libiscsi: Drop taskqueuelock
  scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling
  ...

1  2 
drivers/scsi/sd_zbc.c
drivers/scsi/ufs/ufshcd.c

diff --combined drivers/scsi/sd_zbc.c
index 03adb39293c2d897f6e6968a1414c8ee9800b4dd,87a7274e4632b4f3e9201beefd090b634bb90ee0..ee558675eab4aa862850dd86a620570e1e4fe98a
@@@ -665,28 -665,12 +665,28 @@@ static int sd_zbc_init_disk(struct scsi
        return 0;
  }
  
 -void sd_zbc_release_disk(struct scsi_disk *sdkp)
 +static void sd_zbc_clear_zone_info(struct scsi_disk *sdkp)
  {
 +      /* Serialize against revalidate zones */
 +      mutex_lock(&sdkp->rev_mutex);
 +
        kvfree(sdkp->zones_wp_offset);
        sdkp->zones_wp_offset = NULL;
        kfree(sdkp->zone_wp_update_buf);
        sdkp->zone_wp_update_buf = NULL;
 +
 +      sdkp->nr_zones = 0;
 +      sdkp->rev_nr_zones = 0;
 +      sdkp->zone_blocks = 0;
 +      sdkp->rev_zone_blocks = 0;
 +
 +      mutex_unlock(&sdkp->rev_mutex);
 +}
 +
 +void sd_zbc_release_disk(struct scsi_disk *sdkp)
 +{
 +      if (sd_is_zoned(sdkp))
 +              sd_zbc_clear_zone_info(sdkp);
  }
  
  static void sd_zbc_revalidate_zones_cb(struct gendisk *disk)
@@@ -704,6 -688,7 +704,7 @@@ int sd_zbc_revalidate_zones(struct scsi
        unsigned int nr_zones = sdkp->rev_nr_zones;
        u32 max_append;
        int ret = 0;
+       unsigned int flags;
  
        /*
         * For all zoned disks, initialize zone append emulation data if not
            disk->queue->nr_zones == nr_zones)
                goto unlock;
  
+       flags = memalloc_noio_save();
        sdkp->zone_blocks = zone_blocks;
        sdkp->nr_zones = nr_zones;
-       sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_NOIO);
+       sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);
        if (!sdkp->rev_wp_offset) {
                ret = -ENOMEM;
+               memalloc_noio_restore(flags);
                goto unlock;
        }
  
        ret = blk_revalidate_disk_zones(disk, sd_zbc_revalidate_zones_cb);
  
+       memalloc_noio_restore(flags);
        kvfree(sdkp->rev_wp_offset);
        sdkp->rev_wp_offset = NULL;
  
@@@ -785,21 -773,6 +789,21 @@@ int sd_zbc_read_zones(struct scsi_disk 
                 */
                return 0;
  
 +      /* READ16/WRITE16 is mandatory for ZBC disks */
 +      sdkp->device->use_16_for_rw = 1;
 +      sdkp->device->use_10_for_rw = 0;
 +
 +      if (!blk_queue_is_zoned(q)) {
 +              /*
 +               * This can happen for a host aware disk with partitions.
 +               * The block device zone information was already cleared
 +               * by blk_queue_set_zoned(). Only clear the scsi disk zone
 +               * information and exit early.
 +               */
 +              sd_zbc_clear_zone_info(sdkp);
 +              return 0;
 +      }
 +
        /* Check zoned block device characteristics (unconstrained reads) */
        ret = sd_zbc_check_zoned_characteristics(sdkp, buf);
        if (ret)
        blk_queue_max_active_zones(q, 0);
        nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
  
 -      /* READ16/WRITE16 is mandatory for ZBC disks */
 -      sdkp->device->use_16_for_rw = 1;
 -      sdkp->device->use_10_for_rw = 0;
 +      /*
 +       * Per ZBC and ZAC specifications, writes in sequential write required
 +       * zones of host-managed devices must be aligned to the device physical
 +       * block size.
 +       */
 +      if (blk_queue_zoned_model(q) == BLK_ZONED_HM)
 +              blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
  
        sdkp->rev_nr_zones = nr_zones;
        sdkp->rev_zone_blocks = zone_blocks;
index 721f55db181f404c2def0311dba7ca33d6ae4f96,80620c8661929128412e65647cd77997f09cb263..77161750c9fb34df04e48caf6548600f7b16bac6
@@@ -451,6 -451,8 +451,8 @@@ static void ufshcd_print_evt(struct ufs
  
        if (!found)
                dev_err(hba->dev, "No record of %s\n", err_name);
+       else
+               dev_err(hba->dev, "%s: total cnt=%llu\n", err_name, e->cnt);
  }
  
  static void ufshcd_print_evt_hist(struct ufs_hba *hba)
@@@ -1866,7 -1868,7 +1868,7 @@@ static ssize_t ufshcd_clkgate_delay_sho
  {
        struct ufs_hba *hba = dev_get_drvdata(dev);
  
-       return snprintf(buf, PAGE_SIZE, "%lu\n", hba->clk_gating.delay_ms);
+       return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
  }
  
  static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
@@@ -1889,7 -1891,7 +1891,7 @@@ static ssize_t ufshcd_clkgate_enable_sh
  {
        struct ufs_hba *hba = dev_get_drvdata(dev);
  
-       return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_gating.is_enabled);
+       return sysfs_emit(buf, "%d\n", hba->clk_gating.is_enabled);
  }
  
  static ssize_t ufshcd_clkgate_enable_store(struct device *dev,
@@@ -9188,6 -9190,7 +9190,6 @@@ EXPORT_SYMBOL_GPL(ufshcd_remove)
   */
  void ufshcd_dealloc_host(struct ufs_hba *hba)
  {
 -      ufshcd_crypto_destroy_keyslot_manager(hba);
        scsi_host_put(hba->host);
  }
  EXPORT_SYMBOL_GPL(ufshcd_dealloc_host);