Merge branch develop-3.10 into develop-3.10-next
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / sd.c
index c39863441337cd8982472af8e0ba4e68b60a49c6..26b543bc4f53caf9270027e8d5e297612c82cf78 100644 (file)
@@ -2627,14 +2627,23 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
 {
        struct scsi_device *sdev = sdkp->device;
 
+       if (sdev->host->no_write_same) {
+               sdev->no_write_same = 1;
+
+               return;
+       }
+
        if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) {
+               /* too large values might cause issues with arcmsr */
+               int vpd_buf_len = 64;
+
                sdev->no_report_opcodes = 1;
 
                /* Disable WRITE SAME if REPORT SUPPORTED OPERATION
                 * CODES is unsupported and the device has an ATA
                 * Information VPD page (SAT).
                 */
-               if (!scsi_get_vpd_page(sdev, 0x89, buffer, SD_BUF_SIZE))
+               if (!scsi_get_vpd_page(sdev, 0x89, buffer, vpd_buf_len))
                        sdev->no_write_same = 1;
        }
 
@@ -2843,6 +2852,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
                gd->events |= DISK_EVENT_MEDIA_CHANGE;
        }
 
+       blk_pm_runtime_init(sdp->request_queue, dev);
        add_disk(gd);
        if (sdkp->capacity)
                sd_dif_config_host(sdkp);
@@ -2851,7 +2861,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
 
        sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
                  sdp->removable ? "removable " : "");
-       blk_pm_runtime_init(sdp->request_queue, dev);
        scsi_autopm_put_device(sdp);
        put_device(&sdkp->dev);
 }