aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:32:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:32:15 -0500
commitd9978ec5680059d727b39d6c706777c6973587f2 (patch)
tree8fad9cf8cf9599af58757e4acbf27c602df9ed79 /drivers/scsi
parenta883b70d8e0a88278c0a1f80753b4dc99962b541 (diff)
parent53637e0760d56274177be7e6d630490bc49766c1 (diff)
Merge tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
Pull libata updates from Jeff Garzik: 1) apply, and then revert, the sysfs export of ATA host controller number. Discussion was continuing after patch application, trying to figure out how to best mesh exported data with the installers, boot-time agents and other parties that want this info. 2) Merge Zero-Power Optical Device Driver (ZPODD) support, bringing the wonderfulness of sane power management to your CD/DVD device. Includes one SCSI-subsystem patch (with appropriate ACKs), adding runtime PM support to 'sr' driver. That is the ZPODD interaction bits. Patchset went through some 13 revisions before it got here; kudos to Intel for persistence. 3) pata_samsung_cf: use devm_clk_get() 4) more ata_piix, ahci PCI IDs 5) Add SATA driver for R-Car SoC 6) Convert libata to use devm_ioremap_resource (Note: I think Greg sent this to you, also) 7) Set proper Sense Key (SK) in the SCSI simulator when ATA passthrough indicates check condition. Google and specification hawks everywhere shall rejoice. * tag 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (22 commits) [libata] fix smatch warning for zpodd_wake_dev [libata] Set proper SK when CK_COND is set. [libata] Convert to devm_ioremap_resource() libata: add R-Car SATA driver ahci: Add Device IDs for Intel Wellsburg PCH ata_piix: Add Device IDs for Intel Wellsburg PCH [SCSI] remove can_power_off flag from scsi_device [libata] scsi: no poll when ODD is powered off [SCSI] sr: support runtime pm ahci: AHCI-mode SATA patch for Intel Avoton DeviceIDs ata_piix: IDE-mode SATA patch for Intel Avoton DeviceIDs [libata] PM code cleanup for ata port [libata] pm: differentiate system and runtime pm for ata port Revert "libata: export host controller number thru /sys" libata: do not suspend port if normal ODD is attached libata: expose pm qos flags for ata device libata: handle power transition of ODD libata: check zero power ready status for ZPODD libata: move acpi notification code to zpodd libata: identify and init ZPODD devices ...
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_lib.c14
-rw-r--r--drivers/scsi/sr.c46
2 files changed, 57 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f1bf5aff68ed..765398c063c7 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2617,3 +2617,17 @@ void scsi_kunmap_atomic_sg(void *virt)
2617 kunmap_atomic(virt); 2617 kunmap_atomic(virt);
2618} 2618}
2619EXPORT_SYMBOL(scsi_kunmap_atomic_sg); 2619EXPORT_SYMBOL(scsi_kunmap_atomic_sg);
2620
2621void sdev_disable_disk_events(struct scsi_device *sdev)
2622{
2623 atomic_inc(&sdev->disk_events_disable_depth);
2624}
2625EXPORT_SYMBOL(sdev_disable_disk_events);
2626
2627void sdev_enable_disk_events(struct scsi_device *sdev)
2628{
2629 if (WARN_ON_ONCE(atomic_read(&sdev->disk_events_disable_depth) <= 0))
2630 return;
2631 atomic_dec(&sdev->disk_events_disable_depth);
2632}
2633EXPORT_SYMBOL(sdev_enable_disk_events);
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 5fc97d2ba2fd..f2884ee90710 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -45,6 +45,7 @@
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/slab.h> 47#include <linux/slab.h>
48#include <linux/pm_runtime.h>
48#include <asm/uaccess.h> 49#include <asm/uaccess.h>
49 50
50#include <scsi/scsi.h> 51#include <scsi/scsi.h>
@@ -79,6 +80,11 @@ static DEFINE_MUTEX(sr_mutex);
79static int sr_probe(struct device *); 80static int sr_probe(struct device *);
80static int sr_remove(struct device *); 81static int sr_remove(struct device *);
81static int sr_done(struct scsi_cmnd *); 82static int sr_done(struct scsi_cmnd *);
83static int sr_runtime_suspend(struct device *dev);
84
85static struct dev_pm_ops sr_pm_ops = {
86 .runtime_suspend = sr_runtime_suspend,
87};
82 88
83static struct scsi_driver sr_template = { 89static struct scsi_driver sr_template = {
84 .owner = THIS_MODULE, 90 .owner = THIS_MODULE,
@@ -86,6 +92,7 @@ static struct scsi_driver sr_template = {
86 .name = "sr", 92 .name = "sr",
87 .probe = sr_probe, 93 .probe = sr_probe,
88 .remove = sr_remove, 94 .remove = sr_remove,
95 .pm = &sr_pm_ops,
89 }, 96 },
90 .done = sr_done, 97 .done = sr_done,
91}; 98};
@@ -131,6 +138,16 @@ static inline struct scsi_cd *scsi_cd(struct gendisk *disk)
131 return container_of(disk->private_data, struct scsi_cd, driver); 138 return container_of(disk->private_data, struct scsi_cd, driver);
132} 139}
133 140
141static int sr_runtime_suspend(struct device *dev)
142{
143 struct scsi_cd *cd = dev_get_drvdata(dev);
144
145 if (cd->media_present)
146 return -EBUSY;
147 else
148 return 0;
149}
150
134/* 151/*
135 * The get and put routines for the struct scsi_cd. Note this entity 152 * The get and put routines for the struct scsi_cd. Note this entity
136 * has a scsi_device pointer and owns a reference to this. 153 * has a scsi_device pointer and owns a reference to this.
@@ -146,7 +163,8 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
146 kref_get(&cd->kref); 163 kref_get(&cd->kref);
147 if (scsi_device_get(cd->device)) 164 if (scsi_device_get(cd->device))
148 goto out_put; 165 goto out_put;
149 goto out; 166 if (!scsi_autopm_get_device(cd->device))
167 goto out;
150 168
151 out_put: 169 out_put:
152 kref_put(&cd->kref, sr_kref_release); 170 kref_put(&cd->kref, sr_kref_release);
@@ -162,6 +180,7 @@ static void scsi_cd_put(struct scsi_cd *cd)
162 180
163 mutex_lock(&sr_ref_mutex); 181 mutex_lock(&sr_ref_mutex);
164 kref_put(&cd->kref, sr_kref_release); 182 kref_put(&cd->kref, sr_kref_release);
183 scsi_autopm_put_device(sdev);
165 scsi_device_put(sdev); 184 scsi_device_put(sdev);
166 mutex_unlock(&sr_ref_mutex); 185 mutex_unlock(&sr_ref_mutex);
167} 186}
@@ -540,6 +559,8 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
540 void __user *argp = (void __user *)arg; 559 void __user *argp = (void __user *)arg;
541 int ret; 560 int ret;
542 561
562 scsi_autopm_get_device(cd->device);
563
543 mutex_lock(&sr_mutex); 564 mutex_lock(&sr_mutex);
544 565
545 /* 566 /*
@@ -571,6 +592,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
571 592
572out: 593out:
573 mutex_unlock(&sr_mutex); 594 mutex_unlock(&sr_mutex);
595 scsi_autopm_put_device(cd->device);
574 return ret; 596 return ret;
575} 597}
576 598
@@ -578,7 +600,17 @@ static unsigned int sr_block_check_events(struct gendisk *disk,
578 unsigned int clearing) 600 unsigned int clearing)
579{ 601{
580 struct scsi_cd *cd = scsi_cd(disk); 602 struct scsi_cd *cd = scsi_cd(disk);
581 return cdrom_check_events(&cd->cdi, clearing); 603 unsigned int ret;
604
605 if (atomic_read(&cd->device->disk_events_disable_depth) == 0) {
606 scsi_autopm_get_device(cd->device);
607 ret = cdrom_check_events(&cd->cdi, clearing);
608 scsi_autopm_put_device(cd->device);
609 } else {
610 ret = 0;
611 }
612
613 return ret;
582} 614}
583 615
584static int sr_block_revalidate_disk(struct gendisk *disk) 616static int sr_block_revalidate_disk(struct gendisk *disk)
@@ -586,12 +618,16 @@ static int sr_block_revalidate_disk(struct gendisk *disk)
586 struct scsi_cd *cd = scsi_cd(disk); 618 struct scsi_cd *cd = scsi_cd(disk);
587 struct scsi_sense_hdr sshdr; 619 struct scsi_sense_hdr sshdr;
588 620
621 scsi_autopm_get_device(cd->device);
622
589 /* if the unit is not ready, nothing more to do */ 623 /* if the unit is not ready, nothing more to do */
590 if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)) 624 if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
591 return 0; 625 goto out;
592 626
593 sr_cd_check(&cd->cdi); 627 sr_cd_check(&cd->cdi);
594 get_sectorsize(cd); 628 get_sectorsize(cd);
629out:
630 scsi_autopm_put_device(cd->device);
595 return 0; 631 return 0;
596} 632}
597 633
@@ -718,6 +754,8 @@ static int sr_probe(struct device *dev)
718 754
719 sdev_printk(KERN_DEBUG, sdev, 755 sdev_printk(KERN_DEBUG, sdev,
720 "Attached scsi CD-ROM %s\n", cd->cdi.name); 756 "Attached scsi CD-ROM %s\n", cd->cdi.name);
757 scsi_autopm_put_device(cd->device);
758
721 return 0; 759 return 0;
722 760
723fail_put: 761fail_put:
@@ -965,6 +1003,8 @@ static int sr_remove(struct device *dev)
965{ 1003{
966 struct scsi_cd *cd = dev_get_drvdata(dev); 1004 struct scsi_cd *cd = dev_get_drvdata(dev);
967 1005
1006 scsi_autopm_get_device(cd->device);
1007
968 blk_queue_prep_rq(cd->device->request_queue, scsi_prep_fn); 1008 blk_queue_prep_rq(cd->device->request_queue, scsi_prep_fn);
969 del_gendisk(cd->disk); 1009 del_gendisk(cd->disk);
970 1010