Correct .gbs.conf settings
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / scsi / scsi_scan.c
index 5fad646..054ec2c 100644 (file)
@@ -320,6 +320,7 @@ static void scsi_target_destroy(struct scsi_target *starget)
        struct Scsi_Host *shost = dev_to_shost(dev->parent);
        unsigned long flags;
 
+       starget->state = STARGET_DEL;
        transport_destroy_device(dev);
        spin_lock_irqsave(shost->host_lock, flags);
        if (shost->hostt->target_destroy)
@@ -384,9 +385,15 @@ static void scsi_target_reap_ref_release(struct kref *kref)
        struct scsi_target *starget
                = container_of(kref, struct scsi_target, reap_ref);
 
-       transport_remove_device(&starget->dev);
-       device_del(&starget->dev);
-       starget->state = STARGET_DEL;
+       /*
+        * if we get here and the target is still in the CREATED state that
+        * means it was allocated but never made visible (because a scan
+        * turned up no LUNs), so don't call device_del() on it.
+        */
+       if (starget->state != STARGET_CREATED) {
+               transport_remove_device(&starget->dev);
+               device_del(&starget->dev);
+       }
        scsi_target_destroy(starget);
 }
 
@@ -506,11 +513,13 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
  */
 void scsi_target_reap(struct scsi_target *starget)
 {
+       /*
+        * serious problem if this triggers: STARGET_DEL is only set in the if
+        * the reap_ref drops to zero, so we're trying to do another final put
+        * on an already released kref
+        */
        BUG_ON(starget->state == STARGET_DEL);
-       if (starget->state == STARGET_CREATED)
-               scsi_target_destroy(starget);
-       else
-               scsi_target_reap_ref_put(starget);
+       scsi_target_reap_ref_put(starget);
 }
 
 /**
@@ -913,6 +922,12 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
        if (*bflags & BLIST_USE_10_BYTE_MS)
                sdev->use_10_for_ms = 1;
 
+       /* some devices don't like REPORT SUPPORTED OPERATION CODES
+        * and will simply timeout causing sd_mod init to take a very
+        * very long time */
+       if (*bflags & BLIST_NO_RSOC)
+               sdev->no_report_opcodes = 1;
+
        /* set the device running here so that slave configure
         * may do I/O */
        ret = scsi_device_set_state(sdev, SDEV_RUNNING);
@@ -941,7 +956,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 
        sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
 
-       if (*bflags & BLIST_SKIP_VPD_PAGES)
+       if (*bflags & BLIST_TRY_VPD_PAGES)
+               sdev->try_vpd_pages = 1;
+       else if (*bflags & BLIST_SKIP_VPD_PAGES)
                sdev->skip_vpd_pages = 1;
 
        transport_configure_device(&sdev->sdev_gendev);
@@ -1227,6 +1244,12 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
                max_dev_lun = min(8U, max_dev_lun);
 
        /*
+        * Stop scanning at 255 unless BLIST_SCSI3LUN
+        */
+       if (!(bflags & BLIST_SCSI3LUN))
+               max_dev_lun = min(256U, max_dev_lun);
+
+       /*
         * We have already scanned LUN 0, so start at LUN 1. Keep scanning
         * until we reach the max, or no LUN is found and we are not
         * sparse_lun.