Merge branch '5.18/scsi-queue' into 5.18/scsi-fixes
authorMartin K. Petersen <martin.petersen@oracle.com>
Thu, 7 Apr 2022 01:46:54 +0000 (21:46 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 7 Apr 2022 01:46:54 +0000 (21:46 -0400)
Pull the remaining commits from 5.18/scsi-queue into fixes.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1  2 
drivers/scsi/lpfc/lpfc.h
drivers/scsi/sr.c

diff --combined drivers/scsi/lpfc/lpfc.h
index f0cf8ffdc5f3ea7f6c0ba38ca04146c2ed6e256a,8405fd0bbc598348e6a31edf49fa5c7b9a623838..0025760230e5182ffdeddb4e5a6aca470024394d
@@@ -592,7 -592,6 +592,7 @@@ struct lpfc_vport 
  #define FC_VPORT_LOGO_RCVD      0x200    /* LOGO received on vport */
  #define FC_RSCN_DISCOVERY       0x400  /* Auth all devices after RSCN */
  #define FC_LOGO_RCVD_DID_CHNG   0x800    /* FDISC on phys port detect DID chng*/
 +#define FC_PT2PT_NO_NVME        0x1000   /* Don't send NVME PRLI */
  #define FC_SCSI_SCAN_TMO        0x4000         /* scsi scan timer running */
  #define FC_ABORT_DISCOVERY      0x8000         /* we want to abort discovery */
  #define FC_NDISC_ACTIVE         0x10000        /* NPort discovery active */
@@@ -897,6 -896,11 +897,11 @@@ enum lpfc_irq_chann_mode 
        NHT_MODE,
  };
  
+ enum lpfc_hba_bit_flags {
+       FABRIC_COMANDS_BLOCKED,
+       HBA_PCI_ERR,
+ };
  struct lpfc_hba {
        /* SCSI interface function jump table entries */
        struct lpfc_io_buf * (*lpfc_get_scsi_buf)
                                         * Firmware supports Forced Link Speed
                                         * capability
                                         */
- #define HBA_PCI_ERR           0x80000 /* The PCI slot is offline */
  #define HBA_FLOGI_ISSUED      0x100000 /* FLOGI was issued */
  #define HBA_SHORT_CMF         0x200000 /* shorter CMF timer routine */
  #define HBA_CGN_DAY_WRAP      0x400000 /* HBA Congestion info day wraps */
        atomic_t fabric_iocb_count;
        struct timer_list fabric_block_timer;
        unsigned long bit_flags;
- #define       FABRIC_COMANDS_BLOCKED  0
        atomic_t num_rsrc_err;
        atomic_t num_cmd_success;
        unsigned long last_rsrc_error_time;
diff --combined drivers/scsi/sr.c
index 5ba9df334968d6dc2ef284a99e4c1eb760003199,f232514f5a2b320cb63b422f84e45ddcbae3c2a2..cbd92891a762c854fe35181fe1bb355dd94c776a
@@@ -109,6 -109,11 +109,6 @@@ static DEFINE_SPINLOCK(sr_index_lock)
  
  static struct lock_class_key sr_bio_compl_lkclass;
  
 -/* This semaphore is used to mediate the 0->1 reference get in the
 - * face of object destruction (i.e. we can't allow a get on an
 - * object after last put) */
 -static DEFINE_MUTEX(sr_ref_mutex);
 -
  static int sr_open(struct cdrom_device_info *, int);
  static void sr_release(struct cdrom_device_info *);
  
@@@ -138,9 -143,11 +138,9 @@@ static const struct cdrom_device_ops sr
        .capability             = SR_CAPABILITIES,
  };
  
 -static void sr_kref_release(struct kref *kref);
 -
  static inline struct scsi_cd *scsi_cd(struct gendisk *disk)
  {
 -      return container_of(disk->private_data, struct scsi_cd, driver);
 +      return disk->private_data;
  }
  
  static int sr_runtime_suspend(struct device *dev)
                return 0;
  }
  
 -/*
 - * The get and put routines for the struct scsi_cd.  Note this entity
 - * has a scsi_device pointer and owns a reference to this.
 - */
 -static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
 -{
 -      struct scsi_cd *cd = NULL;
 -
 -      mutex_lock(&sr_ref_mutex);
 -      if (disk->private_data == NULL)
 -              goto out;
 -      cd = scsi_cd(disk);
 -      kref_get(&cd->kref);
 -      if (scsi_device_get(cd->device)) {
 -              kref_put(&cd->kref, sr_kref_release);
 -              cd = NULL;
 -      }
 - out:
 -      mutex_unlock(&sr_ref_mutex);
 -      return cd;
 -}
 -
 -static void scsi_cd_put(struct scsi_cd *cd)
 -{
 -      struct scsi_device *sdev = cd->device;
 -
 -      mutex_lock(&sr_ref_mutex);
 -      kref_put(&cd->kref, sr_kref_release);
 -      scsi_device_put(sdev);
 -      mutex_unlock(&sr_ref_mutex);
 -}
 -
  static unsigned int sr_get_events(struct scsi_device *sdev)
  {
        u8 buf[8];
@@@ -483,13 -522,15 +483,13 @@@ static void sr_revalidate_disk(struct s
  
  static int sr_block_open(struct block_device *bdev, fmode_t mode)
  {
 -      struct scsi_cd *cd;
 -      struct scsi_device *sdev;
 -      int ret = -ENXIO;
 +      struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
 +      struct scsi_device *sdev = cd->device;
 +      int ret;
  
 -      cd = scsi_cd_get(bdev->bd_disk);
 -      if (!cd)
 -              goto out;
 +      if (scsi_device_get(cd->device))
 +              return -ENXIO;
  
 -      sdev = cd->device;
        scsi_autopm_get_device(sdev);
        if (bdev_check_media_change(bdev))
                sr_revalidate_disk(cd);
  
        scsi_autopm_put_device(sdev);
        if (ret)
 -              scsi_cd_put(cd);
 -
 -out:
 +              scsi_device_put(cd->device);
        return ret;
  }
  
@@@ -512,7 -555,7 +512,7 @@@ static void sr_block_release(struct gen
        cdrom_release(&cd->cdi, mode);
        mutex_unlock(&cd->lock);
  
 -      scsi_cd_put(cd);
 +      scsi_device_put(cd->device);
  }
  
  static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
  
        scsi_autopm_get_device(sdev);
  
-       if (ret != CDROMCLOSETRAY && ret != CDROMEJECT) {
+       if (cmd != CDROMCLOSETRAY && cmd != CDROMEJECT) {
                ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);
                if (ret != -ENOSYS)
                        goto put;
@@@ -552,24 -595,18 +552,24 @@@ out
  static unsigned int sr_block_check_events(struct gendisk *disk,
                                          unsigned int clearing)
  {
 -      unsigned int ret = 0;
 -      struct scsi_cd *cd;
 +      struct scsi_cd *cd = disk->private_data;
  
 -      cd = scsi_cd_get(disk);
 -      if (!cd)
 +      if (atomic_read(&cd->device->disk_events_disable_depth))
                return 0;
 +      return cdrom_check_events(&cd->cdi, clearing);
 +}
  
 -      if (!atomic_read(&cd->device->disk_events_disable_depth))
 -              ret = cdrom_check_events(&cd->cdi, clearing);
 +static void sr_free_disk(struct gendisk *disk)
 +{
 +      struct scsi_cd *cd = disk->private_data;
  
 -      scsi_cd_put(cd);
 -      return ret;
 +      spin_lock(&sr_index_lock);
 +      clear_bit(MINOR(disk_devt(disk)), sr_index_bits);
 +      spin_unlock(&sr_index_lock);
 +
 +      unregister_cdrom(&cd->cdi);
 +      mutex_destroy(&cd->lock);
 +      kfree(cd);
  }
  
  static const struct block_device_operations sr_bdops =
        .ioctl          = sr_block_ioctl,
        .compat_ioctl   = blkdev_compat_ptr_ioctl,
        .check_events   = sr_block_check_events,
 +      .free_disk      = sr_free_disk,
  };
  
  static int sr_open(struct cdrom_device_info *cdi, int purpose)
@@@ -624,6 -660,8 +624,6 @@@ static int sr_probe(struct device *dev
        if (!cd)
                goto fail;
  
 -      kref_init(&cd->kref);
 -
        disk = __alloc_disk_node(sdev->request_queue, NUMA_NO_NODE,
                                 &sr_bio_compl_lkclass);
        if (!disk)
  
        cd->device = sdev;
        cd->disk = disk;
 -      cd->driver = &sr_template;
        cd->capacity = 0x1fffff;
        cd->device->changed = 1;        /* force recheck CD type */
        cd->media_present = 1;
        sr_vendor_init(cd);
  
        set_capacity(disk, cd->capacity);
 -      disk->private_data = &cd->driver;
 +      disk->private_data = cd;
  
        if (register_cdrom(disk, &cd->cdi))
                goto fail_minor;
        sr_revalidate_disk(cd);
  
        error = device_add_disk(&sdev->sdev_gendev, disk, NULL);
 -      if (error) {
 -              kref_put(&cd->kref, sr_kref_release);
 -              goto fail;
 -      }
 +      if (error)
 +              goto unregister_cdrom;
  
        sdev_printk(KERN_DEBUG, sdev,
                    "Attached scsi CD-ROM %s\n", cd->cdi.name);
  
        return 0;
  
 +unregister_cdrom:
 +      unregister_cdrom(&cd->cdi);
  fail_minor:
        spin_lock(&sr_index_lock);
        clear_bit(minor, sr_index_bits);
@@@ -971,6 -1010,36 +971,6 @@@ out_put_request
        return ret;
  }
  
 -
 -/**
 - *    sr_kref_release - Called to free the scsi_cd structure
 - *    @kref: pointer to embedded kref
 - *
 - *    sr_ref_mutex must be held entering this routine.  Because it is
 - *    called on last put, you should always use the scsi_cd_get()
 - *    scsi_cd_put() helpers which manipulate the semaphore directly
 - *    and never do a direct kref_put().
 - **/
 -static void sr_kref_release(struct kref *kref)
 -{
 -      struct scsi_cd *cd = container_of(kref, struct scsi_cd, kref);
 -      struct gendisk *disk = cd->disk;
 -
 -      spin_lock(&sr_index_lock);
 -      clear_bit(MINOR(disk_devt(disk)), sr_index_bits);
 -      spin_unlock(&sr_index_lock);
 -
 -      unregister_cdrom(&cd->cdi);
 -
 -      disk->private_data = NULL;
 -
 -      put_disk(disk);
 -
 -      mutex_destroy(&cd->lock);
 -
 -      kfree(cd);
 -}
 -
  static int sr_remove(struct device *dev)
  {
        struct scsi_cd *cd = dev_get_drvdata(dev);
        scsi_autopm_get_device(cd->device);
  
        del_gendisk(cd->disk);
 -      dev_set_drvdata(dev, NULL);
 -
 -      mutex_lock(&sr_ref_mutex);
 -      kref_put(&cd->kref, sr_kref_release);
 -      mutex_unlock(&sr_ref_mutex);
 +      put_disk(cd->disk);
  
        return 0;
  }