diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/Kconfig | 10 | ||||
-rw-r--r-- | drivers/scsi/ahci.c | 1 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 5 | ||||
-rw-r--r-- | drivers/scsi/hosts.c | 9 | ||||
-rw-r--r-- | drivers/scsi/ide-scsi.c | 4 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 145 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 48 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_nv.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sil.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sis.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_svw.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_uli.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_via.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 1 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 50 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 31 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 85 |
22 files changed, 273 insertions, 130 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 4c42065dea88..3c606cf8c8ca 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -914,7 +914,7 @@ config SCSI_INIA100 | |||
914 | 914 | ||
915 | config SCSI_PPA | 915 | config SCSI_PPA |
916 | tristate "IOMEGA parallel port (ppa - older drives)" | 916 | tristate "IOMEGA parallel port (ppa - older drives)" |
917 | depends on SCSI && PARPORT | 917 | depends on SCSI && PARPORT_PC |
918 | ---help--- | 918 | ---help--- |
919 | This driver supports older versions of IOMEGA's parallel port ZIP | 919 | This driver supports older versions of IOMEGA's parallel port ZIP |
920 | drive (a 100 MB removable media device). | 920 | drive (a 100 MB removable media device). |
@@ -941,7 +941,7 @@ config SCSI_PPA | |||
941 | 941 | ||
942 | config SCSI_IMM | 942 | config SCSI_IMM |
943 | tristate "IOMEGA parallel port (imm - newer drives)" | 943 | tristate "IOMEGA parallel port (imm - newer drives)" |
944 | depends on SCSI && PARPORT | 944 | depends on SCSI && PARPORT_PC |
945 | ---help--- | 945 | ---help--- |
946 | This driver supports newer versions of IOMEGA's parallel port ZIP | 946 | This driver supports newer versions of IOMEGA's parallel port ZIP |
947 | drive (a 100 MB removable media device). | 947 | drive (a 100 MB removable media device). |
@@ -968,7 +968,7 @@ config SCSI_IMM | |||
968 | 968 | ||
969 | config SCSI_IZIP_EPP16 | 969 | config SCSI_IZIP_EPP16 |
970 | bool "ppa/imm option - Use slow (but safe) EPP-16" | 970 | bool "ppa/imm option - Use slow (but safe) EPP-16" |
971 | depends on PARPORT && (SCSI_PPA || SCSI_IMM) | 971 | depends on SCSI_PPA || SCSI_IMM |
972 | ---help--- | 972 | ---help--- |
973 | EPP (Enhanced Parallel Port) is a standard for parallel ports which | 973 | EPP (Enhanced Parallel Port) is a standard for parallel ports which |
974 | allows them to act as expansion buses that can handle up to 64 | 974 | allows them to act as expansion buses that can handle up to 64 |
@@ -983,7 +983,7 @@ config SCSI_IZIP_EPP16 | |||
983 | 983 | ||
984 | config SCSI_IZIP_SLOW_CTR | 984 | config SCSI_IZIP_SLOW_CTR |
985 | bool "ppa/imm option - Assume slow parport control register" | 985 | bool "ppa/imm option - Assume slow parport control register" |
986 | depends on PARPORT && (SCSI_PPA || SCSI_IMM) | 986 | depends on SCSI_PPA || SCSI_IMM |
987 | help | 987 | help |
988 | Some parallel ports are known to have excessive delays between | 988 | Some parallel ports are known to have excessive delays between |
989 | changing the parallel port control register and good data being | 989 | changing the parallel port control register and good data being |
@@ -1815,7 +1815,7 @@ config SCSI_SUNESP | |||
1815 | 1815 | ||
1816 | config ZFCP | 1816 | config ZFCP |
1817 | tristate "FCP host bus adapter driver for IBM eServer zSeries" | 1817 | tristate "FCP host bus adapter driver for IBM eServer zSeries" |
1818 | depends on ARCH_S390 && QDIO && SCSI | 1818 | depends on S390 && QDIO && SCSI |
1819 | select SCSI_FC_ATTRS | 1819 | select SCSI_FC_ATTRS |
1820 | help | 1820 | help |
1821 | If you want to access SCSI devices attached to your IBM eServer | 1821 | If you want to access SCSI devices attached to your IBM eServer |
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 887eaa2a3ebf..d113290b5fc0 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -214,7 +214,6 @@ static struct scsi_host_template ahci_sht = { | |||
214 | .dma_boundary = AHCI_DMA_BOUNDARY, | 214 | .dma_boundary = AHCI_DMA_BOUNDARY, |
215 | .slave_configure = ata_scsi_slave_config, | 215 | .slave_configure = ata_scsi_slave_config, |
216 | .bios_param = ata_std_bios_param, | 216 | .bios_param = ata_std_bios_param, |
217 | .ordered_flush = 1, | ||
218 | }; | 217 | }; |
219 | 218 | ||
220 | static const struct ata_port_operations ahci_ops = { | 219 | static const struct ata_port_operations ahci_ops = { |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 0ea27873b9ff..557788ec4eec 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -166,6 +166,8 @@ static struct pci_driver piix_pci_driver = { | |||
166 | .id_table = piix_pci_tbl, | 166 | .id_table = piix_pci_tbl, |
167 | .probe = piix_init_one, | 167 | .probe = piix_init_one, |
168 | .remove = ata_pci_remove_one, | 168 | .remove = ata_pci_remove_one, |
169 | .suspend = ata_pci_device_suspend, | ||
170 | .resume = ata_pci_device_resume, | ||
169 | }; | 171 | }; |
170 | 172 | ||
171 | static struct scsi_host_template piix_sht = { | 173 | static struct scsi_host_template piix_sht = { |
@@ -185,7 +187,8 @@ static struct scsi_host_template piix_sht = { | |||
185 | .dma_boundary = ATA_DMA_BOUNDARY, | 187 | .dma_boundary = ATA_DMA_BOUNDARY, |
186 | .slave_configure = ata_scsi_slave_config, | 188 | .slave_configure = ata_scsi_slave_config, |
187 | .bios_param = ata_std_bios_param, | 189 | .bios_param = ata_std_bios_param, |
188 | .ordered_flush = 1, | 190 | .resume = ata_scsi_device_resume, |
191 | .suspend = ata_scsi_device_suspend, | ||
189 | }; | 192 | }; |
190 | 193 | ||
191 | static const struct ata_port_operations piix_pata_ops = { | 194 | static const struct ata_port_operations piix_pata_ops = { |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5b9c2c5a7f0e..66783c860a19 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -347,17 +347,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
347 | shost->cmd_per_lun = sht->cmd_per_lun; | 347 | shost->cmd_per_lun = sht->cmd_per_lun; |
348 | shost->unchecked_isa_dma = sht->unchecked_isa_dma; | 348 | shost->unchecked_isa_dma = sht->unchecked_isa_dma; |
349 | shost->use_clustering = sht->use_clustering; | 349 | shost->use_clustering = sht->use_clustering; |
350 | shost->ordered_flush = sht->ordered_flush; | ||
351 | shost->ordered_tag = sht->ordered_tag; | 350 | shost->ordered_tag = sht->ordered_tag; |
352 | 351 | ||
353 | /* | ||
354 | * hosts/devices that do queueing must support ordered tags | ||
355 | */ | ||
356 | if (shost->can_queue > 1 && shost->ordered_flush) { | ||
357 | printk(KERN_ERR "scsi: ordered flushes don't support queueing\n"); | ||
358 | shost->ordered_flush = 0; | ||
359 | } | ||
360 | |||
361 | if (sht->max_host_blocked) | 352 | if (sht->max_host_blocked) |
362 | shost->max_host_blocked = sht->max_host_blocked; | 353 | shost->max_host_blocked = sht->max_host_blocked; |
363 | else | 354 | else |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 4cb1f3ed9100..3c688ef54660 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -1046,7 +1046,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) | |||
1046 | 1046 | ||
1047 | /* kill current request */ | 1047 | /* kill current request */ |
1048 | blkdev_dequeue_request(req); | 1048 | blkdev_dequeue_request(req); |
1049 | end_that_request_last(req); | 1049 | end_that_request_last(req, 0); |
1050 | if (req->flags & REQ_SENSE) | 1050 | if (req->flags & REQ_SENSE) |
1051 | kfree(scsi->pc->buffer); | 1051 | kfree(scsi->pc->buffer); |
1052 | kfree(scsi->pc); | 1052 | kfree(scsi->pc); |
@@ -1056,7 +1056,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) | |||
1056 | /* now nuke the drive queue */ | 1056 | /* now nuke the drive queue */ |
1057 | while ((req = elv_next_request(drive->queue))) { | 1057 | while ((req = elv_next_request(drive->queue))) { |
1058 | blkdev_dequeue_request(req); | 1058 | blkdev_dequeue_request(req); |
1059 | end_that_request_last(req); | 1059 | end_that_request_last(req, 0); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | HWGROUP(drive)->rq = NULL; | 1062 | HWGROUP(drive)->rq = NULL; |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9ea102587914..f55b9b3f7b37 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -562,16 +562,28 @@ static const u8 ata_rw_cmds[] = { | |||
562 | ATA_CMD_WRITE_MULTI, | 562 | ATA_CMD_WRITE_MULTI, |
563 | ATA_CMD_READ_MULTI_EXT, | 563 | ATA_CMD_READ_MULTI_EXT, |
564 | ATA_CMD_WRITE_MULTI_EXT, | 564 | ATA_CMD_WRITE_MULTI_EXT, |
565 | 0, | ||
566 | 0, | ||
567 | 0, | ||
568 | ATA_CMD_WRITE_MULTI_FUA_EXT, | ||
565 | /* pio */ | 569 | /* pio */ |
566 | ATA_CMD_PIO_READ, | 570 | ATA_CMD_PIO_READ, |
567 | ATA_CMD_PIO_WRITE, | 571 | ATA_CMD_PIO_WRITE, |
568 | ATA_CMD_PIO_READ_EXT, | 572 | ATA_CMD_PIO_READ_EXT, |
569 | ATA_CMD_PIO_WRITE_EXT, | 573 | ATA_CMD_PIO_WRITE_EXT, |
574 | 0, | ||
575 | 0, | ||
576 | 0, | ||
577 | 0, | ||
570 | /* dma */ | 578 | /* dma */ |
571 | ATA_CMD_READ, | 579 | ATA_CMD_READ, |
572 | ATA_CMD_WRITE, | 580 | ATA_CMD_WRITE, |
573 | ATA_CMD_READ_EXT, | 581 | ATA_CMD_READ_EXT, |
574 | ATA_CMD_WRITE_EXT | 582 | ATA_CMD_WRITE_EXT, |
583 | 0, | ||
584 | 0, | ||
585 | 0, | ||
586 | ATA_CMD_WRITE_FUA_EXT | ||
575 | }; | 587 | }; |
576 | 588 | ||
577 | /** | 589 | /** |
@@ -584,25 +596,32 @@ static const u8 ata_rw_cmds[] = { | |||
584 | * LOCKING: | 596 | * LOCKING: |
585 | * caller. | 597 | * caller. |
586 | */ | 598 | */ |
587 | void ata_rwcmd_protocol(struct ata_queued_cmd *qc) | 599 | int ata_rwcmd_protocol(struct ata_queued_cmd *qc) |
588 | { | 600 | { |
589 | struct ata_taskfile *tf = &qc->tf; | 601 | struct ata_taskfile *tf = &qc->tf; |
590 | struct ata_device *dev = qc->dev; | 602 | struct ata_device *dev = qc->dev; |
603 | u8 cmd; | ||
591 | 604 | ||
592 | int index, lba48, write; | 605 | int index, fua, lba48, write; |
593 | 606 | ||
607 | fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; | ||
594 | lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; | 608 | lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; |
595 | write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; | 609 | write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; |
596 | 610 | ||
597 | if (dev->flags & ATA_DFLAG_PIO) { | 611 | if (dev->flags & ATA_DFLAG_PIO) { |
598 | tf->protocol = ATA_PROT_PIO; | 612 | tf->protocol = ATA_PROT_PIO; |
599 | index = dev->multi_count ? 0 : 4; | 613 | index = dev->multi_count ? 0 : 8; |
600 | } else { | 614 | } else { |
601 | tf->protocol = ATA_PROT_DMA; | 615 | tf->protocol = ATA_PROT_DMA; |
602 | index = 8; | 616 | index = 16; |
603 | } | 617 | } |
604 | 618 | ||
605 | tf->command = ata_rw_cmds[index + lba48 + write]; | 619 | cmd = ata_rw_cmds[index + fua + lba48 + write]; |
620 | if (cmd) { | ||
621 | tf->command = cmd; | ||
622 | return 0; | ||
623 | } | ||
624 | return -1; | ||
606 | } | 625 | } |
607 | 626 | ||
608 | static const char * const xfer_mode_str[] = { | 627 | static const char * const xfer_mode_str[] = { |
@@ -4154,6 +4173,96 @@ err_out: | |||
4154 | * Inherited from caller. | 4173 | * Inherited from caller. |
4155 | */ | 4174 | */ |
4156 | 4175 | ||
4176 | /* | ||
4177 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, | ||
4178 | * without filling any other registers | ||
4179 | */ | ||
4180 | static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, | ||
4181 | u8 cmd) | ||
4182 | { | ||
4183 | struct ata_taskfile tf; | ||
4184 | int err; | ||
4185 | |||
4186 | ata_tf_init(ap, &tf, dev->devno); | ||
4187 | |||
4188 | tf.command = cmd; | ||
4189 | tf.flags |= ATA_TFLAG_DEVICE; | ||
4190 | tf.protocol = ATA_PROT_NODATA; | ||
4191 | |||
4192 | err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | ||
4193 | if (err) | ||
4194 | printk(KERN_ERR "%s: ata command failed: %d\n", | ||
4195 | __FUNCTION__, err); | ||
4196 | |||
4197 | return err; | ||
4198 | } | ||
4199 | |||
4200 | static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) | ||
4201 | { | ||
4202 | u8 cmd; | ||
4203 | |||
4204 | if (!ata_try_flush_cache(dev)) | ||
4205 | return 0; | ||
4206 | |||
4207 | if (ata_id_has_flush_ext(dev->id)) | ||
4208 | cmd = ATA_CMD_FLUSH_EXT; | ||
4209 | else | ||
4210 | cmd = ATA_CMD_FLUSH; | ||
4211 | |||
4212 | return ata_do_simple_cmd(ap, dev, cmd); | ||
4213 | } | ||
4214 | |||
4215 | static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev) | ||
4216 | { | ||
4217 | return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1); | ||
4218 | } | ||
4219 | |||
4220 | static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | ||
4221 | { | ||
4222 | return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE); | ||
4223 | } | ||
4224 | |||
4225 | /** | ||
4226 | * ata_device_resume - wakeup a previously suspended devices | ||
4227 | * | ||
4228 | * Kick the drive back into action, by sending it an idle immediate | ||
4229 | * command and making sure its transfer mode matches between drive | ||
4230 | * and host. | ||
4231 | * | ||
4232 | */ | ||
4233 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | ||
4234 | { | ||
4235 | if (ap->flags & ATA_FLAG_SUSPENDED) { | ||
4236 | ap->flags &= ~ATA_FLAG_SUSPENDED; | ||
4237 | ata_set_mode(ap); | ||
4238 | } | ||
4239 | if (!ata_dev_present(dev)) | ||
4240 | return 0; | ||
4241 | if (dev->class == ATA_DEV_ATA) | ||
4242 | ata_start_drive(ap, dev); | ||
4243 | |||
4244 | return 0; | ||
4245 | } | ||
4246 | |||
4247 | /** | ||
4248 | * ata_device_suspend - prepare a device for suspend | ||
4249 | * | ||
4250 | * Flush the cache on the drive, if appropriate, then issue a | ||
4251 | * standbynow command. | ||
4252 | * | ||
4253 | */ | ||
4254 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) | ||
4255 | { | ||
4256 | if (!ata_dev_present(dev)) | ||
4257 | return 0; | ||
4258 | if (dev->class == ATA_DEV_ATA) | ||
4259 | ata_flush_cache(ap, dev); | ||
4260 | |||
4261 | ata_standby_drive(ap, dev); | ||
4262 | ap->flags |= ATA_FLAG_SUSPENDED; | ||
4263 | return 0; | ||
4264 | } | ||
4265 | |||
4157 | int ata_port_start (struct ata_port *ap) | 4266 | int ata_port_start (struct ata_port *ap) |
4158 | { | 4267 | { |
4159 | struct device *dev = ap->host_set->dev; | 4268 | struct device *dev = ap->host_set->dev; |
@@ -4902,6 +5011,23 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) | |||
4902 | 5011 | ||
4903 | return (tmp == bits->val) ? 1 : 0; | 5012 | return (tmp == bits->val) ? 1 : 0; |
4904 | } | 5013 | } |
5014 | |||
5015 | int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state) | ||
5016 | { | ||
5017 | pci_save_state(pdev); | ||
5018 | pci_disable_device(pdev); | ||
5019 | pci_set_power_state(pdev, PCI_D3hot); | ||
5020 | return 0; | ||
5021 | } | ||
5022 | |||
5023 | int ata_pci_device_resume(struct pci_dev *pdev) | ||
5024 | { | ||
5025 | pci_set_power_state(pdev, PCI_D0); | ||
5026 | pci_restore_state(pdev); | ||
5027 | pci_enable_device(pdev); | ||
5028 | pci_set_master(pdev); | ||
5029 | return 0; | ||
5030 | } | ||
4905 | #endif /* CONFIG_PCI */ | 5031 | #endif /* CONFIG_PCI */ |
4906 | 5032 | ||
4907 | 5033 | ||
@@ -5005,4 +5131,11 @@ EXPORT_SYMBOL_GPL(ata_pci_host_stop); | |||
5005 | EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); | 5131 | EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); |
5006 | EXPORT_SYMBOL_GPL(ata_pci_init_one); | 5132 | EXPORT_SYMBOL_GPL(ata_pci_init_one); |
5007 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); | 5133 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
5134 | EXPORT_SYMBOL_GPL(ata_pci_device_suspend); | ||
5135 | EXPORT_SYMBOL_GPL(ata_pci_device_resume); | ||
5008 | #endif /* CONFIG_PCI */ | 5136 | #endif /* CONFIG_PCI */ |
5137 | |||
5138 | EXPORT_SYMBOL_GPL(ata_device_suspend); | ||
5139 | EXPORT_SYMBOL_GPL(ata_device_resume); | ||
5140 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); | ||
5141 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); | ||
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index e0439be4b573..cfbceb504718 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -396,6 +396,22 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf) | |||
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | int ata_scsi_device_resume(struct scsi_device *sdev) | ||
400 | { | ||
401 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; | ||
402 | struct ata_device *dev = &ap->device[sdev->id]; | ||
403 | |||
404 | return ata_device_resume(ap, dev); | ||
405 | } | ||
406 | |||
407 | int ata_scsi_device_suspend(struct scsi_device *sdev) | ||
408 | { | ||
409 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; | ||
410 | struct ata_device *dev = &ap->device[sdev->id]; | ||
411 | |||
412 | return ata_device_suspend(ap, dev); | ||
413 | } | ||
414 | |||
399 | /** | 415 | /** |
400 | * ata_to_sense_error - convert ATA error to SCSI error | 416 | * ata_to_sense_error - convert ATA error to SCSI error |
401 | * @id: ATA device number | 417 | * @id: ATA device number |
@@ -1080,11 +1096,13 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1080 | scsicmd[0] == WRITE_16) | 1096 | scsicmd[0] == WRITE_16) |
1081 | tf->flags |= ATA_TFLAG_WRITE; | 1097 | tf->flags |= ATA_TFLAG_WRITE; |
1082 | 1098 | ||
1083 | /* Calculate the SCSI LBA and transfer length. */ | 1099 | /* Calculate the SCSI LBA, transfer length and FUA. */ |
1084 | switch (scsicmd[0]) { | 1100 | switch (scsicmd[0]) { |
1085 | case READ_10: | 1101 | case READ_10: |
1086 | case WRITE_10: | 1102 | case WRITE_10: |
1087 | scsi_10_lba_len(scsicmd, &block, &n_block); | 1103 | scsi_10_lba_len(scsicmd, &block, &n_block); |
1104 | if (unlikely(scsicmd[1] & (1 << 3))) | ||
1105 | tf->flags |= ATA_TFLAG_FUA; | ||
1088 | break; | 1106 | break; |
1089 | case READ_6: | 1107 | case READ_6: |
1090 | case WRITE_6: | 1108 | case WRITE_6: |
@@ -1099,6 +1117,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1099 | case READ_16: | 1117 | case READ_16: |
1100 | case WRITE_16: | 1118 | case WRITE_16: |
1101 | scsi_16_lba_len(scsicmd, &block, &n_block); | 1119 | scsi_16_lba_len(scsicmd, &block, &n_block); |
1120 | if (unlikely(scsicmd[1] & (1 << 3))) | ||
1121 | tf->flags |= ATA_TFLAG_FUA; | ||
1102 | break; | 1122 | break; |
1103 | default: | 1123 | default: |
1104 | DPRINTK("no-byte command\n"); | 1124 | DPRINTK("no-byte command\n"); |
@@ -1142,7 +1162,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1142 | tf->device |= (block >> 24) & 0xf; | 1162 | tf->device |= (block >> 24) & 0xf; |
1143 | } | 1163 | } |
1144 | 1164 | ||
1145 | ata_rwcmd_protocol(qc); | 1165 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) |
1166 | goto invalid_fld; | ||
1146 | 1167 | ||
1147 | qc->nsect = n_block; | 1168 | qc->nsect = n_block; |
1148 | tf->nsect = n_block & 0xff; | 1169 | tf->nsect = n_block & 0xff; |
@@ -1160,7 +1181,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1160 | if ((block >> 28) || (n_block > 256)) | 1181 | if ((block >> 28) || (n_block > 256)) |
1161 | goto out_of_range; | 1182 | goto out_of_range; |
1162 | 1183 | ||
1163 | ata_rwcmd_protocol(qc); | 1184 | if (unlikely(ata_rwcmd_protocol(qc) < 0)) |
1185 | goto invalid_fld; | ||
1164 | 1186 | ||
1165 | /* Convert LBA to CHS */ | 1187 | /* Convert LBA to CHS */ |
1166 | track = (u32)block / dev->sectors; | 1188 | track = (u32)block / dev->sectors; |
@@ -1695,6 +1717,7 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) | |||
1695 | unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | 1717 | unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, |
1696 | unsigned int buflen) | 1718 | unsigned int buflen) |
1697 | { | 1719 | { |
1720 | struct ata_device *dev = args->dev; | ||
1698 | u8 *scsicmd = args->cmd->cmnd, *p, *last; | 1721 | u8 *scsicmd = args->cmd->cmnd, *p, *last; |
1699 | const u8 sat_blk_desc[] = { | 1722 | const u8 sat_blk_desc[] = { |
1700 | 0, 0, 0, 0, /* number of blocks: sat unspecified */ | 1723 | 0, 0, 0, 0, /* number of blocks: sat unspecified */ |
@@ -1703,6 +1726,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1703 | }; | 1726 | }; |
1704 | u8 pg, spg; | 1727 | u8 pg, spg; |
1705 | unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; | 1728 | unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; |
1729 | u8 dpofua; | ||
1706 | 1730 | ||
1707 | VPRINTK("ENTER\n"); | 1731 | VPRINTK("ENTER\n"); |
1708 | 1732 | ||
@@ -1771,9 +1795,17 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1771 | 1795 | ||
1772 | if (minlen < 1) | 1796 | if (minlen < 1) |
1773 | return 0; | 1797 | return 0; |
1798 | |||
1799 | dpofua = 0; | ||
1800 | if (ata_id_has_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 && | ||
1801 | (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) | ||
1802 | dpofua = 1 << 4; | ||
1803 | |||
1774 | if (six_byte) { | 1804 | if (six_byte) { |
1775 | output_len--; | 1805 | output_len--; |
1776 | rbuf[0] = output_len; | 1806 | rbuf[0] = output_len; |
1807 | if (minlen > 2) | ||
1808 | rbuf[2] |= dpofua; | ||
1777 | if (ebd) { | 1809 | if (ebd) { |
1778 | if (minlen > 3) | 1810 | if (minlen > 3) |
1779 | rbuf[3] = sizeof(sat_blk_desc); | 1811 | rbuf[3] = sizeof(sat_blk_desc); |
@@ -1786,6 +1818,8 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, | |||
1786 | rbuf[0] = output_len >> 8; | 1818 | rbuf[0] = output_len >> 8; |
1787 | if (minlen > 1) | 1819 | if (minlen > 1) |
1788 | rbuf[1] = output_len; | 1820 | rbuf[1] = output_len; |
1821 | if (minlen > 3) | ||
1822 | rbuf[3] |= dpofua; | ||
1789 | if (ebd) { | 1823 | if (ebd) { |
1790 | if (minlen > 7) | 1824 | if (minlen > 7) |
1791 | rbuf[7] = sizeof(sat_blk_desc); | 1825 | rbuf[7] = sizeof(sat_blk_desc); |
@@ -2446,7 +2480,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
2446 | if (xlat_func) | 2480 | if (xlat_func) |
2447 | ata_scsi_translate(ap, dev, cmd, done, xlat_func); | 2481 | ata_scsi_translate(ap, dev, cmd, done, xlat_func); |
2448 | else | 2482 | else |
2449 | ata_scsi_simulate(dev->id, cmd, done); | 2483 | ata_scsi_simulate(ap, dev, cmd, done); |
2450 | } else | 2484 | } else |
2451 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); | 2485 | ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); |
2452 | 2486 | ||
@@ -2469,14 +2503,16 @@ out_unlock: | |||
2469 | * spin_lock_irqsave(host_set lock) | 2503 | * spin_lock_irqsave(host_set lock) |
2470 | */ | 2504 | */ |
2471 | 2505 | ||
2472 | void ata_scsi_simulate(u16 *id, | 2506 | void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, |
2473 | struct scsi_cmnd *cmd, | 2507 | struct scsi_cmnd *cmd, |
2474 | void (*done)(struct scsi_cmnd *)) | 2508 | void (*done)(struct scsi_cmnd *)) |
2475 | { | 2509 | { |
2476 | struct ata_scsi_args args; | 2510 | struct ata_scsi_args args; |
2477 | const u8 *scsicmd = cmd->cmnd; | 2511 | const u8 *scsicmd = cmd->cmnd; |
2478 | 2512 | ||
2479 | args.id = id; | 2513 | args.ap = ap; |
2514 | args.dev = dev; | ||
2515 | args.id = dev->id; | ||
2480 | args.cmd = cmd; | 2516 | args.cmd = cmd; |
2481 | args.done = done; | 2517 | args.done = done; |
2482 | 2518 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 251e53bdc6e0..e03ce48b7b4b 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -32,6 +32,8 @@ | |||
32 | #define DRV_VERSION "1.20" /* must be exactly four chars */ | 32 | #define DRV_VERSION "1.20" /* must be exactly four chars */ |
33 | 33 | ||
34 | struct ata_scsi_args { | 34 | struct ata_scsi_args { |
35 | struct ata_port *ap; | ||
36 | struct ata_device *dev; | ||
35 | u16 *id; | 37 | u16 *id; |
36 | struct scsi_cmnd *cmd; | 38 | struct scsi_cmnd *cmd; |
37 | void (*done)(struct scsi_cmnd *); | 39 | void (*done)(struct scsi_cmnd *); |
@@ -41,7 +43,7 @@ struct ata_scsi_args { | |||
41 | extern int atapi_enabled; | 43 | extern int atapi_enabled; |
42 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 44 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
43 | struct ata_device *dev); | 45 | struct ata_device *dev); |
44 | extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 46 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
45 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 47 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
46 | extern int ata_qc_issue(struct ata_queued_cmd *qc); | 48 | extern int ata_qc_issue(struct ata_queued_cmd *qc); |
47 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 49 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index b2bf16a9bf4b..cd54244058b5 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -374,7 +374,6 @@ static struct scsi_host_template mv_sht = { | |||
374 | .dma_boundary = MV_DMA_BOUNDARY, | 374 | .dma_boundary = MV_DMA_BOUNDARY, |
375 | .slave_configure = ata_scsi_slave_config, | 375 | .slave_configure = ata_scsi_slave_config, |
376 | .bios_param = ata_std_bios_param, | 376 | .bios_param = ata_std_bios_param, |
377 | .ordered_flush = 1, | ||
378 | }; | 377 | }; |
379 | 378 | ||
380 | static const struct ata_port_operations mv5_ops = { | 379 | static const struct ata_port_operations mv5_ops = { |
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 4954896dfdb9..c0cf52cb975a 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c | |||
@@ -235,7 +235,6 @@ static struct scsi_host_template nv_sht = { | |||
235 | .dma_boundary = ATA_DMA_BOUNDARY, | 235 | .dma_boundary = ATA_DMA_BOUNDARY, |
236 | .slave_configure = ata_scsi_slave_config, | 236 | .slave_configure = ata_scsi_slave_config, |
237 | .bios_param = ata_std_bios_param, | 237 | .bios_param = ata_std_bios_param, |
238 | .ordered_flush = 1, | ||
239 | }; | 238 | }; |
240 | 239 | ||
241 | static const struct ata_port_operations nv_ops = { | 240 | static const struct ata_port_operations nv_ops = { |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index da7fa04b8a73..3d1ea09a06a1 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -114,7 +114,6 @@ static struct scsi_host_template pdc_ata_sht = { | |||
114 | .dma_boundary = ATA_DMA_BOUNDARY, | 114 | .dma_boundary = ATA_DMA_BOUNDARY, |
115 | .slave_configure = ata_scsi_slave_config, | 115 | .slave_configure = ata_scsi_slave_config, |
116 | .bios_param = ata_std_bios_param, | 116 | .bios_param = ata_std_bios_param, |
117 | .ordered_flush = 1, | ||
118 | }; | 117 | }; |
119 | 118 | ||
120 | static const struct ata_port_operations pdc_sata_ops = { | 119 | static const struct ata_port_operations pdc_sata_ops = { |
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index d2053487c73b..b017f85e6d6a 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -147,7 +147,6 @@ static struct scsi_host_template sil_sht = { | |||
147 | .dma_boundary = ATA_DMA_BOUNDARY, | 147 | .dma_boundary = ATA_DMA_BOUNDARY, |
148 | .slave_configure = ata_scsi_slave_config, | 148 | .slave_configure = ata_scsi_slave_config, |
149 | .bios_param = ata_std_bios_param, | 149 | .bios_param = ata_std_bios_param, |
150 | .ordered_flush = 1, | ||
151 | }; | 150 | }; |
152 | 151 | ||
153 | static const struct ata_port_operations sil_ops = { | 152 | static const struct ata_port_operations sil_ops = { |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index a0ad3ed2200a..923130185a9e 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -292,7 +292,6 @@ static struct scsi_host_template sil24_sht = { | |||
292 | .dma_boundary = ATA_DMA_BOUNDARY, | 292 | .dma_boundary = ATA_DMA_BOUNDARY, |
293 | .slave_configure = ata_scsi_slave_config, | 293 | .slave_configure = ata_scsi_slave_config, |
294 | .bios_param = ata_std_bios_param, | 294 | .bios_param = ata_std_bios_param, |
295 | .ordered_flush = 1, /* NCQ not supported yet */ | ||
296 | }; | 295 | }; |
297 | 296 | ||
298 | static const struct ata_port_operations sil24_ops = { | 297 | static const struct ata_port_operations sil24_ops = { |
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 32e12620b162..2df8c5632ac3 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c | |||
@@ -99,7 +99,6 @@ static struct scsi_host_template sis_sht = { | |||
99 | .dma_boundary = ATA_DMA_BOUNDARY, | 99 | .dma_boundary = ATA_DMA_BOUNDARY, |
100 | .slave_configure = ata_scsi_slave_config, | 100 | .slave_configure = ata_scsi_slave_config, |
101 | .bios_param = ata_std_bios_param, | 101 | .bios_param = ata_std_bios_param, |
102 | .ordered_flush = 1, | ||
103 | }; | 102 | }; |
104 | 103 | ||
105 | static const struct ata_port_operations sis_ops = { | 104 | static const struct ata_port_operations sis_ops = { |
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 6e7f7c83a75a..668373590aa4 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -303,7 +303,6 @@ static struct scsi_host_template k2_sata_sht = { | |||
303 | .proc_info = k2_sata_proc_info, | 303 | .proc_info = k2_sata_proc_info, |
304 | #endif | 304 | #endif |
305 | .bios_param = ata_std_bios_param, | 305 | .bios_param = ata_std_bios_param, |
306 | .ordered_flush = 1, | ||
307 | }; | 306 | }; |
308 | 307 | ||
309 | 308 | ||
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 94b253b80da8..bc87c16c80d2 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -194,7 +194,6 @@ static struct scsi_host_template pdc_sata_sht = { | |||
194 | .dma_boundary = ATA_DMA_BOUNDARY, | 194 | .dma_boundary = ATA_DMA_BOUNDARY, |
195 | .slave_configure = ata_scsi_slave_config, | 195 | .slave_configure = ata_scsi_slave_config, |
196 | .bios_param = ata_std_bios_param, | 196 | .bios_param = ata_std_bios_param, |
197 | .ordered_flush = 1, | ||
198 | }; | 197 | }; |
199 | 198 | ||
200 | static const struct ata_port_operations pdc_20621_ops = { | 199 | static const struct ata_port_operations pdc_20621_ops = { |
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index b2422a0f25c8..9635ca700977 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c | |||
@@ -87,7 +87,6 @@ static struct scsi_host_template uli_sht = { | |||
87 | .dma_boundary = ATA_DMA_BOUNDARY, | 87 | .dma_boundary = ATA_DMA_BOUNDARY, |
88 | .slave_configure = ata_scsi_slave_config, | 88 | .slave_configure = ata_scsi_slave_config, |
89 | .bios_param = ata_std_bios_param, | 89 | .bios_param = ata_std_bios_param, |
90 | .ordered_flush = 1, | ||
91 | }; | 90 | }; |
92 | 91 | ||
93 | static const struct ata_port_operations uli_ops = { | 92 | static const struct ata_port_operations uli_ops = { |
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index c76215692da2..6d5b0a794cfd 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c | |||
@@ -106,7 +106,6 @@ static struct scsi_host_template svia_sht = { | |||
106 | .dma_boundary = ATA_DMA_BOUNDARY, | 106 | .dma_boundary = ATA_DMA_BOUNDARY, |
107 | .slave_configure = ata_scsi_slave_config, | 107 | .slave_configure = ata_scsi_slave_config, |
108 | .bios_param = ata_std_bios_param, | 108 | .bios_param = ata_std_bios_param, |
109 | .ordered_flush = 1, | ||
110 | }; | 109 | }; |
111 | 110 | ||
112 | static const struct ata_port_operations svia_sata_ops = { | 111 | static const struct ata_port_operations svia_sata_ops = { |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index fcfa486965b4..2e2c3b7acb0c 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -235,7 +235,6 @@ static struct scsi_host_template vsc_sata_sht = { | |||
235 | .dma_boundary = ATA_DMA_BOUNDARY, | 235 | .dma_boundary = ATA_DMA_BOUNDARY, |
236 | .slave_configure = ata_scsi_slave_config, | 236 | .slave_configure = ata_scsi_slave_config, |
237 | .bios_param = ata_std_bios_param, | 237 | .bios_param = ata_std_bios_param, |
238 | .ordered_flush = 1, | ||
239 | }; | 238 | }; |
240 | 239 | ||
241 | 240 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a7f3f0c84db7..ba93d6e66d48 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -308,7 +308,7 @@ struct scsi_io_context { | |||
308 | 308 | ||
309 | static kmem_cache_t *scsi_io_context_cache; | 309 | static kmem_cache_t *scsi_io_context_cache; |
310 | 310 | ||
311 | static void scsi_end_async(struct request *req) | 311 | static void scsi_end_async(struct request *req, int uptodate) |
312 | { | 312 | { |
313 | struct scsi_io_context *sioc = req->end_io_data; | 313 | struct scsi_io_context *sioc = req->end_io_data; |
314 | 314 | ||
@@ -791,7 +791,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, | |||
791 | spin_lock_irqsave(q->queue_lock, flags); | 791 | spin_lock_irqsave(q->queue_lock, flags); |
792 | if (blk_rq_tagged(req)) | 792 | if (blk_rq_tagged(req)) |
793 | blk_queue_end_tag(q, req); | 793 | blk_queue_end_tag(q, req); |
794 | end_that_request_last(req); | 794 | end_that_request_last(req, uptodate); |
795 | spin_unlock_irqrestore(q->queue_lock, flags); | 795 | spin_unlock_irqrestore(q->queue_lock, flags); |
796 | 796 | ||
797 | /* | 797 | /* |
@@ -932,9 +932,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, | |||
932 | int sense_valid = 0; | 932 | int sense_valid = 0; |
933 | int sense_deferred = 0; | 933 | int sense_deferred = 0; |
934 | 934 | ||
935 | if (blk_complete_barrier_rq(q, req, good_bytes >> 9)) | ||
936 | return; | ||
937 | |||
938 | /* | 935 | /* |
939 | * Free up any indirection buffers we allocated for DMA purposes. | 936 | * Free up any indirection buffers we allocated for DMA purposes. |
940 | * For the case of a READ, we need to copy the data out of the | 937 | * For the case of a READ, we need to copy the data out of the |
@@ -1199,38 +1196,6 @@ static int scsi_init_io(struct scsi_cmnd *cmd) | |||
1199 | return BLKPREP_KILL; | 1196 | return BLKPREP_KILL; |
1200 | } | 1197 | } |
1201 | 1198 | ||
1202 | static int scsi_prepare_flush_fn(request_queue_t *q, struct request *rq) | ||
1203 | { | ||
1204 | struct scsi_device *sdev = q->queuedata; | ||
1205 | struct scsi_driver *drv; | ||
1206 | |||
1207 | if (sdev->sdev_state == SDEV_RUNNING) { | ||
1208 | drv = *(struct scsi_driver **) rq->rq_disk->private_data; | ||
1209 | |||
1210 | if (drv->prepare_flush) | ||
1211 | return drv->prepare_flush(q, rq); | ||
1212 | } | ||
1213 | |||
1214 | return 0; | ||
1215 | } | ||
1216 | |||
1217 | static void scsi_end_flush_fn(request_queue_t *q, struct request *rq) | ||
1218 | { | ||
1219 | struct scsi_device *sdev = q->queuedata; | ||
1220 | struct request *flush_rq = rq->end_io_data; | ||
1221 | struct scsi_driver *drv; | ||
1222 | |||
1223 | if (flush_rq->errors) { | ||
1224 | printk("scsi: barrier error, disabling flush support\n"); | ||
1225 | blk_queue_ordered(q, QUEUE_ORDERED_NONE); | ||
1226 | } | ||
1227 | |||
1228 | if (sdev->sdev_state == SDEV_RUNNING) { | ||
1229 | drv = *(struct scsi_driver **) rq->rq_disk->private_data; | ||
1230 | drv->end_flush(q, rq); | ||
1231 | } | ||
1232 | } | ||
1233 | |||
1234 | static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, | 1199 | static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, |
1235 | sector_t *error_sector) | 1200 | sector_t *error_sector) |
1236 | { | 1201 | { |
@@ -1703,17 +1668,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) | |||
1703 | blk_queue_segment_boundary(q, shost->dma_boundary); | 1668 | blk_queue_segment_boundary(q, shost->dma_boundary); |
1704 | blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); | 1669 | blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); |
1705 | 1670 | ||
1706 | /* | ||
1707 | * ordered tags are superior to flush ordering | ||
1708 | */ | ||
1709 | if (shost->ordered_tag) | ||
1710 | blk_queue_ordered(q, QUEUE_ORDERED_TAG); | ||
1711 | else if (shost->ordered_flush) { | ||
1712 | blk_queue_ordered(q, QUEUE_ORDERED_FLUSH); | ||
1713 | q->prepare_flush_fn = scsi_prepare_flush_fn; | ||
1714 | q->end_flush_fn = scsi_end_flush_fn; | ||
1715 | } | ||
1716 | |||
1717 | if (!shost->use_clustering) | 1671 | if (!shost->use_clustering) |
1718 | clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); | 1672 | clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); |
1719 | return q; | 1673 | return q; |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 15842b1f0f4a..ea7f3a433572 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -263,9 +263,40 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv) | |||
263 | return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; | 263 | return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; |
264 | } | 264 | } |
265 | 265 | ||
266 | static int scsi_bus_suspend(struct device * dev, pm_message_t state) | ||
267 | { | ||
268 | struct scsi_device *sdev = to_scsi_device(dev); | ||
269 | struct scsi_host_template *sht = sdev->host->hostt; | ||
270 | int err; | ||
271 | |||
272 | err = scsi_device_quiesce(sdev); | ||
273 | if (err) | ||
274 | return err; | ||
275 | |||
276 | if (sht->suspend) | ||
277 | err = sht->suspend(sdev); | ||
278 | |||
279 | return err; | ||
280 | } | ||
281 | |||
282 | static int scsi_bus_resume(struct device * dev) | ||
283 | { | ||
284 | struct scsi_device *sdev = to_scsi_device(dev); | ||
285 | struct scsi_host_template *sht = sdev->host->hostt; | ||
286 | int err = 0; | ||
287 | |||
288 | if (sht->resume) | ||
289 | err = sht->resume(sdev); | ||
290 | |||
291 | scsi_device_resume(sdev); | ||
292 | return err; | ||
293 | } | ||
294 | |||
266 | struct bus_type scsi_bus_type = { | 295 | struct bus_type scsi_bus_type = { |
267 | .name = "scsi", | 296 | .name = "scsi", |
268 | .match = scsi_bus_match, | 297 | .match = scsi_bus_match, |
298 | .suspend = scsi_bus_suspend, | ||
299 | .resume = scsi_bus_resume, | ||
269 | }; | 300 | }; |
270 | 301 | ||
271 | int scsi_sysfs_register(void) | 302 | int scsi_sysfs_register(void) |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3d3ad7d1b779..32d4d8d7b9f3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -102,6 +102,7 @@ struct scsi_disk { | |||
102 | u8 write_prot; | 102 | u8 write_prot; |
103 | unsigned WCE : 1; /* state of disk WCE bit */ | 103 | unsigned WCE : 1; /* state of disk WCE bit */ |
104 | unsigned RCD : 1; /* state of disk RCD bit, unused */ | 104 | unsigned RCD : 1; /* state of disk RCD bit, unused */ |
105 | unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ | ||
105 | }; | 106 | }; |
106 | 107 | ||
107 | static DEFINE_IDR(sd_index_idr); | 108 | static DEFINE_IDR(sd_index_idr); |
@@ -121,8 +122,7 @@ static void sd_shutdown(struct device *dev); | |||
121 | static void sd_rescan(struct device *); | 122 | static void sd_rescan(struct device *); |
122 | static int sd_init_command(struct scsi_cmnd *); | 123 | static int sd_init_command(struct scsi_cmnd *); |
123 | static int sd_issue_flush(struct device *, sector_t *); | 124 | static int sd_issue_flush(struct device *, sector_t *); |
124 | static void sd_end_flush(request_queue_t *, struct request *); | 125 | static void sd_prepare_flush(request_queue_t *, struct request *); |
125 | static int sd_prepare_flush(request_queue_t *, struct request *); | ||
126 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, | 126 | static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, |
127 | unsigned char *buffer); | 127 | unsigned char *buffer); |
128 | 128 | ||
@@ -137,8 +137,6 @@ static struct scsi_driver sd_template = { | |||
137 | .rescan = sd_rescan, | 137 | .rescan = sd_rescan, |
138 | .init_command = sd_init_command, | 138 | .init_command = sd_init_command, |
139 | .issue_flush = sd_issue_flush, | 139 | .issue_flush = sd_issue_flush, |
140 | .prepare_flush = sd_prepare_flush, | ||
141 | .end_flush = sd_end_flush, | ||
142 | }; | 140 | }; |
143 | 141 | ||
144 | /* | 142 | /* |
@@ -346,6 +344,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) | |||
346 | 344 | ||
347 | if (block > 0xffffffff) { | 345 | if (block > 0xffffffff) { |
348 | SCpnt->cmnd[0] += READ_16 - READ_6; | 346 | SCpnt->cmnd[0] += READ_16 - READ_6; |
347 | SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; | ||
349 | SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; | 348 | SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; |
350 | SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; | 349 | SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; |
351 | SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; | 350 | SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; |
@@ -365,6 +364,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) | |||
365 | this_count = 0xffff; | 364 | this_count = 0xffff; |
366 | 365 | ||
367 | SCpnt->cmnd[0] += READ_10 - READ_6; | 366 | SCpnt->cmnd[0] += READ_10 - READ_6; |
367 | SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; | ||
368 | SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; | 368 | SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; |
369 | SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; | 369 | SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; |
370 | SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; | 370 | SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; |
@@ -373,6 +373,17 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) | |||
373 | SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; | 373 | SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; |
374 | SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; | 374 | SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; |
375 | } else { | 375 | } else { |
376 | if (unlikely(blk_fua_rq(rq))) { | ||
377 | /* | ||
378 | * This happens only if this drive failed | ||
379 | * 10byte rw command with ILLEGAL_REQUEST | ||
380 | * during operation and thus turned off | ||
381 | * use_10_for_rw. | ||
382 | */ | ||
383 | printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n"); | ||
384 | return 0; | ||
385 | } | ||
386 | |||
376 | SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); | 387 | SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); |
377 | SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); | 388 | SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); |
378 | SCpnt->cmnd[3] = (unsigned char) block & 0xff; | 389 | SCpnt->cmnd[3] = (unsigned char) block & 0xff; |
@@ -729,42 +740,13 @@ static int sd_issue_flush(struct device *dev, sector_t *error_sector) | |||
729 | return ret; | 740 | return ret; |
730 | } | 741 | } |
731 | 742 | ||
732 | static void sd_end_flush(request_queue_t *q, struct request *flush_rq) | 743 | static void sd_prepare_flush(request_queue_t *q, struct request *rq) |
733 | { | ||
734 | struct request *rq = flush_rq->end_io_data; | ||
735 | struct scsi_cmnd *cmd = rq->special; | ||
736 | unsigned int bytes = rq->hard_nr_sectors << 9; | ||
737 | |||
738 | if (!flush_rq->errors) { | ||
739 | spin_unlock(q->queue_lock); | ||
740 | scsi_io_completion(cmd, bytes, 0); | ||
741 | spin_lock(q->queue_lock); | ||
742 | } else if (blk_barrier_postflush(rq)) { | ||
743 | spin_unlock(q->queue_lock); | ||
744 | scsi_io_completion(cmd, 0, bytes); | ||
745 | spin_lock(q->queue_lock); | ||
746 | } else { | ||
747 | /* | ||
748 | * force journal abort of barriers | ||
749 | */ | ||
750 | end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors); | ||
751 | end_that_request_last(rq); | ||
752 | } | ||
753 | } | ||
754 | |||
755 | static int sd_prepare_flush(request_queue_t *q, struct request *rq) | ||
756 | { | 744 | { |
757 | struct scsi_device *sdev = q->queuedata; | ||
758 | struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev); | ||
759 | |||
760 | if (!sdkp || !sdkp->WCE) | ||
761 | return 0; | ||
762 | |||
763 | memset(rq->cmd, 0, sizeof(rq->cmd)); | 745 | memset(rq->cmd, 0, sizeof(rq->cmd)); |
764 | rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; | 746 | rq->flags |= REQ_BLOCK_PC; |
765 | rq->timeout = SD_TIMEOUT; | 747 | rq->timeout = SD_TIMEOUT; |
766 | rq->cmd[0] = SYNCHRONIZE_CACHE; | 748 | rq->cmd[0] = SYNCHRONIZE_CACHE; |
767 | return 1; | 749 | rq->cmd_len = 10; |
768 | } | 750 | } |
769 | 751 | ||
770 | static void sd_rescan(struct device *dev) | 752 | static void sd_rescan(struct device *dev) |
@@ -1427,10 +1409,18 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, | |||
1427 | sdkp->RCD = 0; | 1409 | sdkp->RCD = 0; |
1428 | } | 1410 | } |
1429 | 1411 | ||
1412 | sdkp->DPOFUA = (data.device_specific & 0x10) != 0; | ||
1413 | if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { | ||
1414 | printk(KERN_NOTICE "SCSI device %s: uses " | ||
1415 | "READ/WRITE(6), disabling FUA\n", diskname); | ||
1416 | sdkp->DPOFUA = 0; | ||
1417 | } | ||
1418 | |||
1430 | ct = sdkp->RCD + 2*sdkp->WCE; | 1419 | ct = sdkp->RCD + 2*sdkp->WCE; |
1431 | 1420 | ||
1432 | printk(KERN_NOTICE "SCSI device %s: drive cache: %s\n", | 1421 | printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", |
1433 | diskname, types[ct]); | 1422 | diskname, types[ct], |
1423 | sdkp->DPOFUA ? " w/ FUA" : ""); | ||
1434 | 1424 | ||
1435 | return; | 1425 | return; |
1436 | } | 1426 | } |
@@ -1462,6 +1452,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1462 | struct scsi_disk *sdkp = scsi_disk(disk); | 1452 | struct scsi_disk *sdkp = scsi_disk(disk); |
1463 | struct scsi_device *sdp = sdkp->device; | 1453 | struct scsi_device *sdp = sdkp->device; |
1464 | unsigned char *buffer; | 1454 | unsigned char *buffer; |
1455 | unsigned ordered; | ||
1465 | 1456 | ||
1466 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); | 1457 | SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); |
1467 | 1458 | ||
@@ -1498,7 +1489,21 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1498 | sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); | 1489 | sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); |
1499 | sd_read_cache_type(sdkp, disk->disk_name, buffer); | 1490 | sd_read_cache_type(sdkp, disk->disk_name, buffer); |
1500 | } | 1491 | } |
1501 | 1492 | ||
1493 | /* | ||
1494 | * We now have all cache related info, determine how we deal | ||
1495 | * with ordered requests. Note that as the current SCSI | ||
1496 | * dispatch function can alter request order, we cannot use | ||
1497 | * QUEUE_ORDERED_TAG_* even when ordered tag is supported. | ||
1498 | */ | ||
1499 | if (sdkp->WCE) | ||
1500 | ordered = sdkp->DPOFUA | ||
1501 | ? QUEUE_ORDERED_DRAIN_FUA : QUEUE_ORDERED_DRAIN_FLUSH; | ||
1502 | else | ||
1503 | ordered = QUEUE_ORDERED_DRAIN; | ||
1504 | |||
1505 | blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); | ||
1506 | |||
1502 | set_capacity(disk, sdkp->capacity); | 1507 | set_capacity(disk, sdkp->capacity); |
1503 | kfree(buffer); | 1508 | kfree(buffer); |
1504 | 1509 | ||
@@ -1598,6 +1603,7 @@ static int sd_probe(struct device *dev) | |||
1598 | strcpy(gd->devfs_name, sdp->devfs_name); | 1603 | strcpy(gd->devfs_name, sdp->devfs_name); |
1599 | 1604 | ||
1600 | gd->private_data = &sdkp->driver; | 1605 | gd->private_data = &sdkp->driver; |
1606 | gd->queue = sdkp->device->request_queue; | ||
1601 | 1607 | ||
1602 | sd_revalidate_disk(gd); | 1608 | sd_revalidate_disk(gd); |
1603 | 1609 | ||
@@ -1605,7 +1611,6 @@ static int sd_probe(struct device *dev) | |||
1605 | gd->flags = GENHD_FL_DRIVERFS; | 1611 | gd->flags = GENHD_FL_DRIVERFS; |
1606 | if (sdp->removable) | 1612 | if (sdp->removable) |
1607 | gd->flags |= GENHD_FL_REMOVABLE; | 1613 | gd->flags |= GENHD_FL_REMOVABLE; |
1608 | gd->queue = sdkp->device->request_queue; | ||
1609 | 1614 | ||
1610 | dev_set_drvdata(dev, sdkp); | 1615 | dev_set_drvdata(dev, sdkp); |
1611 | add_disk(gd); | 1616 | add_disk(gd); |